bazelbuild / rules_go

Go rules for Bazel
Apache License 2.0
1.36k stars 645 forks source link

`bazel coverage` does not respect "exclude_files" in nogo config #2232

Open yunjiz opened 4 years ago

yunjiz commented 4 years ago

What version of rules_go are you using?

v0.19.5

What version of gazelle are you using?

N/A

What version of Bazel are you using?

0.27.1

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

darwin18.0 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz

Any other potentially useful information about your toolchain?

What did you do?

I have create a simple repo for repro: https://github.com/Yunji-Leo/ReproNOGO

bazel coverage does not respect "exclude_files" in nogo config if "only_files" is not defined. However bazel build and bazel test works fine.

run bazel coverage src/demo/...

What did you expect to see?

build successful

What did you see instead?

Use --sandbox_debug to see verbose messages from the sandbox
compilepkg: nogo: errors found by nogo during build-time code analysis:
/private/var/tmp/_bazel_yunji/b1c64e481d6397575279d2b82276f282/sandbox/darwin-sandbox/37/execroot/__main__/src/demo/foo.go:11: unreachable code
Target //src/demo:go_default_library failed to build

note in nogo.json, "unreachable" is excluded from entire "src/"

weixiao-huang commented 4 years ago

Is there any progress of this bug?

jayconrod commented 4 years ago

@weixiao-huang No update

mmcloughlin commented 4 years ago

We ran into the same problem in our monorepo at Uber ATG. We've had to work around it by using select on a condition to disable nogo checks in coverage mode.