1 //! Implementation of the test-related targets of the build system.
3 //! This file implements the various regression test suites that we execute on
7 use std::ffi::OsString;
11 use std::path::{Path, PathBuf};
12 use std::process::{Command, Stdio};
14 use crate::builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
15 use crate::cache::Interned;
17 use crate::config::TargetSelection;
19 use crate::flags::Subcommand;
21 use crate::tool::{self, SourceType, Tool};
22 use crate::toolstate::ToolState;
23 use crate::util::{self, add_link_lib_path, dylib_path, dylib_path_var, output, t};
24 use crate::{envify, CLang, DocTests, GitRepo, Mode};
26 const ADB_TEST_DIR: &str = "/data/tmp/work";
28 /// The two modes of the test runner; tests or benchmarks.
29 #[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, PartialOrd, Ord)]
33 /// Run `cargo bench`.
37 impl From<Kind> for TestKind {
38 fn from(kind: Kind) -> Self {
40 Kind::Test => TestKind::Test,
41 Kind::Bench => TestKind::Bench,
42 _ => panic!("unexpected kind in crate: {:?}", kind),
48 // Return the cargo subcommand for this test kind
49 fn subcommand(self) -> &'static str {
51 TestKind::Test => "test",
52 TestKind::Bench => "bench",
57 impl fmt::Display for TestKind {
58 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
59 f.write_str(match *self {
60 TestKind::Test => "Testing",
61 TestKind::Bench => "Benchmarking",
66 fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool {
67 if !builder.fail_fast {
68 if !builder.try_run(cmd) {
69 let mut failures = builder.delayed_failures.borrow_mut();
70 failures.push(format!("{:?}", cmd));
79 fn try_run_quiet(builder: &Builder<'_>, cmd: &mut Command) -> bool {
80 if !builder.fail_fast {
81 if !builder.try_run_quiet(cmd) {
82 let mut failures = builder.delayed_failures.borrow_mut();
83 failures.push(format!("{:?}", cmd));
87 builder.run_quiet(cmd);
92 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
93 pub struct Linkcheck {
94 host: TargetSelection,
97 impl Step for Linkcheck {
99 const ONLY_HOSTS: bool = true;
100 const DEFAULT: bool = true;
102 /// Runs the `linkchecker` tool as compiled in `stage` by the `host` compiler.
104 /// This tool in `src/tools` will verify the validity of all our links in the
105 /// documentation to ensure we don't have a bunch of dead ones.
106 fn run(self, builder: &Builder<'_>) {
107 let host = self.host;
108 let hosts = &builder.hosts;
109 let targets = &builder.targets;
111 // if we have different hosts and targets, some things may be built for
112 // the host (e.g. rustc) and others for the target (e.g. std). The
113 // documentation built for each will contain broken links to
114 // docs built for the other platform (e.g. rustc linking to cargo)
115 if (hosts != targets) && !hosts.is_empty() && !targets.is_empty() {
117 "Linkcheck currently does not support builds with different hosts and targets.
118 You can skip linkcheck with --exclude src/tools/linkchecker"
122 builder.info(&format!("Linkcheck ({})", host));
124 // Test the linkchecker itself.
125 let bootstrap_host = builder.config.build;
126 let compiler = builder.compiler(0, bootstrap_host);
127 let cargo = tool::prepare_tool_cargo(
133 "src/tools/linkchecker",
137 try_run(builder, &mut cargo.into());
139 // Build all the default documentation.
140 builder.default_doc(&[]);
142 // Run the linkchecker.
143 let _time = util::timeit(&builder);
146 builder.tool_cmd(Tool::Linkchecker).arg(builder.out.join(host.triple).join("doc")),
150 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
151 let builder = run.builder;
152 let run = run.path("src/tools/linkchecker");
153 run.default_condition(builder.config.docs)
156 fn make_run(run: RunConfig<'_>) {
157 run.builder.ensure(Linkcheck { host: run.target });
161 fn check_if_tidy_is_installed() -> bool {
164 .stdout(Stdio::null())
166 .map_or(false, |status| status.success())
169 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
170 pub struct HtmlCheck {
171 target: TargetSelection,
174 impl Step for HtmlCheck {
176 const DEFAULT: bool = true;
177 const ONLY_HOSTS: bool = true;
179 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
180 let run = run.path("src/tools/html-checker");
181 run.lazy_default_condition(Box::new(check_if_tidy_is_installed))
184 fn make_run(run: RunConfig<'_>) {
185 run.builder.ensure(HtmlCheck { target: run.target });
188 fn run(self, builder: &Builder<'_>) {
189 if !check_if_tidy_is_installed() {
190 eprintln!("not running HTML-check tool because `tidy` is missing");
192 "Note that `tidy` is not the in-tree `src/tools/tidy` but needs to be installed"
194 panic!("Cannot run html-check tests");
196 // Ensure that a few different kinds of documentation are available.
197 builder.default_doc(&[]);
198 builder.ensure(crate::doc::Rustc { target: self.target, stage: builder.top_stage });
200 try_run(builder, builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target)));
204 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
205 pub struct Cargotest {
207 host: TargetSelection,
210 impl Step for Cargotest {
212 const ONLY_HOSTS: bool = true;
214 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
215 run.path("src/tools/cargotest")
218 fn make_run(run: RunConfig<'_>) {
219 run.builder.ensure(Cargotest { stage: run.builder.top_stage, host: run.target });
222 /// Runs the `cargotest` tool as compiled in `stage` by the `host` compiler.
224 /// This tool in `src/tools` will check out a few Rust projects and run `cargo
225 /// test` to ensure that we don't regress the test suites there.
226 fn run(self, builder: &Builder<'_>) {
227 let compiler = builder.compiler(self.stage, self.host);
228 builder.ensure(compile::Rustc::new(compiler, compiler.host));
229 let cargo = builder.ensure(tool::Cargo { compiler, target: compiler.host });
231 // Note that this is a short, cryptic, and not scoped directory name. This
232 // is currently to minimize the length of path on Windows where we otherwise
233 // quickly run into path name limit constraints.
234 let out_dir = builder.out.join("ct");
235 t!(fs::create_dir_all(&out_dir));
237 let _time = util::timeit(&builder);
238 let mut cmd = builder.tool_cmd(Tool::CargoTest);
243 .args(builder.config.cmd.test_args())
244 .env("RUSTC", builder.rustc(compiler))
245 .env("RUSTDOC", builder.rustdoc(compiler)),
250 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
253 host: TargetSelection,
256 impl Step for Cargo {
258 const ONLY_HOSTS: bool = true;
260 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
261 run.path("src/tools/cargo")
264 fn make_run(run: RunConfig<'_>) {
265 run.builder.ensure(Cargo { stage: run.builder.top_stage, host: run.target });
268 /// Runs `cargo test` for `cargo` packaged with Rust.
269 fn run(self, builder: &Builder<'_>) {
270 let compiler = builder.compiler(self.stage, self.host);
272 builder.ensure(tool::Cargo { compiler, target: self.host });
273 let mut cargo = tool::prepare_tool_cargo(
280 SourceType::Submodule,
284 if !builder.fail_fast {
285 cargo.arg("--no-fail-fast");
287 cargo.arg("--").args(builder.config.cmd.test_args());
289 // Don't run cross-compile tests, we may not have cross-compiled libstd libs
291 cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
292 // Disable a test that has issues with mingw.
293 cargo.env("CARGO_TEST_DISABLE_GIT_CLI", "1");
294 // Forcibly disable tests using nightly features since any changes to
295 // those features won't be able to land.
296 cargo.env("CARGO_TEST_DISABLE_NIGHTLY", "1");
298 cargo.env("PATH", &path_for_cargo(builder, compiler));
300 try_run(builder, &mut cargo.into());
304 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
307 host: TargetSelection,
312 const ONLY_HOSTS: bool = true;
314 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
315 run.path("src/tools/rls")
318 fn make_run(run: RunConfig<'_>) {
319 run.builder.ensure(Rls { stage: run.builder.top_stage, host: run.target });
322 /// Runs `cargo test` for the rls.
323 fn run(self, builder: &Builder<'_>) {
324 let stage = self.stage;
325 let host = self.host;
326 let compiler = builder.compiler(stage, host);
329 builder.ensure(tool::Rls { compiler, target: self.host, extra_features: Vec::new() });
330 if build_result.is_none() {
331 eprintln!("failed to test rls: could not build");
335 let mut cargo = tool::prepare_tool_cargo(
342 SourceType::Submodule,
346 cargo.add_rustc_lib_path(builder, compiler);
347 cargo.arg("--").args(builder.config.cmd.test_args());
349 if try_run(builder, &mut cargo.into()) {
350 builder.save_toolstate("rls", ToolState::TestPass);
355 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
358 host: TargetSelection,
361 impl Step for Rustfmt {
363 const ONLY_HOSTS: bool = true;
365 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
366 run.path("src/tools/rustfmt")
369 fn make_run(run: RunConfig<'_>) {
370 run.builder.ensure(Rustfmt { stage: run.builder.top_stage, host: run.target });
373 /// Runs `cargo test` for rustfmt.
374 fn run(self, builder: &Builder<'_>) {
375 let stage = self.stage;
376 let host = self.host;
377 let compiler = builder.compiler(stage, host);
380 .ensure(tool::Rustfmt { compiler, target: self.host, extra_features: Vec::new() })
381 .expect("in-tree tool");
383 let mut cargo = tool::prepare_tool_cargo(
394 let dir = testdir(builder, compiler.host);
395 t!(fs::create_dir_all(&dir));
396 cargo.env("RUSTFMT_TEST_DIR", dir);
398 cargo.add_rustc_lib_path(builder, compiler);
400 builder.run(&mut cargo.into());
404 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
405 pub struct RustDemangler {
407 host: TargetSelection,
410 impl Step for RustDemangler {
412 const ONLY_HOSTS: bool = true;
414 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
415 run.path("src/tools/rust-demangler")
418 fn make_run(run: RunConfig<'_>) {
419 run.builder.ensure(RustDemangler { stage: run.builder.top_stage, host: run.target });
422 /// Runs `cargo test` for rust-demangler.
423 fn run(self, builder: &Builder<'_>) {
424 let stage = self.stage;
425 let host = self.host;
426 let compiler = builder.compiler(stage, host);
428 let rust_demangler = builder
429 .ensure(tool::RustDemangler { compiler, target: self.host, extra_features: Vec::new() })
430 .expect("in-tree tool");
431 let mut cargo = tool::prepare_tool_cargo(
437 "src/tools/rust-demangler",
442 let dir = testdir(builder, compiler.host);
443 t!(fs::create_dir_all(&dir));
445 cargo.env("RUST_DEMANGLER_DRIVER_PATH", rust_demangler);
447 cargo.arg("--").args(builder.config.cmd.test_args());
449 cargo.add_rustc_lib_path(builder, compiler);
451 builder.run(&mut cargo.into());
455 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
458 host: TargetSelection,
463 const ONLY_HOSTS: bool = true;
465 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
466 run.path("src/tools/miri")
469 fn make_run(run: RunConfig<'_>) {
470 run.builder.ensure(Miri { stage: run.builder.top_stage, host: run.target });
473 /// Runs `cargo test` for miri.
474 fn run(self, builder: &Builder<'_>) {
475 let stage = self.stage;
476 let host = self.host;
477 let compiler = builder.compiler(stage, host);
478 // We need the stdlib for the *next* stage, as it was built with this compiler that also built Miri.
479 // Except if we are at stage 2, the bootstrap loop is complete and we can stick with our current stage.
480 let compiler_std = builder.compiler(if stage < 2 { stage + 1 } else { stage }, host);
483 builder.ensure(tool::Miri { compiler, target: self.host, extra_features: Vec::new() });
484 let cargo_miri = builder.ensure(tool::CargoMiri {
487 extra_features: Vec::new(),
489 // The stdlib we need might be at a different stage. And just asking for the
490 // sysroot does not seem to populate it, so we do that first.
491 builder.ensure(compile::Std::new(compiler_std, host));
492 let sysroot = builder.sysroot(compiler_std);
493 if let (Some(miri), Some(_cargo_miri)) = (miri, cargo_miri) {
495 builder.cargo(compiler, Mode::ToolRustc, SourceType::Submodule, host, "install");
497 // Configure `cargo install` path. cargo adds a `bin/`.
498 cargo.env("CARGO_INSTALL_ROOT", &builder.out);
500 let mut cargo = Command::from(cargo);
501 if !try_run(builder, &mut cargo) {
505 // # Run `cargo miri setup`.
506 let mut cargo = tool::prepare_tool_cargo(
512 "src/tools/miri/cargo-miri",
513 SourceType::Submodule,
516 cargo.add_rustc_lib_path(builder, compiler);
517 cargo.arg("--").arg("miri").arg("setup");
519 // Tell `cargo miri setup` where to find the sources.
520 cargo.env("XARGO_RUST_SRC", builder.src.join("library"));
521 // Tell it where to find Miri.
522 cargo.env("MIRI", &miri);
524 cargo.env("RUST_BACKTRACE", "1");
525 // Let cargo-miri know where xargo ended up.
526 cargo.env("XARGO_CHECK", builder.out.join("bin").join("xargo-check"));
528 let mut cargo = Command::from(cargo);
529 if !try_run(builder, &mut cargo) {
533 // # Determine where Miri put its sysroot.
534 // To this end, we run `cargo miri setup --print-sysroot` and capture the output.
535 // (We do this separately from the above so that when the setup actually
536 // happens we get some output.)
537 // We re-use the `cargo` from above.
538 cargo.arg("--print-sysroot");
540 // FIXME: Is there a way in which we can re-use the usual `run` helpers?
541 let miri_sysroot = if builder.config.dry_run {
544 builder.verbose(&format!("running: {:?}", cargo));
547 .expect("We already ran `cargo miri setup` before and that worked");
548 assert!(out.status.success(), "`cargo miri setup` returned with non-0 exit code");
549 // Output is "<sysroot>\n".
550 let stdout = String::from_utf8(out.stdout)
551 .expect("`cargo miri setup` stdout is not valid UTF-8");
552 let sysroot = stdout.trim_end();
553 builder.verbose(&format!("`cargo miri setup --print-sysroot` said: {:?}", sysroot));
557 // # Run `cargo test`.
558 let mut cargo = tool::prepare_tool_cargo(
565 SourceType::Submodule,
568 cargo.add_rustc_lib_path(builder, compiler);
570 // miri tests need to know about the stage sysroot
571 cargo.env("MIRI_SYSROOT", miri_sysroot);
572 cargo.env("MIRI_HOST_SYSROOT", sysroot);
573 cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
574 cargo.env("MIRI", miri);
576 cargo.arg("--").args(builder.config.cmd.test_args());
578 let mut cargo = Command::from(cargo);
579 if !try_run(builder, &mut cargo) {
584 builder.save_toolstate("miri", ToolState::TestPass);
586 eprintln!("failed to test miri: could not build");
591 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
592 pub struct CompiletestTest {
593 host: TargetSelection,
596 impl Step for CompiletestTest {
599 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
600 run.path("src/tools/compiletest")
603 fn make_run(run: RunConfig<'_>) {
604 run.builder.ensure(CompiletestTest { host: run.target });
607 /// Runs `cargo test` for compiletest.
608 fn run(self, builder: &Builder<'_>) {
609 let host = self.host;
610 let compiler = builder.compiler(0, host);
612 // We need `ToolStd` for the locally-built sysroot because
613 // compiletest uses unstable features of the `test` crate.
614 builder.ensure(compile::Std::new(compiler, host));
615 let cargo = tool::prepare_tool_cargo(
621 "src/tools/compiletest",
626 try_run(builder, &mut cargo.into());
630 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
633 host: TargetSelection,
636 impl Step for Clippy {
638 const ONLY_HOSTS: bool = true;
639 const DEFAULT: bool = false;
641 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
642 run.path("src/tools/clippy")
645 fn make_run(run: RunConfig<'_>) {
646 run.builder.ensure(Clippy { stage: run.builder.top_stage, host: run.target });
649 /// Runs `cargo test` for clippy.
650 fn run(self, builder: &Builder<'_>) {
651 let stage = self.stage;
652 let host = self.host;
653 let compiler = builder.compiler(stage, host);
656 .ensure(tool::Clippy { compiler, target: self.host, extra_features: Vec::new() })
657 .expect("in-tree tool");
658 let mut cargo = tool::prepare_tool_cargo(
669 cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
670 cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
671 let host_libs = builder.stage_out(compiler, Mode::ToolRustc).join(builder.cargo_dir());
672 cargo.env("HOST_LIBS", host_libs);
674 cargo.arg("--").args(builder.config.cmd.test_args());
676 cargo.add_rustc_lib_path(builder, compiler);
678 if builder.try_run(&mut cargo.into()) {
679 // The tests succeeded; nothing to do.
683 if !builder.config.cmd.bless() {
684 crate::detail_exit(1);
687 let mut cargo = builder.cargo(compiler, Mode::ToolRustc, SourceType::InTree, host, "run");
688 cargo.arg("-p").arg("clippy_dev");
689 // clippy_dev gets confused if it can't find `clippy/Cargo.toml`
690 cargo.current_dir(&builder.src.join("src").join("tools").join("clippy"));
691 if builder.config.rust_optimize {
692 cargo.env("PROFILE", "release");
694 cargo.env("PROFILE", "debug");
698 builder.run(&mut cargo.into());
702 fn path_for_cargo(builder: &Builder<'_>, compiler: Compiler) -> OsString {
703 // Configure PATH to find the right rustc. NB. we have to use PATH
704 // and not RUSTC because the Cargo test suite has tests that will
705 // fail if rustc is not spelled `rustc`.
706 let path = builder.sysroot(compiler).join("bin");
707 let old_path = env::var_os("PATH").unwrap_or_default();
708 env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("")
711 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
712 pub struct RustdocTheme {
713 pub compiler: Compiler,
716 impl Step for RustdocTheme {
718 const DEFAULT: bool = true;
719 const ONLY_HOSTS: bool = true;
721 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
722 run.path("src/tools/rustdoc-themes")
725 fn make_run(run: RunConfig<'_>) {
726 let compiler = run.builder.compiler(run.builder.top_stage, run.target);
728 run.builder.ensure(RustdocTheme { compiler });
731 fn run(self, builder: &Builder<'_>) {
732 let rustdoc = builder.bootstrap_out.join("rustdoc");
733 let mut cmd = builder.tool_cmd(Tool::RustdocTheme);
734 cmd.arg(rustdoc.to_str().unwrap())
735 .arg(builder.src.join("src/librustdoc/html/static/css/themes").to_str().unwrap())
736 .env("RUSTC_STAGE", self.compiler.stage.to_string())
737 .env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
738 .env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host))
739 .env("CFG_RELEASE_CHANNEL", &builder.config.channel)
740 .env("RUSTDOC_REAL", builder.rustdoc(self.compiler))
741 .env("RUSTC_BOOTSTRAP", "1");
742 if let Some(linker) = builder.linker(self.compiler.host) {
743 cmd.env("RUSTDOC_LINKER", linker);
745 if builder.is_fuse_ld_lld(self.compiler.host) {
746 cmd.env("RUSTDOC_FUSE_LD_LLD", "1");
748 try_run(builder, &mut cmd);
752 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
753 pub struct RustdocJSStd {
754 pub target: TargetSelection,
757 impl Step for RustdocJSStd {
759 const DEFAULT: bool = true;
760 const ONLY_HOSTS: bool = true;
762 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
763 run.suite_path("src/test/rustdoc-js-std")
766 fn make_run(run: RunConfig<'_>) {
767 run.builder.ensure(RustdocJSStd { target: run.target });
770 fn run(self, builder: &Builder<'_>) {
771 if let Some(ref nodejs) = builder.config.nodejs {
772 let mut command = Command::new(nodejs);
774 .arg(builder.src.join("src/tools/rustdoc-js/tester.js"))
777 .arg("--resource-suffix")
778 .arg(&builder.version)
780 .arg(builder.doc_out(self.target))
781 .arg("--test-folder")
782 .arg(builder.src.join("src/test/rustdoc-js-std"));
783 for path in &builder.paths {
785 util::is_valid_test_suite_arg(path, "src/test/rustdoc-js-std", builder)
787 if !p.ends_with(".js") {
788 eprintln!("A non-js file was given: `{}`", path.display());
789 panic!("Cannot run rustdoc-js-std tests");
791 command.arg("--test-file").arg(path);
794 builder.ensure(crate::doc::Std { target: self.target, stage: builder.top_stage });
795 builder.run(&mut command);
797 builder.info("No nodejs found, skipping \"src/test/rustdoc-js-std\" tests");
802 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
803 pub struct RustdocJSNotStd {
804 pub target: TargetSelection,
805 pub compiler: Compiler,
808 impl Step for RustdocJSNotStd {
810 const DEFAULT: bool = true;
811 const ONLY_HOSTS: bool = true;
813 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
814 run.suite_path("src/test/rustdoc-js")
817 fn make_run(run: RunConfig<'_>) {
818 let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
819 run.builder.ensure(RustdocJSNotStd { target: run.target, compiler });
822 fn run(self, builder: &Builder<'_>) {
823 if builder.config.nodejs.is_some() {
824 builder.ensure(Compiletest {
825 compiler: self.compiler,
829 path: "src/test/rustdoc-js",
833 builder.info("No nodejs found, skipping \"src/test/rustdoc-js\" tests");
838 fn get_browser_ui_test_version_inner(npm: &Path, global: bool) -> Option<String> {
839 let mut command = Command::new(&npm);
840 command.arg("list").arg("--parseable").arg("--long").arg("--depth=0");
842 command.arg("--global");
846 .map(|output| String::from_utf8_lossy(&output.stdout).into_owned())
847 .unwrap_or(String::new());
848 lines.lines().find_map(|l| l.split(":browser-ui-test@").skip(1).next()).map(|v| v.to_owned())
851 fn get_browser_ui_test_version(npm: &Path) -> Option<String> {
852 get_browser_ui_test_version_inner(npm, false)
853 .or_else(|| get_browser_ui_test_version_inner(npm, true))
856 fn compare_browser_ui_test_version(installed_version: &str, src: &Path) {
857 match fs::read_to_string(
858 src.join("src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version"),
861 if v.trim() != installed_version {
863 "⚠️ Installed version of browser-ui-test (`{}`) is different than the \
864 one used in the CI (`{}`)",
869 Err(e) => eprintln!("Couldn't find the CI browser-ui-test version: {:?}", e),
873 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
874 pub struct RustdocGUI {
875 pub target: TargetSelection,
876 pub compiler: Compiler,
879 impl Step for RustdocGUI {
881 const DEFAULT: bool = true;
882 const ONLY_HOSTS: bool = true;
884 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
885 let builder = run.builder;
886 let run = run.suite_path("src/test/rustdoc-gui");
887 run.lazy_default_condition(Box::new(move || {
888 builder.config.nodejs.is_some()
893 .map(|p| get_browser_ui_test_version(p).is_some())
898 fn make_run(run: RunConfig<'_>) {
899 let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
900 run.builder.ensure(RustdocGUI { target: run.target, compiler });
903 fn run(self, builder: &Builder<'_>) {
904 let nodejs = builder.config.nodejs.as_ref().expect("nodejs isn't available");
905 let npm = builder.config.npm.as_ref().expect("npm isn't available");
907 builder.ensure(compile::Std::new(self.compiler, self.target));
909 // The goal here is to check if the necessary packages are installed, and if not, we
911 match get_browser_ui_test_version(&npm) {
913 // We also check the version currently used in CI and emit a warning if it's not the
915 compare_browser_ui_test_version(&version, &builder.build.src);
919 "error: rustdoc-gui test suite cannot be run because npm `browser-ui-test` \
920 dependency is missing",
923 "If you want to install the `{0}` dependency, run `npm install {0}`",
926 panic!("Cannot run rustdoc-gui tests");
930 let out_dir = builder.test_out(self.target).join("rustdoc-gui");
932 // We remove existing folder to be sure there won't be artifacts remaining.
933 builder.clear_if_dirty(&out_dir, &builder.rustdoc(self.compiler));
935 let src_path = builder.build.src.join("src/test/rustdoc-gui/src");
936 // We generate docs for the libraries present in the rustdoc-gui's src folder.
937 for entry in src_path.read_dir().expect("read_dir call failed") {
938 if let Ok(entry) = entry {
939 let path = entry.path();
945 let mut cargo = Command::new(&builder.initial_cargo);
950 .env("RUSTDOC", builder.rustdoc(self.compiler))
951 .env("RUSTC", builder.rustc(self.compiler))
953 // FIXME: implement a `// compile-flags` command or similar
954 // instead of hard-coding this test
955 if entry.file_name() == "link_to_definition" {
956 cargo.env("RUSTDOCFLAGS", "-Zunstable-options --generate-link-to-definition");
958 builder.run(&mut cargo);
962 // We now run GUI tests.
963 let mut command = Command::new(&nodejs);
965 .arg(builder.build.src.join("src/tools/rustdoc-gui/tester.js"))
967 .arg(&builder.jobs().to_string())
969 .arg(out_dir.join("doc"))
970 .arg("--tests-folder")
971 .arg(builder.build.src.join("src/test/rustdoc-gui"));
972 for path in &builder.paths {
973 if let Some(p) = util::is_valid_test_suite_arg(path, "src/test/rustdoc-gui", builder) {
974 if !p.ends_with(".goml") {
975 eprintln!("A non-goml file was given: `{}`", path.display());
976 panic!("Cannot run rustdoc-gui tests");
978 if let Some(name) = path.file_name().and_then(|f| f.to_str()) {
979 command.arg("--file").arg(name);
983 for test_arg in builder.config.cmd.test_args() {
984 command.arg(test_arg);
986 builder.run(&mut command);
990 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
995 const DEFAULT: bool = true;
996 const ONLY_HOSTS: bool = true;
998 /// Runs the `tidy` tool.
1000 /// This tool in `src/tools` checks up on various bits and pieces of style and
1001 /// otherwise just implements a few lint-like checks that are specific to the
1002 /// compiler itself.
1004 /// Once tidy passes, this step also runs `fmt --check` if tests are being run
1005 /// for the `dev` or `nightly` channels.
1006 fn run(self, builder: &Builder<'_>) {
1007 let mut cmd = builder.tool_cmd(Tool::Tidy);
1008 cmd.arg(&builder.src);
1009 cmd.arg(&builder.initial_cargo);
1010 cmd.arg(&builder.out);
1011 cmd.arg(builder.jobs().to_string());
1012 if builder.is_verbose() {
1013 cmd.arg("--verbose");
1016 builder.info("tidy check");
1017 try_run(builder, &mut cmd);
1019 if builder.config.channel == "dev" || builder.config.channel == "nightly" {
1020 builder.info("fmt check");
1021 if builder.initial_rustfmt().is_none() {
1022 let inferred_rustfmt_dir = builder.config.initial_rustc.parent().unwrap();
1025 error: no `rustfmt` binary found in {PATH}
1026 info: `rust.channel` is currently set to \"{CHAN}\"
1027 help: if you are testing a beta branch, set `rust.channel` to \"beta\" in the `config.toml` file
1028 help: to skip test's attempt to check tidiness, pass `--exclude src/tools/tidy` to `x.py test`",
1029 PATH = inferred_rustfmt_dir.display(),
1030 CHAN = builder.config.channel,
1032 crate::detail_exit(1);
1034 crate::format::format(&builder, !builder.config.cmd.bless(), &[]);
1038 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1039 run.path("src/tools/tidy")
1042 fn make_run(run: RunConfig<'_>) {
1043 run.builder.ensure(Tidy);
1047 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1048 pub struct ExpandYamlAnchors;
1050 impl Step for ExpandYamlAnchors {
1052 const ONLY_HOSTS: bool = true;
1054 /// Ensure the `generate-ci-config` tool was run locally.
1056 /// The tool in `src/tools` reads the CI definition in `src/ci/builders.yml` and generates the
1057 /// appropriate configuration for all our CI providers. This step ensures the tool was called
1058 /// by the user before committing CI changes.
1059 fn run(self, builder: &Builder<'_>) {
1060 builder.info("Ensuring the YAML anchors in the GitHub Actions config were expanded");
1063 &mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("check").arg(&builder.src),
1067 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1068 run.path("src/tools/expand-yaml-anchors")
1071 fn make_run(run: RunConfig<'_>) {
1072 run.builder.ensure(ExpandYamlAnchors);
1076 fn testdir(builder: &Builder<'_>, host: TargetSelection) -> PathBuf {
1077 builder.out.join(host.triple).join("test")
1080 macro_rules! default_test {
1081 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr }) => {
1082 test!($name { path: $path, mode: $mode, suite: $suite, default: true, host: false });
1086 macro_rules! default_test_with_compare_mode {
1087 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr,
1088 compare_mode: $compare_mode:expr }) => {
1089 test_with_compare_mode!($name {
1095 compare_mode: $compare_mode
1100 macro_rules! host_test {
1101 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr }) => {
1102 test!($name { path: $path, mode: $mode, suite: $suite, default: true, host: true });
1107 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr, default: $default:expr,
1108 host: $host:expr }) => {
1109 test_definitions!($name {
1120 macro_rules! test_with_compare_mode {
1121 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr, default: $default:expr,
1122 host: $host:expr, compare_mode: $compare_mode:expr }) => {
1123 test_definitions!($name {
1129 compare_mode: Some($compare_mode)
1134 macro_rules! test_definitions {
1139 default: $default:expr,
1141 compare_mode: $compare_mode:expr
1143 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1145 pub compiler: Compiler,
1146 pub target: TargetSelection,
1149 impl Step for $name {
1151 const DEFAULT: bool = $default;
1152 const ONLY_HOSTS: bool = $host;
1154 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1155 run.suite_path($path)
1158 fn make_run(run: RunConfig<'_>) {
1159 let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
1161 run.builder.ensure($name { compiler, target: run.target });
1164 fn run(self, builder: &Builder<'_>) {
1165 builder.ensure(Compiletest {
1166 compiler: self.compiler,
1167 target: self.target,
1171 compare_mode: $compare_mode,
1178 default_test!(Ui { path: "src/test/ui", mode: "ui", suite: "ui" });
1180 default_test!(RunPassValgrind {
1181 path: "src/test/run-pass-valgrind",
1182 mode: "run-pass-valgrind",
1183 suite: "run-pass-valgrind"
1186 default_test!(MirOpt { path: "src/test/mir-opt", mode: "mir-opt", suite: "mir-opt" });
1188 default_test!(Codegen { path: "src/test/codegen", mode: "codegen", suite: "codegen" });
1190 default_test!(CodegenUnits {
1191 path: "src/test/codegen-units",
1192 mode: "codegen-units",
1193 suite: "codegen-units"
1196 default_test!(Incremental {
1197 path: "src/test/incremental",
1198 mode: "incremental",
1199 suite: "incremental"
1202 default_test_with_compare_mode!(Debuginfo {
1203 path: "src/test/debuginfo",
1206 compare_mode: "split-dwarf"
1209 host_test!(UiFullDeps { path: "src/test/ui-fulldeps", mode: "ui", suite: "ui-fulldeps" });
1211 host_test!(Rustdoc { path: "src/test/rustdoc", mode: "rustdoc", suite: "rustdoc" });
1212 host_test!(RustdocUi { path: "src/test/rustdoc-ui", mode: "ui", suite: "rustdoc-ui" });
1214 host_test!(RustdocJson {
1215 path: "src/test/rustdoc-json",
1216 mode: "rustdoc-json",
1217 suite: "rustdoc-json"
1220 host_test!(Pretty { path: "src/test/pretty", mode: "pretty", suite: "pretty" });
1222 default_test!(RunMake { path: "src/test/run-make", mode: "run-make", suite: "run-make" });
1224 host_test!(RunMakeFullDeps {
1225 path: "src/test/run-make-fulldeps",
1227 suite: "run-make-fulldeps"
1230 default_test!(Assembly { path: "src/test/assembly", mode: "assembly", suite: "assembly" });
1232 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1233 struct Compiletest {
1235 target: TargetSelection,
1237 suite: &'static str,
1239 compare_mode: Option<&'static str>,
1242 impl Step for Compiletest {
1245 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1249 /// Executes the `compiletest` tool to run a suite of tests.
1251 /// Compiles all tests with `compiler` for `target` with the specified
1252 /// compiletest `mode` and `suite` arguments. For example `mode` can be
1253 /// "run-pass" or `suite` can be something like `debuginfo`.
1254 fn run(self, builder: &Builder<'_>) {
1255 if builder.top_stage == 0 && env::var("COMPILETEST_FORCE_STAGE0").is_err() {
1257 error: `--stage 0` runs compiletest on the beta compiler, not your local changes, and will almost always cause tests to fail
1258 help: to test the compiler, use `--stage 1` instead
1259 help: to test the standard library, use `--stage 0 library/std` instead
1260 note: if you're sure you want to do this, please open an issue as to why. In the meantime, you can override this with `COMPILETEST_FORCE_STAGE0=1`."
1262 crate::detail_exit(1);
1265 let compiler = self.compiler;
1266 let target = self.target;
1267 let mode = self.mode;
1268 let suite = self.suite;
1270 // Path for test suite
1271 let suite_path = self.path;
1273 // Skip codegen tests if they aren't enabled in configuration.
1274 if !builder.config.codegen_tests && suite == "codegen" {
1278 if suite == "debuginfo" {
1280 .ensure(dist::DebuggerScripts { sysroot: builder.sysroot(compiler), host: target });
1283 if suite.ends_with("fulldeps") {
1284 builder.ensure(compile::Rustc::new(compiler, target));
1287 builder.ensure(compile::Std::new(compiler, target));
1288 // ensure that `libproc_macro` is available on the host.
1289 builder.ensure(compile::Std::new(compiler, compiler.host));
1291 // Also provide `rust_test_helpers` for the host.
1292 builder.ensure(native::TestHelpers { target: compiler.host });
1294 // As well as the target, except for plain wasm32, which can't build it
1295 if !target.contains("wasm") || target.contains("emscripten") {
1296 builder.ensure(native::TestHelpers { target });
1299 builder.ensure(RemoteCopyLibs { compiler, target });
1301 let mut cmd = builder.tool_cmd(Tool::Compiletest);
1303 // compiletest currently has... a lot of arguments, so let's just pass all
1306 cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler));
1307 cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target));
1308 cmd.arg("--rustc-path").arg(builder.rustc(compiler));
1310 let is_rustdoc = suite.ends_with("rustdoc-ui") || suite.ends_with("rustdoc-js");
1312 // Avoid depending on rustdoc when we don't need it.
1313 if mode == "rustdoc"
1314 || mode == "run-make"
1315 || (mode == "ui" && is_rustdoc)
1316 || mode == "js-doc-test"
1317 || mode == "rustdoc-json"
1319 cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler));
1322 if mode == "rustdoc-json" {
1323 // Use the beta compiler for jsondocck
1324 let json_compiler = compiler.with_stage(0);
1325 cmd.arg("--jsondocck-path")
1326 .arg(builder.ensure(tool::JsonDocCk { compiler: json_compiler, target }));
1329 if mode == "run-make" && suite.ends_with("fulldeps") {
1330 let rust_demangler = builder
1331 .ensure(tool::RustDemangler { compiler, target, extra_features: Vec::new() })
1332 .expect("in-tree tool");
1333 cmd.arg("--rust-demangler-path").arg(rust_demangler);
1336 cmd.arg("--src-base").arg(builder.src.join("src/test").join(suite));
1337 cmd.arg("--build-base").arg(testdir(builder, compiler.host).join(suite));
1338 cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
1339 cmd.arg("--suite").arg(suite);
1340 cmd.arg("--mode").arg(mode);
1341 cmd.arg("--target").arg(target.rustc_target_arg());
1342 cmd.arg("--host").arg(&*compiler.host.triple);
1343 cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.build));
1345 if builder.config.cmd.bless() {
1349 if builder.config.cmd.force_rerun() {
1350 cmd.arg("--force-rerun");
1354 builder.config.cmd.compare_mode().or_else(|| {
1355 if builder.config.test_compare_mode { self.compare_mode } else { None }
1358 if let Some(ref pass) = builder.config.cmd.pass() {
1363 if let Some(ref run) = builder.config.cmd.run() {
1368 if let Some(ref nodejs) = builder.config.nodejs {
1369 cmd.arg("--nodejs").arg(nodejs);
1371 if let Some(ref npm) = builder.config.npm {
1372 cmd.arg("--npm").arg(npm);
1374 if builder.config.rust_optimize_tests {
1375 cmd.arg("--optimize-tests");
1377 let mut flags = if is_rustdoc { Vec::new() } else { vec!["-Crpath".to_string()] };
1378 flags.push(format!("-Cdebuginfo={}", builder.config.rust_debuginfo_level_tests));
1379 flags.push(builder.config.cmd.rustc_args().join(" "));
1381 if let Some(linker) = builder.linker(target) {
1382 cmd.arg("--linker").arg(linker);
1385 let mut hostflags = flags.clone();
1386 hostflags.push(format!("-Lnative={}", builder.test_helpers_out(compiler.host).display()));
1387 hostflags.extend(builder.lld_flags(compiler.host));
1388 cmd.arg("--host-rustcflags").arg(hostflags.join(" "));
1390 let mut targetflags = flags;
1391 targetflags.push(format!("-Lnative={}", builder.test_helpers_out(target).display()));
1392 targetflags.extend(builder.lld_flags(target));
1393 cmd.arg("--target-rustcflags").arg(targetflags.join(" "));
1395 cmd.arg("--python").arg(builder.python());
1397 if let Some(ref gdb) = builder.config.gdb {
1398 cmd.arg("--gdb").arg(gdb);
1401 let run = |cmd: &mut Command| {
1402 cmd.output().map(|output| {
1403 String::from_utf8_lossy(&output.stdout)
1406 .unwrap_or_else(|| panic!("{:?} failed {:?}", cmd, output))
1410 let lldb_exe = "lldb";
1411 let lldb_version = Command::new(lldb_exe)
1414 .map(|output| String::from_utf8_lossy(&output.stdout).to_string())
1416 if let Some(ref vers) = lldb_version {
1417 cmd.arg("--lldb-version").arg(vers);
1418 let lldb_python_dir = run(Command::new(lldb_exe).arg("-P")).ok();
1419 if let Some(ref dir) = lldb_python_dir {
1420 cmd.arg("--lldb-python-dir").arg(dir);
1424 if util::forcing_clang_based_tests() {
1425 let clang_exe = builder.llvm_out(target).join("bin").join("clang");
1426 cmd.arg("--run-clang-based-tests-with").arg(clang_exe);
1429 // Get paths from cmd args
1430 let paths = match &builder.config.cmd {
1431 Subcommand::Test { ref paths, .. } => &paths[..],
1435 // Get test-args by striping suite path
1436 let mut test_args: Vec<&str> = paths
1438 .filter_map(|p| util::is_valid_test_suite_arg(p, suite_path, builder))
1441 test_args.append(&mut builder.config.cmd.test_args());
1443 cmd.args(&test_args);
1445 if builder.is_verbose() {
1446 cmd.arg("--verbose");
1449 if !builder.config.verbose_tests {
1453 let mut llvm_components_passed = false;
1454 let mut copts_passed = false;
1455 if builder.config.llvm_enabled() {
1456 let llvm_config = builder.ensure(native::Llvm { target: builder.config.build });
1457 if !builder.config.dry_run {
1458 let llvm_version = output(Command::new(&llvm_config).arg("--version"));
1459 let llvm_components = output(Command::new(&llvm_config).arg("--components"));
1460 // Remove trailing newline from llvm-config output.
1461 cmd.arg("--llvm-version")
1462 .arg(llvm_version.trim())
1463 .arg("--llvm-components")
1464 .arg(llvm_components.trim());
1465 llvm_components_passed = true;
1467 if !builder.is_rust_llvm(target) {
1468 cmd.arg("--system-llvm");
1471 // Tests that use compiler libraries may inherit the `-lLLVM` link
1472 // requirement, but the `-L` library path is not propagated across
1473 // separate compilations. We can add LLVM's library path to the
1474 // platform-specific environment variable as a workaround.
1475 if !builder.config.dry_run && suite.ends_with("fulldeps") {
1476 let llvm_libdir = output(Command::new(&llvm_config).arg("--libdir"));
1477 add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cmd);
1480 // Only pass correct values for these flags for the `run-make` suite as it
1481 // requires that a C++ compiler was configured which isn't always the case.
1482 if !builder.config.dry_run && matches!(suite, "run-make" | "run-make-fulldeps") {
1483 // The llvm/bin directory contains many useful cross-platform
1484 // tools. Pass the path to run-make tests so they can use them.
1485 let llvm_bin_path = llvm_config
1487 .expect("Expected llvm-config to be contained in directory");
1488 assert!(llvm_bin_path.is_dir());
1489 cmd.arg("--llvm-bin-dir").arg(llvm_bin_path);
1491 // If LLD is available, add it to the PATH
1492 if builder.config.lld_enabled {
1493 let lld_install_root =
1494 builder.ensure(native::Lld { target: builder.config.build });
1496 let lld_bin_path = lld_install_root.join("bin");
1498 let old_path = env::var_os("PATH").unwrap_or_default();
1499 let new_path = env::join_paths(
1500 std::iter::once(lld_bin_path).chain(env::split_paths(&old_path)),
1502 .expect("Could not add LLD bin path to PATH");
1503 cmd.env("PATH", new_path);
1508 // Only pass correct values for these flags for the `run-make` suite as it
1509 // requires that a C++ compiler was configured which isn't always the case.
1510 if !builder.config.dry_run && matches!(suite, "run-make" | "run-make-fulldeps") {
1512 .arg(builder.cc(target))
1514 .arg(builder.cxx(target).unwrap())
1516 .arg(builder.cflags(target, GitRepo::Rustc, CLang::C).join(" "))
1518 .arg(builder.cflags(target, GitRepo::Rustc, CLang::Cxx).join(" "));
1519 copts_passed = true;
1520 if let Some(ar) = builder.ar(target) {
1521 cmd.arg("--ar").arg(ar);
1525 if !llvm_components_passed {
1526 cmd.arg("--llvm-components").arg("");
1539 if builder.remote_tested(target) {
1540 cmd.arg("--remote-test-client").arg(builder.tool_exe(Tool::RemoteTestClient));
1543 // Running a C compiler on MSVC requires a few env vars to be set, to be
1544 // sure to set them here.
1546 // Note that if we encounter `PATH` we make sure to append to our own `PATH`
1547 // rather than stomp over it.
1548 if target.contains("msvc") {
1549 for &(ref k, ref v) in builder.cc[&target].env() {
1555 cmd.env("RUSTC_BOOTSTRAP", "1");
1556 // Override the rustc version used in symbol hashes to reduce the amount of normalization
1557 // needed when diffing test output.
1558 cmd.env("RUSTC_FORCE_RUSTC_VERSION", "compiletest");
1559 cmd.env("DOC_RUST_LANG_ORG_CHANNEL", builder.doc_rust_lang_org_channel());
1560 builder.add_rust_test_threads(&mut cmd);
1562 if builder.config.sanitizers_enabled(target) {
1563 cmd.env("RUSTC_SANITIZER_SUPPORT", "1");
1566 if builder.config.profiler_enabled(target) {
1567 cmd.env("RUSTC_PROFILER_SUPPORT", "1");
1570 cmd.env("RUST_TEST_TMPDIR", builder.tempdir());
1572 cmd.arg("--adb-path").arg("adb");
1573 cmd.arg("--adb-test-dir").arg(ADB_TEST_DIR);
1574 if target.contains("android") {
1575 // Assume that cc for this target comes from the android sysroot
1576 cmd.arg("--android-cross-path")
1577 .arg(builder.cc(target).parent().unwrap().parent().unwrap());
1579 cmd.arg("--android-cross-path").arg("");
1582 if builder.config.cmd.rustfix_coverage() {
1583 cmd.arg("--rustfix-coverage");
1586 cmd.env("BOOTSTRAP_CARGO", &builder.initial_cargo);
1588 cmd.arg("--channel").arg(&builder.config.channel);
1590 builder.ci_env.force_coloring_in_ci(&mut cmd);
1592 builder.info(&format!(
1593 "Check compiletest suite={} mode={} ({} -> {})",
1594 suite, mode, &compiler.host, target
1596 let _time = util::timeit(&builder);
1597 try_run(builder, &mut cmd);
1599 if let Some(compare_mode) = compare_mode {
1600 cmd.arg("--compare-mode").arg(compare_mode);
1601 builder.info(&format!(
1602 "Check compiletest suite={} mode={} compare_mode={} ({} -> {})",
1603 suite, mode, compare_mode, &compiler.host, target
1605 let _time = util::timeit(&builder);
1606 try_run(builder, &mut cmd);
1611 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1619 impl Step for BookTest {
1621 const ONLY_HOSTS: bool = true;
1623 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1627 /// Runs the documentation tests for a book in `src/doc`.
1629 /// This uses the `rustdoc` that sits next to `compiler`.
1630 fn run(self, builder: &Builder<'_>) {
1631 // External docs are different from local because:
1632 // - Some books need pre-processing by mdbook before being tested.
1633 // - They need to save their state to toolstate.
1634 // - They are only tested on the "checktools" builders.
1636 // The local docs are tested by default, and we don't want to pay the
1637 // cost of building mdbook, so they use `rustdoc --test` directly.
1638 // Also, the unstable book is special because SUMMARY.md is generated,
1639 // so it is easier to just run `rustdoc` on its files.
1640 if self.is_ext_doc {
1641 self.run_ext_doc(builder);
1643 self.run_local_doc(builder);
1649 /// This runs the equivalent of `mdbook test` (via the rustbook wrapper)
1650 /// which in turn runs `rustdoc --test` on each file in the book.
1651 fn run_ext_doc(self, builder: &Builder<'_>) {
1652 let compiler = self.compiler;
1654 builder.ensure(compile::Std::new(compiler, compiler.host));
1656 // mdbook just executes a binary named "rustdoc", so we need to update
1657 // PATH so that it points to our rustdoc.
1658 let mut rustdoc_path = builder.rustdoc(compiler);
1660 let old_path = env::var_os("PATH").unwrap_or_default();
1661 let new_path = env::join_paths(iter::once(rustdoc_path).chain(env::split_paths(&old_path)))
1662 .expect("could not add rustdoc to PATH");
1664 let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
1665 let path = builder.src.join(&self.path);
1666 rustbook_cmd.env("PATH", new_path).arg("test").arg(path);
1667 builder.add_rust_test_threads(&mut rustbook_cmd);
1668 builder.info(&format!("Testing rustbook {}", self.path.display()));
1669 let _time = util::timeit(&builder);
1670 let toolstate = if try_run(builder, &mut rustbook_cmd) {
1675 builder.save_toolstate(self.name, toolstate);
1678 /// This runs `rustdoc --test` on all `.md` files in the path.
1679 fn run_local_doc(self, builder: &Builder<'_>) {
1680 let compiler = self.compiler;
1682 builder.ensure(compile::Std::new(compiler, compiler.host));
1684 // Do a breadth-first traversal of the `src/doc` directory and just run
1685 // tests for all files that end in `*.md`
1686 let mut stack = vec![builder.src.join(self.path)];
1687 let _time = util::timeit(&builder);
1688 let mut files = Vec::new();
1689 while let Some(p) = stack.pop() {
1691 stack.extend(t!(p.read_dir()).map(|p| t!(p).path()));
1695 if p.extension().and_then(|s| s.to_str()) != Some("md") {
1705 markdown_test(builder, compiler, &file);
1710 macro_rules! test_book {
1711 ($($name:ident, $path:expr, $book_name:expr, default=$default:expr;)+) => {
1713 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1718 impl Step for $name {
1720 const DEFAULT: bool = $default;
1721 const ONLY_HOSTS: bool = true;
1723 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1727 fn make_run(run: RunConfig<'_>) {
1728 run.builder.ensure($name {
1729 compiler: run.builder.compiler(run.builder.top_stage, run.target),
1733 fn run(self, builder: &Builder<'_>) {
1734 builder.ensure(BookTest {
1735 compiler: self.compiler,
1736 path: PathBuf::from($path),
1738 is_ext_doc: !$default,
1747 Nomicon, "src/doc/nomicon", "nomicon", default=false;
1748 Reference, "src/doc/reference", "reference", default=false;
1749 RustdocBook, "src/doc/rustdoc", "rustdoc", default=true;
1750 RustcBook, "src/doc/rustc", "rustc", default=true;
1751 RustByExample, "src/doc/rust-by-example", "rust-by-example", default=false;
1752 EmbeddedBook, "src/doc/embedded-book", "embedded-book", default=false;
1753 TheBook, "src/doc/book", "book", default=false;
1754 UnstableBook, "src/doc/unstable-book", "unstable-book", default=true;
1755 EditionGuide, "src/doc/edition-guide", "edition-guide", default=false;
1758 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1759 pub struct ErrorIndex {
1763 impl Step for ErrorIndex {
1765 const DEFAULT: bool = true;
1766 const ONLY_HOSTS: bool = true;
1768 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1769 run.path("src/tools/error_index_generator")
1772 fn make_run(run: RunConfig<'_>) {
1773 // error_index_generator depends on librustdoc. Use the compiler that
1774 // is normally used to build rustdoc for other tests (like compiletest
1775 // tests in src/test/rustdoc) so that it shares the same artifacts.
1776 let compiler = run.builder.compiler(run.builder.top_stage, run.builder.config.build);
1777 run.builder.ensure(ErrorIndex { compiler });
1780 /// Runs the error index generator tool to execute the tests located in the error
1783 /// The `error_index_generator` tool lives in `src/tools` and is used to
1784 /// generate a markdown file from the error indexes of the code base which is
1785 /// then passed to `rustdoc --test`.
1786 fn run(self, builder: &Builder<'_>) {
1787 let compiler = self.compiler;
1789 let dir = testdir(builder, compiler.host);
1790 t!(fs::create_dir_all(&dir));
1791 let output = dir.join("error-index.md");
1793 let mut tool = tool::ErrorIndex::command(builder);
1794 tool.arg("markdown").arg(&output);
1796 builder.info(&format!("Testing error-index stage{}", compiler.stage));
1797 let _time = util::timeit(&builder);
1798 builder.run_quiet(&mut tool);
1799 // The tests themselves need to link to std, so make sure it is
1801 builder.ensure(compile::Std::new(compiler, compiler.host));
1802 markdown_test(builder, compiler, &output);
1806 fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) -> bool {
1807 if let Ok(contents) = fs::read_to_string(markdown) {
1808 if !contents.contains("```") {
1813 builder.info(&format!("doc tests for: {}", markdown.display()));
1814 let mut cmd = builder.rustdoc_cmd(compiler);
1815 builder.add_rust_test_threads(&mut cmd);
1816 // allow for unstable options such as new editions
1818 cmd.arg("unstable-options");
1821 cmd.env("RUSTC_BOOTSTRAP", "1");
1823 let test_args = builder.config.cmd.test_args().join(" ");
1824 cmd.arg("--test-args").arg(test_args);
1826 if builder.config.verbose_tests {
1827 try_run(builder, &mut cmd)
1829 try_run_quiet(builder, &mut cmd)
1833 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1834 pub struct RustcGuide;
1836 impl Step for RustcGuide {
1838 const DEFAULT: bool = false;
1839 const ONLY_HOSTS: bool = true;
1841 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1842 run.path("src/doc/rustc-dev-guide")
1845 fn make_run(run: RunConfig<'_>) {
1846 run.builder.ensure(RustcGuide);
1849 fn run(self, builder: &Builder<'_>) {
1850 let relative_path = Path::new("src").join("doc").join("rustc-dev-guide");
1851 builder.update_submodule(&relative_path);
1853 let src = builder.src.join(relative_path);
1854 let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
1855 let toolstate = if try_run(builder, rustbook_cmd.arg("linkcheck").arg(&src)) {
1860 builder.save_toolstate("rustc-dev-guide", toolstate);
1864 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1865 pub struct CrateLibrustc {
1867 target: TargetSelection,
1868 test_kind: TestKind,
1869 crates: Vec<Interned<String>>,
1872 impl Step for CrateLibrustc {
1874 const DEFAULT: bool = true;
1875 const ONLY_HOSTS: bool = true;
1877 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1878 run.crate_or_deps("rustc-main")
1881 fn make_run(run: RunConfig<'_>) {
1882 let builder = run.builder;
1883 let host = run.build_triple();
1884 let compiler = builder.compiler_for(builder.top_stage, host, host);
1888 .map(|p| builder.crate_paths[&p.assert_single_path().path].clone())
1890 let test_kind = builder.kind.into();
1892 builder.ensure(CrateLibrustc { compiler, target: run.target, test_kind, crates });
1895 fn run(self, builder: &Builder<'_>) {
1896 builder.ensure(Crate {
1897 compiler: self.compiler,
1898 target: self.target,
1900 test_kind: self.test_kind,
1901 crates: self.crates,
1906 #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
1908 pub compiler: Compiler,
1909 pub target: TargetSelection,
1911 pub test_kind: TestKind,
1912 pub crates: Vec<Interned<String>>,
1915 impl Step for Crate {
1917 const DEFAULT: bool = true;
1919 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1920 run.crate_or_deps("test")
1923 fn make_run(run: RunConfig<'_>) {
1924 let builder = run.builder;
1925 let host = run.build_triple();
1926 let compiler = builder.compiler_for(builder.top_stage, host, host);
1927 let test_kind = builder.kind.into();
1931 .map(|p| builder.crate_paths[&p.assert_single_path().path].clone())
1934 builder.ensure(Crate { compiler, target: run.target, mode: Mode::Std, test_kind, crates });
1937 /// Runs all unit tests plus documentation tests for a given crate defined
1938 /// by a `Cargo.toml` (single manifest)
1940 /// This is what runs tests for crates like the standard library, compiler, etc.
1941 /// It essentially is the driver for running `cargo test`.
1943 /// Currently this runs all tests for a DAG by passing a bunch of `-p foo`
1944 /// arguments, and those arguments are discovered from `cargo metadata`.
1945 fn run(self, builder: &Builder<'_>) {
1946 let compiler = self.compiler;
1947 let target = self.target;
1948 let mode = self.mode;
1949 let test_kind = self.test_kind;
1951 builder.ensure(compile::Std::new(compiler, target));
1952 builder.ensure(RemoteCopyLibs { compiler, target });
1954 // If we're not doing a full bootstrap but we're testing a stage2
1955 // version of libstd, then what we're actually testing is the libstd
1956 // produced in stage1. Reflect that here by updating the compiler that
1957 // we're working with automatically.
1958 let compiler = builder.compiler_for(compiler.stage, compiler.host, target);
1961 builder.cargo(compiler, mode, SourceType::InTree, target, test_kind.subcommand());
1964 compile::std_cargo(builder, target, compiler.stage, &mut cargo);
1967 compile::rustc_cargo(builder, &mut cargo, target);
1969 _ => panic!("can only test libraries"),
1972 // Build up the base `cargo test` command.
1974 // Pass in some standard flags then iterate over the graph we've discovered
1975 // in `cargo metadata` with the maps above and figure out what `-p`
1976 // arguments need to get passed.
1977 if test_kind.subcommand() == "test" && !builder.fail_fast {
1978 cargo.arg("--no-fail-fast");
1980 match builder.doc_tests {
1985 cargo.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]);
1990 for krate in &self.crates {
1991 cargo.arg("-p").arg(krate);
1994 // The tests are going to run with the *target* libraries, so we need to
1995 // ensure that those libraries show up in the LD_LIBRARY_PATH equivalent.
1997 // Note that to run the compiler we need to run with the *host* libraries,
1998 // but our wrapper scripts arrange for that to be the case anyway.
1999 let mut dylib_path = dylib_path();
2000 dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target)));
2001 cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
2004 cargo.args(&builder.config.cmd.test_args());
2006 if !builder.config.verbose_tests {
2007 cargo.arg("--quiet");
2010 if target.contains("emscripten") {
2012 format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)),
2013 builder.config.nodejs.as_ref().expect("nodejs not configured"),
2015 } else if target.starts_with("wasm32") {
2016 let node = builder.config.nodejs.as_ref().expect("nodejs not configured");
2018 format!("{} {}/src/etc/wasm32-shim.js", node.display(), builder.src.display());
2019 cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), &runner);
2020 } else if builder.remote_tested(target) {
2022 format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)),
2023 format!("{} run 0", builder.tool_exe(Tool::RemoteTestClient).display()),
2027 builder.info(&format!(
2028 "{} {:?} stage{} ({} -> {})",
2029 test_kind, self.crates, compiler.stage, &compiler.host, target
2031 let _time = util::timeit(&builder);
2032 try_run(builder, &mut cargo.into());
2036 /// Rustdoc is special in various ways, which is why this step is different from `Crate`.
2037 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2038 pub struct CrateRustdoc {
2039 host: TargetSelection,
2040 test_kind: TestKind,
2043 impl Step for CrateRustdoc {
2045 const DEFAULT: bool = true;
2046 const ONLY_HOSTS: bool = true;
2048 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2049 run.paths(&["src/librustdoc", "src/tools/rustdoc"])
2052 fn make_run(run: RunConfig<'_>) {
2053 let builder = run.builder;
2055 let test_kind = builder.kind.into();
2057 builder.ensure(CrateRustdoc { host: run.target, test_kind });
2060 fn run(self, builder: &Builder<'_>) {
2061 let test_kind = self.test_kind;
2062 let target = self.host;
2064 let compiler = if builder.download_rustc() {
2065 builder.compiler(builder.top_stage, target)
2067 // Use the previous stage compiler to reuse the artifacts that are
2068 // created when running compiletest for src/test/rustdoc. If this used
2069 // `compiler`, then it would cause rustdoc to be built *again*, which
2070 // isn't really necessary.
2071 builder.compiler_for(builder.top_stage, target, target)
2073 builder.ensure(compile::Rustc::new(compiler, target));
2075 let mut cargo = tool::prepare_tool_cargo(
2080 test_kind.subcommand(),
2081 "src/tools/rustdoc",
2085 if test_kind.subcommand() == "test" && !builder.fail_fast {
2086 cargo.arg("--no-fail-fast");
2088 match builder.doc_tests {
2093 cargo.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]);
2098 cargo.arg("-p").arg("rustdoc:0.0.0");
2101 cargo.args(&builder.config.cmd.test_args());
2103 if self.host.contains("musl") {
2104 cargo.arg("'-Ctarget-feature=-crt-static'");
2107 // This is needed for running doctests on librustdoc. This is a bit of
2108 // an unfortunate interaction with how bootstrap works and how cargo
2109 // sets up the dylib path, and the fact that the doctest (in
2110 // html/markdown.rs) links to rustc-private libs. For stage1, the
2111 // compiler host dylibs (in stage1/lib) are not the same as the target
2112 // dylibs (in stage1/lib/rustlib/...). This is different from a normal
2113 // rust distribution where they are the same.
2115 // On the cargo side, normal tests use `target_process` which handles
2116 // setting up the dylib for a *target* (stage1/lib/rustlib/... in this
2117 // case). However, for doctests it uses `rustdoc_process` which only
2118 // sets up the dylib path for the *host* (stage1/lib), which is the
2121 // Recall that we special-cased `compiler_for(top_stage)` above, so we always use stage1.
2123 // It should be considered to just stop running doctests on
2124 // librustdoc. There is only one test, and it doesn't look too
2125 // important. There might be other ways to avoid this, but it seems
2126 // pretty convoluted.
2128 // See also https://github.com/rust-lang/rust/issues/13983 where the
2129 // host vs target dylibs for rustdoc are consistently tricky to deal
2132 // Note that this set the host libdir for `download_rustc`, which uses a normal rust distribution.
2133 let libdir = if builder.download_rustc() {
2134 builder.rustc_libdir(compiler)
2136 builder.sysroot_libdir(compiler, target).to_path_buf()
2138 let mut dylib_path = dylib_path();
2139 dylib_path.insert(0, PathBuf::from(&*libdir));
2140 cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
2142 if !builder.config.verbose_tests {
2143 cargo.arg("--quiet");
2146 builder.info(&format!(
2147 "{} rustdoc stage{} ({} -> {})",
2148 test_kind, compiler.stage, &compiler.host, target
2150 let _time = util::timeit(&builder);
2152 try_run(builder, &mut cargo.into());
2156 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2157 pub struct CrateRustdocJsonTypes {
2158 host: TargetSelection,
2159 test_kind: TestKind,
2162 impl Step for CrateRustdocJsonTypes {
2164 const DEFAULT: bool = true;
2165 const ONLY_HOSTS: bool = true;
2167 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2168 run.path("src/rustdoc-json-types")
2171 fn make_run(run: RunConfig<'_>) {
2172 let builder = run.builder;
2174 let test_kind = builder.kind.into();
2176 builder.ensure(CrateRustdocJsonTypes { host: run.target, test_kind });
2179 fn run(self, builder: &Builder<'_>) {
2180 let test_kind = self.test_kind;
2181 let target = self.host;
2183 // Use the previous stage compiler to reuse the artifacts that are
2184 // created when running compiletest for src/test/rustdoc. If this used
2185 // `compiler`, then it would cause rustdoc to be built *again*, which
2186 // isn't really necessary.
2187 let compiler = builder.compiler_for(builder.top_stage, target, target);
2188 builder.ensure(compile::Rustc::new(compiler, target));
2190 let mut cargo = tool::prepare_tool_cargo(
2195 test_kind.subcommand(),
2196 "src/rustdoc-json-types",
2200 if test_kind.subcommand() == "test" && !builder.fail_fast {
2201 cargo.arg("--no-fail-fast");
2204 cargo.arg("-p").arg("rustdoc-json-types");
2207 cargo.args(&builder.config.cmd.test_args());
2209 if self.host.contains("musl") {
2210 cargo.arg("'-Ctarget-feature=-crt-static'");
2213 if !builder.config.verbose_tests {
2214 cargo.arg("--quiet");
2217 builder.info(&format!(
2218 "{} rustdoc-json-types stage{} ({} -> {})",
2219 test_kind, compiler.stage, &compiler.host, target
2221 let _time = util::timeit(&builder);
2223 try_run(builder, &mut cargo.into());
2227 /// Some test suites are run inside emulators or on remote devices, and most
2228 /// of our test binaries are linked dynamically which means we need to ship
2229 /// the standard library and such to the emulator ahead of time. This step
2230 /// represents this and is a dependency of all test suites.
2232 /// Most of the time this is a no-op. For some steps such as shipping data to
2233 /// QEMU we have to build our own tools so we've got conditional dependencies
2234 /// on those programs as well. Note that the remote test client is built for
2235 /// the build target (us) and the server is built for the target.
2236 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2237 pub struct RemoteCopyLibs {
2239 target: TargetSelection,
2242 impl Step for RemoteCopyLibs {
2245 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2249 fn run(self, builder: &Builder<'_>) {
2250 let compiler = self.compiler;
2251 let target = self.target;
2252 if !builder.remote_tested(target) {
2256 builder.ensure(compile::Std::new(compiler, target));
2258 builder.info(&format!("REMOTE copy libs to emulator ({})", target));
2260 let server = builder.ensure(tool::RemoteTestServer { compiler, target });
2262 // Spawn the emulator and wait for it to come online
2263 let tool = builder.tool_exe(Tool::RemoteTestClient);
2264 let mut cmd = Command::new(&tool);
2265 cmd.arg("spawn-emulator").arg(target.triple).arg(&server).arg(builder.tempdir());
2266 if let Some(rootfs) = builder.qemu_rootfs(target) {
2269 builder.run(&mut cmd);
2271 // Push all our dylibs to the emulator
2272 for f in t!(builder.sysroot_libdir(compiler, target).read_dir()) {
2274 let name = f.file_name().into_string().unwrap();
2275 if util::is_dylib(&name) {
2276 builder.run(Command::new(&tool).arg("push").arg(f.path()));
2282 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2283 pub struct Distcheck;
2285 impl Step for Distcheck {
2288 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2289 run.alias("distcheck")
2292 fn make_run(run: RunConfig<'_>) {
2293 run.builder.ensure(Distcheck);
2296 /// Runs "distcheck", a 'make check' from a tarball
2297 fn run(self, builder: &Builder<'_>) {
2298 builder.info("Distcheck");
2299 let dir = builder.tempdir().join("distcheck");
2300 let _ = fs::remove_dir_all(&dir);
2301 t!(fs::create_dir_all(&dir));
2303 // Guarantee that these are built before we begin running.
2304 builder.ensure(dist::PlainSourceTarball);
2305 builder.ensure(dist::Src);
2307 let mut cmd = Command::new("tar");
2309 .arg(builder.ensure(dist::PlainSourceTarball).tarball())
2310 .arg("--strip-components=1")
2312 builder.run(&mut cmd);
2314 Command::new("./configure")
2315 .args(&builder.config.configure_args)
2316 .arg("--enable-vendor")
2320 Command::new(util::make(&builder.config.build.triple)).arg("check").current_dir(&dir),
2323 // Now make sure that rust-src has all of libstd's dependencies
2324 builder.info("Distcheck rust-src");
2325 let dir = builder.tempdir().join("distcheck-src");
2326 let _ = fs::remove_dir_all(&dir);
2327 t!(fs::create_dir_all(&dir));
2329 let mut cmd = Command::new("tar");
2331 .arg(builder.ensure(dist::Src).tarball())
2332 .arg("--strip-components=1")
2334 builder.run(&mut cmd);
2336 let toml = dir.join("rust-src/lib/rustlib/src/rust/library/std/Cargo.toml");
2338 Command::new(&builder.initial_cargo)
2339 .arg("generate-lockfile")
2340 .arg("--manifest-path")
2347 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2348 pub struct Bootstrap;
2350 impl Step for Bootstrap {
2352 const DEFAULT: bool = true;
2353 const ONLY_HOSTS: bool = true;
2355 /// Tests the build system itself.
2356 fn run(self, builder: &Builder<'_>) {
2357 let mut check_bootstrap = Command::new(&builder.python());
2358 check_bootstrap.arg("bootstrap_test.py").current_dir(builder.src.join("src/bootstrap/"));
2359 try_run(builder, &mut check_bootstrap);
2361 let mut cmd = Command::new(&builder.initial_cargo);
2363 .current_dir(builder.src.join("src/bootstrap"))
2364 .env("RUSTFLAGS", "-Cdebuginfo=2")
2365 .env("CARGO_TARGET_DIR", builder.out.join("bootstrap"))
2366 .env("RUSTC_BOOTSTRAP", "1")
2367 .env("RUSTDOC", builder.rustdoc(builder.compiler(0, builder.build.build)))
2368 .env("RUSTC", &builder.initial_rustc);
2369 if let Some(flags) = option_env!("RUSTFLAGS") {
2370 // Use the same rustc flags for testing as for "normal" compilation,
2371 // so that Cargo doesn’t recompile the entire dependency graph every time:
2372 // https://github.com/rust-lang/rust/issues/49215
2373 cmd.env("RUSTFLAGS", flags);
2375 if !builder.fail_fast {
2376 cmd.arg("--no-fail-fast");
2378 match builder.doc_tests {
2383 cmd.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]);
2388 cmd.arg("--").args(&builder.config.cmd.test_args());
2389 // rustbuild tests are racy on directory creation so just run them one at a time.
2390 // Since there's not many this shouldn't be a problem.
2391 cmd.arg("--test-threads=1");
2392 try_run(builder, &mut cmd);
2395 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2396 run.path("src/bootstrap")
2399 fn make_run(run: RunConfig<'_>) {
2400 run.builder.ensure(Bootstrap);
2404 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2405 pub struct TierCheck {
2406 pub compiler: Compiler,
2409 impl Step for TierCheck {
2411 const DEFAULT: bool = true;
2412 const ONLY_HOSTS: bool = true;
2414 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2415 run.path("src/tools/tier-check")
2418 fn make_run(run: RunConfig<'_>) {
2420 run.builder.compiler_for(run.builder.top_stage, run.builder.build.build, run.target);
2421 run.builder.ensure(TierCheck { compiler });
2424 /// Tests the Platform Support page in the rustc book.
2425 fn run(self, builder: &Builder<'_>) {
2426 builder.ensure(compile::Std::new(self.compiler, self.compiler.host));
2427 let mut cargo = tool::prepare_tool_cargo(
2433 "src/tools/tier-check",
2437 cargo.arg(builder.src.join("src/doc/rustc/src/platform-support.md"));
2438 cargo.arg(&builder.rustc(self.compiler));
2439 if builder.is_verbose() {
2440 cargo.arg("--verbose");
2443 builder.info("platform support check");
2444 try_run(builder, &mut cargo.into());
2448 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2449 pub struct LintDocs {
2450 pub compiler: Compiler,
2451 pub target: TargetSelection,
2454 impl Step for LintDocs {
2456 const DEFAULT: bool = true;
2457 const ONLY_HOSTS: bool = true;
2459 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2460 run.path("src/tools/lint-docs")
2463 fn make_run(run: RunConfig<'_>) {
2464 run.builder.ensure(LintDocs {
2465 compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
2470 /// Tests that the lint examples in the rustc book generate the correct
2471 /// lints and have the expected format.
2472 fn run(self, builder: &Builder<'_>) {
2473 builder.ensure(crate::doc::RustcBook {
2474 compiler: self.compiler,
2475 target: self.target,