You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Good catch and good analysis. Thanks for reporting. We declare new cover files and apply coverage as a separate action before compilation. We should probably filter first, then apply coverage, then compile in the same action. Cgo needs to be done in there too, before coverage.
A proper fix may end up being a large refactoring, but we need to rewrite a lot of the cgo logic anyway. A simpler, faster fix should be possible, too.
I wonder if this means build tags in covered files get stripped out, too? I think coverage removes comments.
Imagine a package with two files:
main.go:
linux.go
Running "bazel coverage ..." on Linux works, but the same on Darwin fails with
main.go:3: undefined: Foo
The reason seems to be:
In coverage mode, rules_go generates a new file, "Coverage_linux.go" that contains coverage-specific stuff.
It then passes Coverage_linux.go to https://golang.org/src/go/build/build.go:1671, which causes the file to be dropped on non-Linux OS.
Looking at the comment in build.go, the file "linux.go" should be accepted on non-linux platforms.
We can easily work around this problem so no hurry to fix it, but I think it's still a bug.
The text was updated successfully, but these errors were encountered: