go.nvim icon indicating copy to clipboard operation
go.nvim copied to clipboard

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

Open maruel opened this issue 1 year ago • 0 comments

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: https://github.com/ray-x/go.nvim/blob/6368756601a358b1491ac2ff10d0e2939a76df5e/lua/go/coverage.lua#L387 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: https://github.com/ray-x/go.nvim/blob/6368756601a358b1491ac2ff10d0e2939a76df5e/lua/go/coverage.lua#L377-L385

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.

maruel avatar Nov 21 '24 21:11 maruel