-
Notifications
You must be signed in to change notification settings - Fork 389
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
Unable to test Go program that involves "@org_golang_google_grpc" elsewhere in its source tree #684
Comments
What's weird here is that this problem seems to arise only when using a recursive target path, presumably including something that shouldn't be included. I can run bazel test <target for package with test>, and bazel build <target for executable program>, but there's some other target in this package tree that aggravates this behavior. [Time passes...] Ah, I think I see a problem: By way of bazel query --output=build //my/redacted/project/..., I see that there are targets for building and pushing container images using the Given that, is there a way to exclude them from consideration when trying to "run all the tests in this project?" |
I'm not sure if there's a better way to go about this, but I found that this worked:
Alternately:
|
I couldn't reproduce this. I was able to build a Could you post a minimum example that demonstrates this issue, either as a repo or a gist? Please give the specific commands you're running. If you could run with Based on the error, I'm speculating that you're cross-compiling something using the |
Generally |
Sorry for the confusion. That |
My various targets using the Once I removed the "goos" and "goarch" attributes from my |
What version of gazelle are you using?
0.19.1
What version of rules_go are you using?
0.20.3
What version of Bazel are you using?
2.0.0
Does this issue reproduce with the latest releases of all the above?
Yes, these are latest I have available today.
What operating system and processor architecture are you using?
macOS Mojave (10.14.6)
AMD64
What did you do?
Within a Bazel workspace with dependencies managed by Gazelle, and a program that depends upon the google.golang.org/grpc Go module at version "v1.23.0," first build the program with bazel build <main target path>. Confirm that the program builds without any problems.
Next, in order to run some unit tests written in Go, run bazel test <target path>/.... Observe that the attempt fails. Try to build all the targets under that path with bazel build <target path>/.... Observe that that attempt fails too.
What did you expect to see?
Bazel would build the unit test program, execute it, and fail if any of the unit tests failed, noting the path to the failure log, or exit successfully if all the unit tests passed. It would not try to build any Go packages using source files not intended for use on macOS.
What did you see instead?
Bazel builds and runs the unit test program (there's just one Go package with tests beneath this tree), but fails trying to compile a different package, due to missing dependencies that are related to Linux. Again, note that I'm running this on macOS.
It's not clear why Bazel is trying to build this
internal/syscall
package for@org_golang_google_grpc
here, and why it's trying to build Go source files that are intended only for use on Linux.I can cut testing out of the picture, and use bazel build to trigger this same problem, if I use not just the target path to my Go executable program, but to a whole tree recursively:
I noted this problem originally in #293, by way of a comment (#293 (comment)) about what looked like an earlier fix this problem in bazel-contrib/rules_go#2009 that was since removed in bazel-contrib/rules_go#2126.
My questions:
The text was updated successfully, but these errors were encountered: