-
-
Notifications
You must be signed in to change notification settings - Fork 661
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
go_test: better diagnostic needed for test dependency cycle #2808
Comments
I have a smaller repro of the same issue here. As above, commenting out the |
My guess is that this is caused by a a circular import. If you change the package name in An internal test (files without a Unfortunately it's hard to provide good diagnostics here. The recompilation logic has to be done during the analysis stage, since we need to create an action to recompile each package. But we can't do any I/O, so we don't actually know which source files are internal or external or whether there's an import cycle. |
So, assuming that there is a circular import, how do I track it down, and how do I repair it? I assume that we'll have to rewrite some of our |
Normally, I'd recommend For internal and external tests, there's usually no need to distinguish the two in build files since the files are filtered and split up at execution time. You can split them into separate Avoiding import cycles (in tests or otherwise) is the main issue. I don't really have a general strategy to recommend there. The |
I think my confusion comes from the fact that this project already builds fine with the
|
I ran into this issue and came up with a minimal repro, in case it's helpful for anyone trying to address this issue: https://github.com/bduffany/rules_go_bug_repro Here's the structure:
The error message is:
But
|
@bduffany
|
I think what's needed here is a better error message. When It would be better to pass in those dependencies using a different flag, so that the builder can print a helpful error if they're imported. |
Filed cockroachdb/cockroach#60441 to fix the issue on our end. I was having trouble finding the cyclic dependency because it was only in the |
I've faced this issue twice in the last couple of weeks, would be nice to provide better error messaging even if it's just a hint along the lines of
|
If anyone wants to get started on a PR based on #2808 (comment), I can provide support. |
What version of rules_go are you using?
0.24.9, but I've also checked 0.25.1 and determined that this doesn't fix the bug.
What version of gazelle are you using?
493b9adf67665beede36502c2094496af9f245a3
, but as above I've checked with 0.22.3 and that didn't fix it.What version of Bazel are you using?
bazel 3.7.1-homebrew
Does this issue reproduce with the latest releases of all the above?
Yes for the first two, but I didn't check with the latest Bazel.
What operating system and processor architecture are you using?
macOS 10.15.7,
x86_64
Any other potentially useful information about your toolchain?
Nothing to note.
What did you do?
The error can be reproduced at the latest
master
of https://github.com/cockroachdb/cockroach (as of this writing,39893f8b75243932263e55cfce9e056673be245a
) withbazel test pkg/util/uuid:uuid_test
. (Sorry, I wasn't able to isolate a smaller repro yet. 😬) Running this command generates the error I've pasted below, namely, thepkg/testutils/skip
package isn't being linked with the test sources.I've verified that the
importpath
s and dependencies all seem correct. Nonetheless, running with--sandbox_debug --verbose_failures
demonstrates that theskip
package isn't even being passed to the compiler:I haven't identified the exact source of the failure yet, but this does seem to be related in some way to the indirect dependency that the test has on
pkg/util:util_go_proto
. To demonstrate this, you can see this commit, which strips out a bunch of unnecessary stuff, and still reproduces the failure. However, commenting out theembed = [":util_go_proto"],
line inpkg/util/BUILD.bazel
suddenly causes the test to pass.What did you expect to see?
No build failure.
What did you see instead?
The error looks like this:
The text was updated successfully, but these errors were encountered: