summaryrefslogtreecommitdiffstats
path: root/src/bootstrap/test.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bootstrap/test.rs')
-rw-r--r--src/bootstrap/test.rs168
1 files changed, 117 insertions, 51 deletions
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index 791c35c36..39cedfdac 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -16,6 +16,7 @@ use crate::cache::Interned;
use crate::compile;
use crate::config::TargetSelection;
use crate::dist;
+use crate::doc::DocumentationFormat;
use crate::flags::Subcommand;
use crate::native;
use crate::tool::{self, SourceType, Tool};
@@ -90,6 +91,42 @@ fn try_run_quiet(builder: &Builder<'_>, cmd: &mut Command) -> bool {
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub struct CrateJsonDocLint {
+ host: TargetSelection,
+}
+
+impl Step for CrateJsonDocLint {
+ type Output = ();
+ const ONLY_HOSTS: bool = true;
+ const DEFAULT: bool = true;
+
+ fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
+ run.path("src/tools/jsondoclint")
+ }
+
+ fn make_run(run: RunConfig<'_>) {
+ run.builder.ensure(CrateJsonDocLint { host: run.target });
+ }
+
+ fn run(self, builder: &Builder<'_>) {
+ let bootstrap_host = builder.config.build;
+ let compiler = builder.compiler(0, bootstrap_host);
+
+ let cargo = tool::prepare_tool_cargo(
+ builder,
+ compiler,
+ Mode::ToolBootstrap,
+ bootstrap_host,
+ "test",
+ "src/tools/jsondoclint",
+ SourceType::InTree,
+ &[],
+ );
+ try_run(builder, &mut cargo.into());
+ }
+}
+
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Linkcheck {
host: TargetSelection,
}
@@ -464,52 +501,23 @@ pub struct Miri {
target: TargetSelection,
}
-impl Step for Miri {
- type Output = ();
- const ONLY_HOSTS: bool = false;
-
- fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
- run.path("src/tools/miri")
- }
-
- fn make_run(run: RunConfig<'_>) {
- run.builder.ensure(Miri {
- stage: run.builder.top_stage,
- host: run.build_triple(),
- target: run.target,
- });
- }
-
- /// Runs `cargo test` for miri.
- fn run(self, builder: &Builder<'_>) {
- let stage = self.stage;
- let host = self.host;
- let target = self.target;
- let compiler = builder.compiler(stage, host);
- // We need the stdlib for the *next* stage, as it was built with this compiler that also built Miri.
- // Except if we are at stage 2, the bootstrap loop is complete and we can stick with our current stage.
- let compiler_std = builder.compiler(if stage < 2 { stage + 1 } else { stage }, host);
-
- let miri = builder
- .ensure(tool::Miri { compiler, target: self.host, extra_features: Vec::new() })
- .expect("in-tree tool");
- let _cargo_miri = builder
- .ensure(tool::CargoMiri { compiler, target: self.host, extra_features: Vec::new() })
- .expect("in-tree tool");
- // The stdlib we need might be at a different stage. And just asking for the
- // sysroot does not seem to populate it, so we do that first.
- builder.ensure(compile::Std::new(compiler_std, host));
- let sysroot = builder.sysroot(compiler_std);
-
- // # Run `cargo miri setup` for the given target.
+impl Miri {
+ /// Run `cargo miri setup` for the given target, return where the Miri sysroot was put.
+ pub fn build_miri_sysroot(
+ builder: &Builder<'_>,
+ compiler: Compiler,
+ miri: &Path,
+ target: TargetSelection,
+ ) -> String {
+ let miri_sysroot = builder.out.join(compiler.host.triple).join("miri-sysroot");
let mut cargo = tool::prepare_tool_cargo(
builder,
compiler,
Mode::ToolRustc,
- host,
+ compiler.host,
"run",
"src/tools/miri/cargo-miri",
- SourceType::Submodule,
+ SourceType::InTree,
&[],
);
cargo.add_rustc_lib_path(builder, compiler);
@@ -520,6 +528,8 @@ impl Step for Miri {
cargo.env("MIRI_LIB_SRC", builder.src.join("library"));
// Tell it where to find Miri.
cargo.env("MIRI", &miri);
+ // Tell it where to put the sysroot.
+ cargo.env("MIRI_SYSROOT", &miri_sysroot);
// Debug things.
cargo.env("RUST_BACKTRACE", "1");
@@ -534,7 +544,7 @@ impl Step for Miri {
cargo.arg("--print-sysroot");
// FIXME: Is there a way in which we can re-use the usual `run` helpers?
- let miri_sysroot = if builder.config.dry_run {
+ if builder.config.dry_run() {
String::new()
} else {
builder.verbose(&format!("running: {:?}", cargo));
@@ -547,7 +557,48 @@ impl Step for Miri {
let sysroot = stdout.trim_end();
builder.verbose(&format!("`cargo miri setup --print-sysroot` said: {:?}", sysroot));
sysroot.to_owned()
- };
+ }
+ }
+}
+
+impl Step for Miri {
+ type Output = ();
+ const ONLY_HOSTS: bool = false;
+
+ fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
+ run.path("src/tools/miri")
+ }
+
+ fn make_run(run: RunConfig<'_>) {
+ run.builder.ensure(Miri {
+ stage: run.builder.top_stage,
+ host: run.build_triple(),
+ target: run.target,
+ });
+ }
+
+ /// Runs `cargo test` for miri.
+ fn run(self, builder: &Builder<'_>) {
+ let stage = self.stage;
+ let host = self.host;
+ let target = self.target;
+ let compiler = builder.compiler(stage, host);
+ // We need the stdlib for the *next* stage, as it was built with this compiler that also built Miri.
+ // Except if we are at stage 2, the bootstrap loop is complete and we can stick with our current stage.
+ let compiler_std = builder.compiler(if stage < 2 { stage + 1 } else { stage }, host);
+
+ let miri = builder
+ .ensure(tool::Miri { compiler, target: self.host, extra_features: Vec::new() })
+ .expect("in-tree tool");
+ let _cargo_miri = builder
+ .ensure(tool::CargoMiri { compiler, target: self.host, extra_features: Vec::new() })
+ .expect("in-tree tool");
+ // The stdlib we need might be at a different stage. And just asking for the
+ // sysroot does not seem to populate it, so we do that first.
+ builder.ensure(compile::Std::new(compiler_std, host));
+ let sysroot = builder.sysroot(compiler_std);
+ // We also need a Miri sysroot.
+ let miri_sysroot = Miri::build_miri_sysroot(builder, compiler, &miri, target);
// # Run `cargo test`.
let mut cargo = tool::prepare_tool_cargo(
@@ -557,7 +608,7 @@ impl Step for Miri {
host,
"test",
"src/tools/miri",
- SourceType::Submodule,
+ SourceType::InTree,
&[],
);
cargo.add_rustc_lib_path(builder, compiler);
@@ -565,7 +616,6 @@ impl Step for Miri {
// miri tests need to know about the stage sysroot
cargo.env("MIRI_SYSROOT", &miri_sysroot);
cargo.env("MIRI_HOST_SYSROOT", sysroot);
- cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
cargo.env("MIRI", &miri);
// propagate --bless
if builder.config.cmd.bless() {
@@ -606,7 +656,6 @@ impl Step for Miri {
// Tell `cargo miri` where to find things.
cargo.env("MIRI_SYSROOT", &miri_sysroot);
cargo.env("MIRI_HOST_SYSROOT", sysroot);
- cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
cargo.env("MIRI", &miri);
// Debug things.
cargo.env("RUST_BACKTRACE", "1");
@@ -771,7 +820,10 @@ impl Step for RustdocTheme {
cmd.env("RUSTDOC_LINKER", linker);
}
if builder.is_fuse_ld_lld(self.compiler.host) {
- cmd.env("RUSTDOC_FUSE_LD_LLD", "1");
+ cmd.env(
+ "RUSTDOC_LLD_NO_THREADS",
+ util::lld_flag_no_threads(self.compiler.host.contains("windows")),
+ );
}
try_run(builder, &mut cmd);
}
@@ -819,7 +871,11 @@ impl Step for RustdocJSStd {
command.arg("--test-file").arg(path);
}
}
- builder.ensure(crate::doc::Std { target: self.target, stage: builder.top_stage });
+ builder.ensure(crate::doc::Std {
+ target: self.target,
+ stage: builder.top_stage,
+ format: DocumentationFormat::HTML,
+ });
builder.run(&mut command);
} else {
builder.info("No nodejs found, skipping \"src/test/rustdoc-js-std\" tests");
@@ -991,6 +1047,8 @@ impl Step for RustdocGUI {
// instead of hard-coding this test
if entry.file_name() == "link_to_definition" {
cargo.env("RUSTDOCFLAGS", "-Zunstable-options --generate-link-to-definition");
+ } else if entry.file_name() == "scrape_examples" {
+ cargo.arg("-Zrustdoc-scrape-examples=examples");
}
builder.run(&mut cargo);
}
@@ -1049,6 +1107,9 @@ impl Step for Tidy {
if builder.is_verbose() {
cmd.arg("--verbose");
}
+ if builder.config.cmd.bless() {
+ cmd.arg("--bless");
+ }
builder.info("tidy check");
try_run(builder, &mut cmd);
@@ -1378,6 +1439,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
cmd.arg("--src-base").arg(builder.src.join("src/test").join(suite));
cmd.arg("--build-base").arg(testdir(builder, compiler.host).join(suite));
+ cmd.arg("--sysroot-base").arg(builder.sysroot(compiler));
cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
cmd.arg("--suite").arg(suite);
cmd.arg("--mode").arg(mode);
@@ -1514,7 +1576,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
let mut copts_passed = false;
if builder.config.llvm_enabled() {
let llvm_config = builder.ensure(native::Llvm { target: builder.config.build });
- if !builder.config.dry_run {
+ if !builder.config.dry_run() {
let llvm_version = output(Command::new(&llvm_config).arg("--version"));
let llvm_components = output(Command::new(&llvm_config).arg("--components"));
// Remove trailing newline from llvm-config output.
@@ -1532,14 +1594,14 @@ note: if you're sure you want to do this, please open an issue as to why. In the
// requirement, but the `-L` library path is not propagated across
// separate compilations. We can add LLVM's library path to the
// platform-specific environment variable as a workaround.
- if !builder.config.dry_run && suite.ends_with("fulldeps") {
+ if !builder.config.dry_run() && suite.ends_with("fulldeps") {
let llvm_libdir = output(Command::new(&llvm_config).arg("--libdir"));
add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cmd);
}
// Only pass correct values for these flags for the `run-make` suite as it
// requires that a C++ compiler was configured which isn't always the case.
- if !builder.config.dry_run && matches!(suite, "run-make" | "run-make-fulldeps") {
+ if !builder.config.dry_run() && matches!(suite, "run-make" | "run-make-fulldeps") {
// The llvm/bin directory contains many useful cross-platform
// tools. Pass the path to run-make tests so they can use them.
let llvm_bin_path = llvm_config
@@ -1567,7 +1629,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
// Only pass correct values for these flags for the `run-make` suite as it
// requires that a C++ compiler was configured which isn't always the case.
- if !builder.config.dry_run && matches!(suite, "run-make" | "run-make-fulldeps") {
+ if !builder.config.dry_run() && matches!(suite, "run-make" | "run-make-fulldeps") {
cmd.arg("--cc")
.arg(builder.cc(target))
.arg("--cxx")
@@ -1647,6 +1709,10 @@ note: if you're sure you want to do this, please open an issue as to why. In the
cmd.arg("--channel").arg(&builder.config.channel);
+ if let Some(commit) = builder.config.download_rustc_commit() {
+ cmd.env("FAKE_DOWNLOAD_RUSTC_PREFIX", format!("/rustc/{commit}"));
+ }
+
builder.ci_env.force_coloring_in_ci(&mut cmd);
builder.info(&format!(