Skip to content

Commit 198a154

Browse files
authored
Rollup merge of rust-lang#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 rust-lang#91071.
2 parents e4b4bf1 + 26cc0be commit 198a154

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

src/bootstrap/test.rs

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,6 +2065,7 @@ impl Step for Crate {
20652065
}
20662066
}
20672067

2068+
/// Rustdoc is special in various ways, which is why this step is different from `Crate`.
20682069
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
20692070
pub struct CrateRustdoc {
20702071
host: TargetSelection,
@@ -2092,11 +2093,15 @@ impl Step for CrateRustdoc {
20922093
let test_kind = self.test_kind;
20932094
let target = self.host;
20942095

2095-
// Use the previous stage compiler to reuse the artifacts that are
2096-
// created when running compiletest for src/test/rustdoc. If this used
2097-
// `compiler`, then it would cause rustdoc to be built *again*, which
2098-
// isn't really necessary.
2099-
let compiler = builder.compiler_for(builder.top_stage, target, target);
2096+
let compiler = if builder.config.download_rustc {
2097+
builder.compiler(builder.top_stage, target)
2098+
} else {
2099+
// Use the previous stage compiler to reuse the artifacts that are
2100+
// created when running compiletest for src/test/rustdoc. If this used
2101+
// `compiler`, then it would cause rustdoc to be built *again*, which
2102+
// isn't really necessary.
2103+
builder.compiler_for(builder.top_stage, target, target)
2104+
};
21002105
builder.ensure(compile::Rustc { compiler, target });
21012106

21022107
let mut cargo = tool::prepare_tool_cargo(
@@ -2112,6 +2117,15 @@ impl Step for CrateRustdoc {
21122117
if test_kind.subcommand() == "test" && !builder.fail_fast {
21132118
cargo.arg("--no-fail-fast");
21142119
}
2120+
match builder.doc_tests {
2121+
DocTests::Only => {
2122+
cargo.arg("--doc");
2123+
}
2124+
DocTests::No => {
2125+
cargo.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]);
2126+
}
2127+
DocTests::Yes => {}
2128+
}
21152129

21162130
cargo.arg("-p").arg("rustdoc:0.0.0");
21172131

@@ -2136,6 +2150,8 @@ impl Step for CrateRustdoc {
21362150
// sets up the dylib path for the *host* (stage1/lib), which is the
21372151
// wrong directory.
21382152
//
2153+
// Recall that we special-cased `compiler_for(top_stage)` above, so we always use stage1.
2154+
//
21392155
// It should be considered to just stop running doctests on
21402156
// librustdoc. There is only one test, and it doesn't look too
21412157
// important. There might be other ways to avoid this, but it seems
@@ -2144,8 +2160,15 @@ impl Step for CrateRustdoc {
21442160
// See also https://github.com/rust-lang/rust/issues/13983 where the
21452161
// host vs target dylibs for rustdoc are consistently tricky to deal
21462162
// with.
2163+
//
2164+
// Note that this set the host libdir for `download_rustc`, which uses a normal rust distribution.
2165+
let libdir = if builder.config.download_rustc {
2166+
builder.rustc_libdir(compiler)
2167+
} else {
2168+
builder.sysroot_libdir(compiler, target).to_path_buf()
2169+
};
21472170
let mut dylib_path = dylib_path();
2148-
dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target)));
2171+
dylib_path.insert(0, PathBuf::from(&*libdir));
21492172
cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
21502173

21512174
if !builder.config.verbose_tests {

0 commit comments

Comments
 (0)