-
Notifications
You must be signed in to change notification settings - Fork 426
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
fix: rust_doc_test
failure to find params file
#1418
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
93558b9
to
444fd2d
Compare
#[clap( | ||
name = "cargo-bazel", | ||
about = "crate_universe` is a collection of tools which use Cargo to generate build targets for Bazel.", | ||
version | ||
)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this change, the the other changes to #[clap(author ...
are not relevant to the underlying fix, but the changes were necessary to get the rust_doc_test test passing on Windows
7174af4
to
e4c6de3
Compare
Turns out this fix isn't perfect, we still hit character limits on Windows. Specifically if the crate you're adding a doc test for has a large dependency tree you can hit |
e4c6de3
to
a738070
Compare
70bd4a0
to
8c93dae
Compare
Bump on this @illicitonion, I updated the PR if you have a chance to review :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thanks for the contribution!
Just one naming/commenting comment :)
tools/rustdoc/rustdoc_test_writer.rs
Outdated
/// The path where we can copy the params file Bazel might generate | ||
optional_params_file: PathBuf, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// The path where we can copy the params file Bazel might generate | |
optional_params_file: PathBuf, | |
/// If Bazel generated a params file, we may need to strip roots from it. | |
/// This is the path where we will output our stripped params file. | |
optional_output_params_file: PathBuf, |
* Declares our own params file, that we copy the Bazel Args into when necessary * Updates crate_universe and runs the rust_doc_test tests
8c93dae
to
dde88da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Thanks for merging! |
Context
Today
rust_doc_test
fails when Bazel Args "spill" over to a file. To a user this failure is seemingly random because Bazel will auto-magically spillArgs
onto a file when there are too many args for the command line, or when it can improve performance. The generated test script, e.g.hellolib.rustdoc_test.sh
, is then run from runfiles, which is separate from the Arg file Bazel created.It's especially tricky because the amount of command line args Windows supports is < macOS < Linux, so there's a "silent" OS dependency here too.
Solution
This PR fixes the issue by manually declaring a params file, e.g.
hellolib.rustdoc_opt_params
, that is a sibling file to our test runner,hellolib.rustdoc_test.sh
. We then pass the path of this optional params file to our test writer. The test writer checks for the presence of the Bazel Args file, and if it finds one, copies the content into our manually declared params file.Our manually declared params file then gets moved into runfiles with our test script. The test script can then find the file, and
rustdoc
picks up the args.Note: Today we detect the params file by matching a prefix of
@
and suffix of.rustdoc_test.sh-0.params
. I'm not sure if this is accurate for all systems, or all versions of bazel. I tried theuse_param_file
option onArgs
to make it easier to detect a params file, but that seem to overwrite (or just generally effect) the other arguments we'd pass torustdoc_test_writer.rs
.Fixes #1233