fix: rust_doc_test failure to find params file#1418
fix: rust_doc_test failure to find params file#1418illicitonion merged 4 commits intobazelbuild:mainfrom
rust_doc_test failure to find params file#1418Conversation
|
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.
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 :) |
illicitonion
left a comment
There was a problem hiding this comment.
LGTM - thanks for the contribution!
Just one naming/commenting comment :)
| /// The path where we can copy the params file Bazel might generate | ||
| optional_params_file: PathBuf, |
There was a problem hiding this comment.
| /// 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
|
Thanks for merging! |
Context
Today
rust_doc_testfails when Bazel Args "spill" over to a file. To a user this failure is seemingly random because Bazel will auto-magically spillArgsonto 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
rustdocpicks 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_fileoption onArgsto 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