Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code coverage covers too much by default and runs in the wrong directory #526

Open
maruel opened this issue Nov 21, 2024 · 0 comments
Open

Comments

@maruel
Copy link

maruel commented Nov 21, 2024

First, the code coverage integration is really nice. Thanks Ray for doing this, it is really appreciated!

Problem

The cwd argument is not set for jobstart()?

At the moment, code coverage :GoCoverage runs with "./..." by default, unless "-p" is provided. Ref:

argsstr = '.' .. utils.sep() .. '...'

I suspect this is done as a workaround for the lack of cwd argument.

Generally speaking, running unit tests in subpackages is quite inefficient when one only wants the data for the current file(s) so the default should be flipped and default instead to "." with the cwd flag correctly set. These lines are unnecessary IMHO:

go.nvim/lua/go/coverage.lua

Lines 377 to 385 in 6368756

log('extend pkg')
table.remove(args, 1)
local pkg = require('go.package').pkg_from_path(nil, vim.api.nvim_get_current_buf())
if vfn.empty(pkg) == 1 then
vim.notify('No package found in current directory.')
argsstr = ''
else
argsstr = pkg[1]
end

Repro

  • With a go package with foo/bar.go, foo/bar_test.go, baz/baz.go
  • cd baz
  • nvim ../foo/bar.go
  • :GoCoverage

It currently fails to show any coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant