diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-04-09 18:26:26 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-09 18:26:26 +0200 |
| commit | 198a1548ea4c25e3756d70bb2cafed6bb1860d6a (patch) | |
| tree | c5c209f17952529e68d5d94eb2be7fdd95b332f8 | |
| parent | e4b4bf1535ab3539c4573c8d960214c6e49eb138 (diff) | |
| parent | 26cc0be248b2f013f96bf47ccc24f99e4424c991 (diff) | |
| download | rust-198a1548ea4c25e3756d70bb2cafed6bb1860d6a.tar.gz rust-198a1548ea4c25e3756d70bb2cafed6bb1860d6a.zip | |
Rollup merge of #95369 - jyn514:test-rustdoc, r=Mark-Simulacrum
Fix `x test src/librustdoc` with `download-rustc` enabled The problem was two-fold: - Bootstrap was hard-coding that unit tests should always run with stage1, not stage2, and - It hard-coded the sysroot layout in stage1, which puts libLLVM.so in `lib/rustlib/` instead of just `lib/`. This also takes the liberty of fixing `test src/librustdoc --no-doc`, which has been broken since it was first added. It would be nice at some point to unify this logic with other tests; I opened a Zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Inconsistency.20in.20.60x.20test.60 Fixes https://github.com/rust-lang/rust/issues/91071.
| -rw-r--r-- | src/bootstrap/test.rs | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 339b7a8d1e6..81200ba60b0 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -2065,6 +2065,7 @@ impl Step for Crate { } } +/// Rustdoc is special in various ways, which is why this step is different from `Crate`. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct CrateRustdoc { host: TargetSelection, @@ -2092,11 +2093,15 @@ impl Step for CrateRustdoc { let test_kind = self.test_kind; let target = self.host; - // Use the previous stage compiler to reuse the artifacts that are - // created when running compiletest for src/test/rustdoc. If this used - // `compiler`, then it would cause rustdoc to be built *again*, which - // isn't really necessary. - let compiler = builder.compiler_for(builder.top_stage, target, target); + let compiler = if builder.config.download_rustc { + builder.compiler(builder.top_stage, target) + } else { + // Use the previous stage compiler to reuse the artifacts that are + // created when running compiletest for src/test/rustdoc. If this used + // `compiler`, then it would cause rustdoc to be built *again*, which + // isn't really necessary. + builder.compiler_for(builder.top_stage, target, target) + }; builder.ensure(compile::Rustc { compiler, target }); let mut cargo = tool::prepare_tool_cargo( @@ -2112,6 +2117,15 @@ impl Step for CrateRustdoc { if test_kind.subcommand() == "test" && !builder.fail_fast { cargo.arg("--no-fail-fast"); } + match builder.doc_tests { + DocTests::Only => { + cargo.arg("--doc"); + } + DocTests::No => { + cargo.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]); + } + DocTests::Yes => {} + } cargo.arg("-p").arg("rustdoc:0.0.0"); @@ -2136,6 +2150,8 @@ impl Step for CrateRustdoc { // sets up the dylib path for the *host* (stage1/lib), which is the // wrong directory. // + // Recall that we special-cased `compiler_for(top_stage)` above, so we always use stage1. + // // It should be considered to just stop running doctests on // librustdoc. There is only one test, and it doesn't look too // important. There might be other ways to avoid this, but it seems @@ -2144,8 +2160,15 @@ impl Step for CrateRustdoc { // See also https://github.com/rust-lang/rust/issues/13983 where the // host vs target dylibs for rustdoc are consistently tricky to deal // with. + // + // Note that this set the host libdir for `download_rustc`, which uses a normal rust distribution. + let libdir = if builder.config.download_rustc { + builder.rustc_libdir(compiler) + } else { + builder.sysroot_libdir(compiler, target).to_path_buf() + }; let mut dylib_path = dylib_path(); - dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target))); + dylib_path.insert(0, PathBuf::from(&*libdir)); cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap()); if !builder.config.verbose_tests { |
