Repository navigation
Have rust_test put its compilation outputs in a subdirectory - #1434
Conversation
|
I believe the current CI failure: I shortened it with the last commit, but CI seems slow today, so I'm marking the PR ready for review now. |
UebelAndre
left a comment
There was a problem hiding this comment.
Thanks! Looks good to me, great work!
| ) | ||
|
|
||
| def _rust_test_common(ctx, toolchain, output): | ||
| def _rust_test_common(ctx): |
There was a problem hiding this comment.
nit: Did this need to change? If _rust_test_impl is just gonna call _rust_test_common, a function that's only parameter is ctx then why the layer of abstraction?
There was a problem hiding this comment.
Before this PR, the output file was declared in _rust_test_impl. As per the changes, it now has a test_{hash} subdirectory, and in order to obtain the hash we need to have the crate root (or the symlink to it in case we had to create such a symlink in order to support generated files). So I would either have to move a lot of the logic from _rust_test_common to _rust_test_impl in order to be able to create the output filename, or to move the declaration of the output file into _rust_test_common. I went with the second option, but I agree that the layer of abstraction is not necessary anymore, and as such I removed _rust_test_common altogether now.
The reason why I put the test outputs into a test_{hash} directory instead of just test or something similar is to avoid conflicts with source directories.
I'll go ahead and merge this PR as you've marked this comment as a nit, but feel free to continue the discussion.
Pull request was closed
This is supposed to fix the long standing Windows flakiness as described in #1427 (comment)
Initially I thought it's an issue with
rustdoc_test, however the actual issue is thatrust_binaryand itsrust_testhave the same crate name and generate the same intermediary.ofiles. For sandboxed builds this is not an issue, as the actions are isolated, however, we have a race condition in non-sandboxed builds (Windows):Let's consider the following build:
The
bin_with_transitive_proc_macrocompile action will create the following intermediate file:bazel-out/k8-fastbuild/bin/test/unit/rustdoc/bin_with_transitive_proc_macro.bin_with_transitive_proc_macro.573369dc-cgu.2.rcgu.o, as will thebin_with_transitive_proc_macro_testaction. These two files differ slightly (as the second action is for a test), namely thebin_with_transitive_proc_macrooutput has the following symbols:while the
bin_with_transitive_proc_macro_test.ooutput looks like this:Now, when the two actions run in parallel, it can happen that
bin_with_transitive_proc_macrocreates the output, andbin_with_transitive_proc_macro_testoverwrites it. Then, at linking time forbin_with_transitive_proc_macro,rustcwill complain:This is because
bin_with_transitive_proc_macrois not a test and as such is not linked againstlibtest.This PR fixes the issue by directing the compilation outputs of
rust_testto be under atest-{hash}directory.