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::Crate as CargoCrate;
25 use crate::{envify, CLang, DocTests, GitRepo, Mode};
27 const ADB_TEST_DIR: &str = "/data/tmp/work";
29 /// The two modes of the test runner; tests or benchmarks.
30 #[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, PartialOrd, Ord)]
34 /// Run `cargo bench`.
38 impl From<Kind> for TestKind {
39 fn from(kind: Kind) -> Self {
41 Kind::Test => TestKind::Test,
42 Kind::Bench => TestKind::Bench,
43 _ => panic!("unexpected kind in crate: {:?}", kind),
49 // Return the cargo subcommand for this test kind
50 fn subcommand(self) -> &'static str {
52 TestKind::Test => "test",
53 TestKind::Bench => "bench",
58 impl fmt::Display for TestKind {
59 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
60 f.write_str(match *self {
61 TestKind::Test => "Testing",
62 TestKind::Bench => "Benchmarking",
67 fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool {
68 if !builder.fail_fast {
69 if !builder.try_run(cmd) {
70 let mut failures = builder.delayed_failures.borrow_mut();
71 failures.push(format!("{:?}", cmd));
80 fn try_run_quiet(builder: &Builder<'_>, cmd: &mut Command) -> bool {
81 if !builder.fail_fast {
82 if !builder.try_run_quiet(cmd) {
83 let mut failures = builder.delayed_failures.borrow_mut();
84 failures.push(format!("{:?}", cmd));
88 builder.run_quiet(cmd);
93 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
94 pub struct Linkcheck {
95 host: TargetSelection,
98 impl Step for Linkcheck {
100 const ONLY_HOSTS: bool = true;
101 const DEFAULT: bool = true;
103 /// Runs the `linkchecker` tool as compiled in `stage` by the `host` compiler.
105 /// This tool in `src/tools` will verify the validity of all our links in the
106 /// documentation to ensure we don't have a bunch of dead ones.
107 fn run(self, builder: &Builder<'_>) {
108 let host = self.host;
109 let hosts = &builder.hosts;
110 let targets = &builder.targets;
112 // if we have different hosts and targets, some things may be built for
113 // the host (e.g. rustc) and others for the target (e.g. std). The
114 // documentation built for each will contain broken links to
115 // docs built for the other platform (e.g. rustc linking to cargo)
116 if (hosts != targets) && !hosts.is_empty() && !targets.is_empty() {
118 "Linkcheck currently does not support builds with different hosts and targets.
119 You can skip linkcheck with --exclude src/tools/linkchecker"
123 builder.info(&format!("Linkcheck ({})", host));
125 // Test the linkchecker itself.
126 let bootstrap_host = builder.config.build;
127 let compiler = builder.compiler(0, bootstrap_host);
128 let cargo = tool::prepare_tool_cargo(
134 "src/tools/linkchecker",
138 try_run(builder, &mut cargo.into());
140 // Build all the default documentation.
141 builder.default_doc(&[]);
143 // Run the linkchecker.
144 let _time = util::timeit(&builder);
147 builder.tool_cmd(Tool::Linkchecker).arg(builder.out.join(host.triple).join("doc")),
151 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
152 let builder = run.builder;
153 let run = run.path("src/tools/linkchecker");
154 run.default_condition(builder.config.docs)
157 fn make_run(run: RunConfig<'_>) {
158 run.builder.ensure(Linkcheck { host: run.target });
162 fn check_if_tidy_is_installed() -> bool {
165 .stdout(Stdio::null())
167 .map_or(false, |status| status.success())
170 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
171 pub struct HtmlCheck {
172 target: TargetSelection,
175 impl Step for HtmlCheck {
177 const DEFAULT: bool = true;
178 const ONLY_HOSTS: bool = true;
180 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
181 let run = run.path("src/tools/html-checker");
182 run.lazy_default_condition(Box::new(check_if_tidy_is_installed))
185 fn make_run(run: RunConfig<'_>) {
186 run.builder.ensure(HtmlCheck { target: run.target });
189 fn run(self, builder: &Builder<'_>) {
190 if !check_if_tidy_is_installed() {
191 eprintln!("not running HTML-check tool because `tidy` is missing");
193 "Note that `tidy` is not the in-tree `src/tools/tidy` but needs to be installed"
195 panic!("Cannot run html-check tests");
197 // Ensure that a few different kinds of documentation are available.
198 builder.default_doc(&[]);
199 builder.ensure(crate::doc::Rustc { target: self.target, stage: builder.top_stage });
201 try_run(builder, builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target)));
205 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
206 pub struct Cargotest {
208 host: TargetSelection,
211 impl Step for Cargotest {
213 const ONLY_HOSTS: bool = true;
215 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
216 run.path("src/tools/cargotest")
219 fn make_run(run: RunConfig<'_>) {
220 run.builder.ensure(Cargotest { stage: run.builder.top_stage, host: run.target });
223 /// Runs the `cargotest` tool as compiled in `stage` by the `host` compiler.
225 /// This tool in `src/tools` will check out a few Rust projects and run `cargo
226 /// test` to ensure that we don't regress the test suites there.
227 fn run(self, builder: &Builder<'_>) {
228 let compiler = builder.compiler(self.stage, self.host);
229 builder.ensure(compile::Rustc { compiler, target: compiler.host });
230 let cargo = builder.ensure(tool::Cargo { compiler, target: compiler.host });
232 // Note that this is a short, cryptic, and not scoped directory name. This
233 // is currently to minimize the length of path on Windows where we otherwise
234 // quickly run into path name limit constraints.
235 let out_dir = builder.out.join("ct");
236 t!(fs::create_dir_all(&out_dir));
238 let _time = util::timeit(&builder);
239 let mut cmd = builder.tool_cmd(Tool::CargoTest);
244 .args(builder.config.cmd.test_args())
245 .env("RUSTC", builder.rustc(compiler))
246 .env("RUSTDOC", builder.rustdoc(compiler)),
251 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
254 host: TargetSelection,
257 impl Step for Cargo {
259 const ONLY_HOSTS: bool = true;
261 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
262 run.path("src/tools/cargo")
265 fn make_run(run: RunConfig<'_>) {
266 run.builder.ensure(Cargo { stage: run.builder.top_stage, host: run.target });
269 /// Runs `cargo test` for `cargo` packaged with Rust.
270 fn run(self, builder: &Builder<'_>) {
271 let compiler = builder.compiler(self.stage, self.host);
273 builder.ensure(tool::Cargo { compiler, target: self.host });
274 let mut cargo = tool::prepare_tool_cargo(
281 SourceType::Submodule,
285 if !builder.fail_fast {
286 cargo.arg("--no-fail-fast");
288 cargo.arg("--").args(builder.config.cmd.test_args());
290 // Don't run cross-compile tests, we may not have cross-compiled libstd libs
292 cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
293 // Disable a test that has issues with mingw.
294 cargo.env("CARGO_TEST_DISABLE_GIT_CLI", "1");
295 // Forcibly disable tests using nightly features since any changes to
296 // those features won't be able to land.
297 cargo.env("CARGO_TEST_DISABLE_NIGHTLY", "1");
299 cargo.env("PATH", &path_for_cargo(builder, compiler));
301 try_run(builder, &mut cargo.into());
305 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
308 host: TargetSelection,
313 const ONLY_HOSTS: bool = true;
315 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
316 run.path("src/tools/rls")
319 fn make_run(run: RunConfig<'_>) {
320 run.builder.ensure(Rls { stage: run.builder.top_stage, host: run.target });
323 /// Runs `cargo test` for the rls.
324 fn run(self, builder: &Builder<'_>) {
325 let stage = self.stage;
326 let host = self.host;
327 let compiler = builder.compiler(stage, host);
330 builder.ensure(tool::Rls { compiler, target: self.host, extra_features: Vec::new() });
331 if build_result.is_none() {
332 eprintln!("failed to test rls: could not build");
336 let mut cargo = tool::prepare_tool_cargo(
343 SourceType::Submodule,
347 cargo.add_rustc_lib_path(builder, compiler);
348 cargo.arg("--").args(builder.config.cmd.test_args());
350 if try_run(builder, &mut cargo.into()) {
351 builder.save_toolstate("rls", ToolState::TestPass);
356 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
359 host: TargetSelection,
362 impl Step for Rustfmt {
364 const ONLY_HOSTS: bool = true;
366 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
367 run.path("src/tools/rustfmt")
370 fn make_run(run: RunConfig<'_>) {
371 run.builder.ensure(Rustfmt { stage: run.builder.top_stage, host: run.target });
374 /// Runs `cargo test` for rustfmt.
375 fn run(self, builder: &Builder<'_>) {
376 let stage = self.stage;
377 let host = self.host;
378 let compiler = builder.compiler(stage, host);
381 .ensure(tool::Rustfmt { compiler, target: self.host, extra_features: Vec::new() })
382 .expect("in-tree tool");
384 let mut cargo = tool::prepare_tool_cargo(
395 let dir = testdir(builder, compiler.host);
396 t!(fs::create_dir_all(&dir));
397 cargo.env("RUSTFMT_TEST_DIR", dir);
399 cargo.add_rustc_lib_path(builder, compiler);
401 builder.run(&mut cargo.into());
405 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
406 pub struct RustDemangler {
408 host: TargetSelection,
411 impl Step for RustDemangler {
413 const ONLY_HOSTS: bool = true;
415 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
416 run.path("src/tools/rust-demangler")
419 fn make_run(run: RunConfig<'_>) {
420 run.builder.ensure(RustDemangler { stage: run.builder.top_stage, host: run.target });
423 /// Runs `cargo test` for rust-demangler.
424 fn run(self, builder: &Builder<'_>) {
425 let stage = self.stage;
426 let host = self.host;
427 let compiler = builder.compiler(stage, host);
429 let rust_demangler = builder
430 .ensure(tool::RustDemangler { compiler, target: self.host, extra_features: Vec::new() })
431 .expect("in-tree tool");
432 let mut cargo = tool::prepare_tool_cargo(
438 "src/tools/rust-demangler",
443 let dir = testdir(builder, compiler.host);
444 t!(fs::create_dir_all(&dir));
446 cargo.env("RUST_DEMANGLER_DRIVER_PATH", rust_demangler);
448 cargo.arg("--").args(builder.config.cmd.test_args());
450 cargo.add_rustc_lib_path(builder, compiler);
452 builder.run(&mut cargo.into());
456 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
459 host: TargetSelection,
464 const ONLY_HOSTS: bool = true;
466 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
467 run.path("src/tools/miri")
470 fn make_run(run: RunConfig<'_>) {
471 run.builder.ensure(Miri { stage: run.builder.top_stage, host: run.target });
474 /// Runs `cargo test` for miri.
475 fn run(self, builder: &Builder<'_>) {
476 let stage = self.stage;
477 let host = self.host;
478 let compiler = builder.compiler(stage, host);
481 builder.ensure(tool::Miri { compiler, target: self.host, extra_features: Vec::new() });
482 let cargo_miri = builder.ensure(tool::CargoMiri {
485 extra_features: Vec::new(),
487 if let (Some(miri), Some(_cargo_miri)) = (miri, cargo_miri) {
489 builder.cargo(compiler, Mode::ToolRustc, SourceType::Submodule, host, "install");
491 // Configure `cargo install` path. cargo adds a `bin/`.
492 cargo.env("CARGO_INSTALL_ROOT", &builder.out);
494 let mut cargo = Command::from(cargo);
495 if !try_run(builder, &mut cargo) {
499 // # Run `cargo miri setup`.
500 let mut cargo = tool::prepare_tool_cargo(
506 "src/tools/miri/cargo-miri",
507 SourceType::Submodule,
510 cargo.add_rustc_lib_path(builder, compiler);
511 cargo.arg("--").arg("miri").arg("setup");
513 // Tell `cargo miri setup` where to find the sources.
514 cargo.env("XARGO_RUST_SRC", builder.src.join("library"));
515 // Tell it where to find Miri.
516 cargo.env("MIRI", &miri);
518 cargo.env("RUST_BACKTRACE", "1");
519 // Let cargo-miri know where xargo ended up.
520 cargo.env("XARGO_CHECK", builder.out.join("bin").join("xargo-check"));
522 let mut cargo = Command::from(cargo);
523 if !try_run(builder, &mut cargo) {
527 // # Determine where Miri put its sysroot.
528 // To this end, we run `cargo miri setup --print-sysroot` and capture the output.
529 // (We do this separately from the above so that when the setup actually
530 // happens we get some output.)
531 // We re-use the `cargo` from above.
532 cargo.arg("--print-sysroot");
534 // FIXME: Is there a way in which we can re-use the usual `run` helpers?
535 let miri_sysroot = if builder.config.dry_run {
538 builder.verbose(&format!("running: {:?}", cargo));
541 .expect("We already ran `cargo miri setup` before and that worked");
542 assert!(out.status.success(), "`cargo miri setup` returned with non-0 exit code");
543 // Output is "<sysroot>\n".
544 let stdout = String::from_utf8(out.stdout)
545 .expect("`cargo miri setup` stdout is not valid UTF-8");
546 let sysroot = stdout.trim_end();
547 builder.verbose(&format!("`cargo miri setup --print-sysroot` said: {:?}", sysroot));
551 // # Run `cargo test`.
552 let mut cargo = tool::prepare_tool_cargo(
559 SourceType::Submodule,
562 cargo.add_rustc_lib_path(builder, compiler);
564 // miri tests need to know about the stage sysroot
565 cargo.env("MIRI_SYSROOT", miri_sysroot);
566 cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
567 cargo.env("MIRI", miri);
569 cargo.arg("--").args(builder.config.cmd.test_args());
571 let mut cargo = Command::from(cargo);
572 if !try_run(builder, &mut cargo) {
576 // # Run `cargo test` with `-Zmir-opt-level=4`.
577 cargo.env("MIRIFLAGS", "-O -Zmir-opt-level=4");
578 if !try_run(builder, &mut cargo) {
583 builder.save_toolstate("miri", ToolState::TestPass);
585 eprintln!("failed to test miri: could not build");
590 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
591 pub struct CompiletestTest {
592 host: TargetSelection,
595 impl Step for CompiletestTest {
598 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
599 run.path("src/tools/compiletest")
602 fn make_run(run: RunConfig<'_>) {
603 run.builder.ensure(CompiletestTest { host: run.target });
606 /// Runs `cargo test` for compiletest.
607 fn run(self, builder: &Builder<'_>) {
608 let host = self.host;
609 let compiler = builder.compiler(0, host);
611 // We need `ToolStd` for the locally-built sysroot because
612 // compiletest uses unstable features of the `test` crate.
613 builder.ensure(compile::Std { compiler, target: host });
614 let cargo = tool::prepare_tool_cargo(
620 "src/tools/compiletest",
625 try_run(builder, &mut cargo.into());
629 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
632 host: TargetSelection,
635 impl Step for Clippy {
637 const ONLY_HOSTS: bool = true;
638 const DEFAULT: bool = false;
640 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
641 run.path("src/tools/clippy")
644 fn make_run(run: RunConfig<'_>) {
645 run.builder.ensure(Clippy { stage: run.builder.top_stage, host: run.target });
648 /// Runs `cargo test` for clippy.
649 fn run(self, builder: &Builder<'_>) {
650 let stage = self.stage;
651 let host = self.host;
652 let compiler = builder.compiler(stage, host);
655 .ensure(tool::Clippy { compiler, target: self.host, extra_features: Vec::new() })
656 .expect("in-tree tool");
657 let mut cargo = tool::prepare_tool_cargo(
668 // clippy tests need to know about the stage sysroot
669 cargo.env("SYSROOT", builder.sysroot(compiler));
670 cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
671 cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
672 let host_libs = builder.stage_out(compiler, Mode::ToolRustc).join(builder.cargo_dir());
673 cargo.env("HOST_LIBS", host_libs);
675 cargo.arg("--").args(builder.config.cmd.test_args());
677 cargo.add_rustc_lib_path(builder, compiler);
679 if builder.try_run(&mut cargo.into()) {
680 // The tests succeeded; nothing to do.
684 if !builder.config.cmd.bless() {
685 std::process::exit(1);
688 let mut cargo = builder.cargo(compiler, Mode::ToolRustc, SourceType::InTree, host, "run");
689 cargo.arg("-p").arg("clippy_dev");
690 // clippy_dev gets confused if it can't find `clippy/Cargo.toml`
691 cargo.current_dir(&builder.src.join("src").join("tools").join("clippy"));
692 if builder.config.rust_optimize {
693 cargo.env("PROFILE", "release");
695 cargo.env("PROFILE", "debug");
699 builder.run(&mut cargo.into());
703 fn path_for_cargo(builder: &Builder<'_>, compiler: Compiler) -> OsString {
704 // Configure PATH to find the right rustc. NB. we have to use PATH
705 // and not RUSTC because the Cargo test suite has tests that will
706 // fail if rustc is not spelled `rustc`.
707 let path = builder.sysroot(compiler).join("bin");
708 let old_path = env::var_os("PATH").unwrap_or_default();
709 env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("")
712 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
713 pub struct RustdocTheme {
714 pub compiler: Compiler,
717 impl Step for RustdocTheme {
719 const DEFAULT: bool = true;
720 const ONLY_HOSTS: bool = true;
722 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
723 run.path("src/tools/rustdoc-themes")
726 fn make_run(run: RunConfig<'_>) {
727 let compiler = run.builder.compiler(run.builder.top_stage, run.target);
729 run.builder.ensure(RustdocTheme { compiler });
732 fn run(self, builder: &Builder<'_>) {
733 let rustdoc = builder.bootstrap_out.join("rustdoc");
734 let mut cmd = builder.tool_cmd(Tool::RustdocTheme);
735 cmd.arg(rustdoc.to_str().unwrap())
736 .arg(builder.src.join("src/librustdoc/html/static/css/themes").to_str().unwrap())
737 .env("RUSTC_STAGE", self.compiler.stage.to_string())
738 .env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
739 .env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host))
740 .env("CFG_RELEASE_CHANNEL", &builder.config.channel)
741 .env("RUSTDOC_REAL", builder.rustdoc(self.compiler))
742 .env("RUSTC_BOOTSTRAP", "1");
743 if let Some(linker) = builder.linker(self.compiler.host) {
744 cmd.env("RUSTDOC_LINKER", linker);
746 if builder.is_fuse_ld_lld(self.compiler.host) {
747 cmd.env("RUSTDOC_FUSE_LD_LLD", "1");
749 try_run(builder, &mut cmd);
753 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
754 pub struct RustdocJSStd {
755 pub target: TargetSelection,
758 impl Step for RustdocJSStd {
760 const DEFAULT: bool = true;
761 const ONLY_HOSTS: bool = true;
763 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
764 run.suite_path("src/test/rustdoc-js-std")
767 fn make_run(run: RunConfig<'_>) {
768 run.builder.ensure(RustdocJSStd { target: run.target });
771 fn run(self, builder: &Builder<'_>) {
772 if let Some(ref nodejs) = builder.config.nodejs {
773 let mut command = Command::new(nodejs);
775 .arg(builder.src.join("src/tools/rustdoc-js/tester.js"))
778 .arg("--resource-suffix")
779 .arg(&builder.version)
781 .arg(builder.doc_out(self.target))
782 .arg("--test-folder")
783 .arg(builder.src.join("src/test/rustdoc-js-std"));
784 for path in &builder.paths {
786 util::is_valid_test_suite_arg(path, "src/test/rustdoc-js-std", builder)
788 if !p.ends_with(".js") {
789 eprintln!("A non-js file was given: `{}`", path.display());
790 panic!("Cannot run rustdoc-js-std tests");
792 command.arg("--test-file").arg(path);
795 builder.ensure(crate::doc::Std { target: self.target, stage: builder.top_stage });
796 builder.run(&mut command);
798 builder.info("No nodejs found, skipping \"src/test/rustdoc-js-std\" tests");
803 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
804 pub struct RustdocJSNotStd {
805 pub target: TargetSelection,
806 pub compiler: Compiler,
809 impl Step for RustdocJSNotStd {
811 const DEFAULT: bool = true;
812 const ONLY_HOSTS: bool = true;
814 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
815 run.suite_path("src/test/rustdoc-js")
818 fn make_run(run: RunConfig<'_>) {
819 let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
820 run.builder.ensure(RustdocJSNotStd { target: run.target, compiler });
823 fn run(self, builder: &Builder<'_>) {
824 if builder.config.nodejs.is_some() {
825 builder.ensure(Compiletest {
826 compiler: self.compiler,
830 path: "src/test/rustdoc-js",
834 builder.info("No nodejs found, skipping \"src/test/rustdoc-js\" tests");
839 fn get_browser_ui_test_version_inner(npm: &Path, global: bool) -> Option<String> {
840 let mut command = Command::new(&npm);
841 command.arg("list").arg("--parseable").arg("--long").arg("--depth=0");
843 command.arg("--global");
847 .map(|output| String::from_utf8_lossy(&output.stdout).into_owned())
848 .unwrap_or(String::new());
849 lines.lines().find_map(|l| l.split(":browser-ui-test@").skip(1).next()).map(|v| v.to_owned())
852 fn get_browser_ui_test_version(npm: &Path) -> Option<String> {
853 get_browser_ui_test_version_inner(npm, false)
854 .or_else(|| get_browser_ui_test_version_inner(npm, true))
857 fn compare_browser_ui_test_version(installed_version: &str, src: &Path) {
858 match fs::read_to_string(
859 src.join("src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version"),
862 if v.trim() != installed_version {
864 "⚠️ Installed version of browser-ui-test (`{}`) is different than the \
865 one used in the CI (`{}`)",
870 Err(e) => eprintln!("Couldn't find the CI browser-ui-test version: {:?}", e),
874 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
875 pub struct RustdocGUI {
876 pub target: TargetSelection,
877 pub compiler: Compiler,
880 impl Step for RustdocGUI {
882 const DEFAULT: bool = true;
883 const ONLY_HOSTS: bool = true;
885 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
886 let builder = run.builder;
887 let run = run.suite_path("src/test/rustdoc-gui");
888 run.lazy_default_condition(Box::new(move || {
889 builder.config.nodejs.is_some()
894 .map(|p| get_browser_ui_test_version(p).is_some())
899 fn make_run(run: RunConfig<'_>) {
900 let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
901 run.builder.ensure(RustdocGUI { target: run.target, compiler });
904 fn run(self, builder: &Builder<'_>) {
905 let nodejs = builder.config.nodejs.as_ref().expect("nodejs isn't available");
906 let npm = builder.config.npm.as_ref().expect("npm isn't available");
908 builder.ensure(compile::Std { compiler: self.compiler, target: self.target });
910 // The goal here is to check if the necessary packages are installed, and if not, we
912 match get_browser_ui_test_version(&npm) {
914 // We also check the version currently used in CI and emit a warning if it's not the
916 compare_browser_ui_test_version(&version, &builder.build.src);
920 "error: rustdoc-gui test suite cannot be run because npm `browser-ui-test` \
921 dependency is missing",
924 "If you want to install the `{0}` dependency, run `npm install {0}`",
927 panic!("Cannot run rustdoc-gui tests");
931 let out_dir = builder.test_out(self.target).join("rustdoc-gui");
933 // We remove existing folder to be sure there won't be artifacts remaining.
934 builder.clear_if_dirty(&out_dir, &builder.rustdoc(self.compiler));
936 let src_path = builder.build.src.join("src/test/rustdoc-gui/src");
937 // We generate docs for the libraries present in the rustdoc-gui's src folder.
938 for entry in src_path.read_dir().expect("read_dir call failed") {
939 if let Ok(entry) = entry {
940 let path = entry.path();
946 let mut cargo = Command::new(&builder.initial_cargo);
951 .env("RUSTDOC", builder.rustdoc(self.compiler))
952 .env("RUSTC", builder.rustc(self.compiler))
954 // FIXME: implement a `// compile-flags` command or similar
955 // instead of hard-coding this test
956 if entry.file_name() == "link_to_definition" {
957 cargo.env("RUSTDOCFLAGS", "-Zunstable-options --generate-link-to-definition");
959 builder.run(&mut cargo);
963 // We now run GUI tests.
964 let mut command = Command::new(&nodejs);
966 .arg(builder.build.src.join("src/tools/rustdoc-gui/tester.js"))
968 .arg(&builder.jobs().to_string())
970 .arg(out_dir.join("doc"))
971 .arg("--tests-folder")
972 .arg(builder.build.src.join("src/test/rustdoc-gui"));
973 for path in &builder.paths {
974 if let Some(p) = util::is_valid_test_suite_arg(path, "src/test/rustdoc-gui", builder) {
975 if !p.ends_with(".goml") {
976 eprintln!("A non-goml file was given: `{}`", path.display());
977 panic!("Cannot run rustdoc-gui tests");
979 if let Some(name) = path.file_name().and_then(|f| f.to_str()) {
980 command.arg("--file").arg(name);
984 for test_arg in builder.config.cmd.test_args() {
985 command.arg(test_arg);
987 builder.run(&mut command);
991 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
996 const DEFAULT: bool = true;
997 const ONLY_HOSTS: bool = true;
999 /// Runs the `tidy` tool.
1001 /// This tool in `src/tools` checks up on various bits and pieces of style and
1002 /// otherwise just implements a few lint-like checks that are specific to the
1003 /// compiler itself.
1005 /// Once tidy passes, this step also runs `fmt --check` if tests are being run
1006 /// for the `dev` or `nightly` channels.
1007 fn run(self, builder: &Builder<'_>) {
1008 let mut cmd = builder.tool_cmd(Tool::Tidy);
1009 cmd.arg(&builder.src);
1010 cmd.arg(&builder.initial_cargo);
1011 cmd.arg(&builder.out);
1012 cmd.arg(builder.jobs().to_string());
1013 if builder.is_verbose() {
1014 cmd.arg("--verbose");
1017 builder.info("tidy check");
1018 try_run(builder, &mut cmd);
1020 if builder.config.channel == "dev" || builder.config.channel == "nightly" {
1021 builder.info("fmt check");
1022 if builder.config.initial_rustfmt.is_none() {
1023 let inferred_rustfmt_dir = builder.config.initial_rustc.parent().unwrap();
1026 error: no `rustfmt` binary found in {PATH}
1027 info: `rust.channel` is currently set to \"{CHAN}\"
1028 help: if you are testing a beta branch, set `rust.channel` to \"beta\" in the `config.toml` file
1029 help: to skip test's attempt to check tidiness, pass `--exclude src/tools/tidy` to `x.py test`",
1030 PATH = inferred_rustfmt_dir.display(),
1031 CHAN = builder.config.channel,
1033 std::process::exit(1);
1035 crate::format::format(&builder.build, !builder.config.cmd.bless(), &[]);
1039 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1040 run.path("src/tools/tidy")
1043 fn make_run(run: RunConfig<'_>) {
1044 run.builder.ensure(Tidy);
1048 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1049 pub struct ExpandYamlAnchors;
1051 impl Step for ExpandYamlAnchors {
1053 const ONLY_HOSTS: bool = true;
1055 /// Ensure the `generate-ci-config` tool was run locally.
1057 /// The tool in `src/tools` reads the CI definition in `src/ci/builders.yml` and generates the
1058 /// appropriate configuration for all our CI providers. This step ensures the tool was called
1059 /// by the user before committing CI changes.
1060 fn run(self, builder: &Builder<'_>) {
1061 builder.info("Ensuring the YAML anchors in the GitHub Actions config were expanded");
1064 &mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("check").arg(&builder.src),
1068 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1069 run.path("src/tools/expand-yaml-anchors")
1072 fn make_run(run: RunConfig<'_>) {
1073 run.builder.ensure(ExpandYamlAnchors);
1077 fn testdir(builder: &Builder<'_>, host: TargetSelection) -> PathBuf {
1078 builder.out.join(host.triple).join("test")
1081 macro_rules! default_test {
1082 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr }) => {
1083 test!($name { path: $path, mode: $mode, suite: $suite, default: true, host: false });
1087 macro_rules! default_test_with_compare_mode {
1088 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr,
1089 compare_mode: $compare_mode:expr }) => {
1090 test_with_compare_mode!($name {
1096 compare_mode: $compare_mode
1101 macro_rules! host_test {
1102 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr }) => {
1103 test!($name { path: $path, mode: $mode, suite: $suite, default: true, host: true });
1108 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr, default: $default:expr,
1109 host: $host:expr }) => {
1110 test_definitions!($name {
1121 macro_rules! test_with_compare_mode {
1122 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr, default: $default:expr,
1123 host: $host:expr, compare_mode: $compare_mode:expr }) => {
1124 test_definitions!($name {
1130 compare_mode: Some($compare_mode)
1135 macro_rules! test_definitions {
1140 default: $default:expr,
1142 compare_mode: $compare_mode:expr
1144 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1146 pub compiler: Compiler,
1147 pub target: TargetSelection,
1150 impl Step for $name {
1152 const DEFAULT: bool = $default;
1153 const ONLY_HOSTS: bool = $host;
1155 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1156 run.suite_path($path)
1159 fn make_run(run: RunConfig<'_>) {
1160 let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
1162 run.builder.ensure($name { compiler, target: run.target });
1165 fn run(self, builder: &Builder<'_>) {
1166 builder.ensure(Compiletest {
1167 compiler: self.compiler,
1168 target: self.target,
1172 compare_mode: $compare_mode,
1179 default_test_with_compare_mode!(Ui {
1180 path: "src/test/ui",
1186 default_test!(RunPassValgrind {
1187 path: "src/test/run-pass-valgrind",
1188 mode: "run-pass-valgrind",
1189 suite: "run-pass-valgrind"
1192 default_test!(MirOpt { path: "src/test/mir-opt", mode: "mir-opt", suite: "mir-opt" });
1194 default_test!(Codegen { path: "src/test/codegen", mode: "codegen", suite: "codegen" });
1196 default_test!(CodegenUnits {
1197 path: "src/test/codegen-units",
1198 mode: "codegen-units",
1199 suite: "codegen-units"
1202 default_test!(Incremental {
1203 path: "src/test/incremental",
1204 mode: "incremental",
1205 suite: "incremental"
1208 default_test_with_compare_mode!(Debuginfo {
1209 path: "src/test/debuginfo",
1212 compare_mode: "split-dwarf"
1215 host_test!(UiFullDeps { path: "src/test/ui-fulldeps", mode: "ui", suite: "ui-fulldeps" });
1217 host_test!(Rustdoc { path: "src/test/rustdoc", mode: "rustdoc", suite: "rustdoc" });
1218 host_test!(RustdocUi { path: "src/test/rustdoc-ui", mode: "ui", suite: "rustdoc-ui" });
1220 host_test!(RustdocJson {
1221 path: "src/test/rustdoc-json",
1222 mode: "rustdoc-json",
1223 suite: "rustdoc-json"
1226 host_test!(Pretty { path: "src/test/pretty", mode: "pretty", suite: "pretty" });
1228 default_test!(RunMake { path: "src/test/run-make", mode: "run-make", suite: "run-make" });
1230 host_test!(RunMakeFullDeps {
1231 path: "src/test/run-make-fulldeps",
1233 suite: "run-make-fulldeps"
1236 default_test!(Assembly { path: "src/test/assembly", mode: "assembly", suite: "assembly" });
1238 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1239 struct Compiletest {
1241 target: TargetSelection,
1243 suite: &'static str,
1245 compare_mode: Option<&'static str>,
1248 impl Step for Compiletest {
1251 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1255 /// Executes the `compiletest` tool to run a suite of tests.
1257 /// Compiles all tests with `compiler` for `target` with the specified
1258 /// compiletest `mode` and `suite` arguments. For example `mode` can be
1259 /// "run-pass" or `suite` can be something like `debuginfo`.
1260 fn run(self, builder: &Builder<'_>) {
1261 if builder.top_stage == 0 && env::var("COMPILETEST_FORCE_STAGE0").is_err() {
1263 error: `--stage 0` runs compiletest on the beta compiler, not your local changes, and will almost always cause tests to fail
1264 help: to test the compiler, use `--stage 1` instead
1265 help: to test the standard library, use `--stage 0 library/std` instead
1266 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`."
1268 std::process::exit(1);
1271 let compiler = self.compiler;
1272 let target = self.target;
1273 let mode = self.mode;
1274 let suite = self.suite;
1276 // Path for test suite
1277 let suite_path = self.path;
1279 // Skip codegen tests if they aren't enabled in configuration.
1280 if !builder.config.codegen_tests && suite == "codegen" {
1284 if suite == "debuginfo" {
1286 .ensure(dist::DebuggerScripts { sysroot: builder.sysroot(compiler), host: target });
1289 if suite.ends_with("fulldeps") {
1290 builder.ensure(compile::Rustc { compiler, target });
1293 builder.ensure(compile::Std { compiler, target });
1294 // ensure that `libproc_macro` is available on the host.
1295 builder.ensure(compile::Std { compiler, target: compiler.host });
1297 // Also provide `rust_test_helpers` for the host.
1298 builder.ensure(native::TestHelpers { target: compiler.host });
1300 // As well as the target, except for plain wasm32, which can't build it
1301 if !target.contains("wasm") || target.contains("emscripten") {
1302 builder.ensure(native::TestHelpers { target });
1305 builder.ensure(RemoteCopyLibs { compiler, target });
1307 let mut cmd = builder.tool_cmd(Tool::Compiletest);
1309 // compiletest currently has... a lot of arguments, so let's just pass all
1312 cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler));
1313 cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target));
1314 cmd.arg("--rustc-path").arg(builder.rustc(compiler));
1316 let is_rustdoc = suite.ends_with("rustdoc-ui") || suite.ends_with("rustdoc-js");
1318 // Avoid depending on rustdoc when we don't need it.
1319 if mode == "rustdoc"
1320 || mode == "run-make"
1321 || (mode == "ui" && is_rustdoc)
1322 || mode == "js-doc-test"
1323 || mode == "rustdoc-json"
1325 cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler));
1328 if mode == "rustdoc-json" {
1329 // Use the beta compiler for jsondocck
1330 let json_compiler = compiler.with_stage(0);
1331 cmd.arg("--jsondocck-path")
1332 .arg(builder.ensure(tool::JsonDocCk { compiler: json_compiler, target }));
1335 if mode == "run-make" && suite.ends_with("fulldeps") {
1336 let rust_demangler = builder
1337 .ensure(tool::RustDemangler { compiler, target, extra_features: Vec::new() })
1338 .expect("in-tree tool");
1339 cmd.arg("--rust-demangler-path").arg(rust_demangler);
1342 cmd.arg("--src-base").arg(builder.src.join("src/test").join(suite));
1343 cmd.arg("--build-base").arg(testdir(builder, compiler.host).join(suite));
1344 cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
1345 cmd.arg("--suite").arg(suite);
1346 cmd.arg("--mode").arg(mode);
1347 cmd.arg("--target").arg(target.rustc_target_arg());
1348 cmd.arg("--host").arg(&*compiler.host.triple);
1349 cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.build));
1351 if builder.config.cmd.bless() {
1355 if builder.config.cmd.force_rerun() {
1356 cmd.arg("--force-rerun");
1360 builder.config.cmd.compare_mode().or_else(|| {
1361 if builder.config.test_compare_mode { self.compare_mode } else { None }
1364 if let Some(ref pass) = builder.config.cmd.pass() {
1369 if let Some(ref run) = builder.config.cmd.run() {
1374 if let Some(ref nodejs) = builder.config.nodejs {
1375 cmd.arg("--nodejs").arg(nodejs);
1377 if let Some(ref npm) = builder.config.npm {
1378 cmd.arg("--npm").arg(npm);
1381 let mut flags = if is_rustdoc { Vec::new() } else { vec!["-Crpath".to_string()] };
1383 if builder.config.rust_optimize_tests {
1384 flags.push("-O".to_string());
1387 flags.push(format!("-Cdebuginfo={}", builder.config.rust_debuginfo_level_tests));
1388 flags.push(builder.config.cmd.rustc_args().join(" "));
1390 if let Some(linker) = builder.linker(target) {
1391 cmd.arg("--linker").arg(linker);
1394 let mut hostflags = flags.clone();
1395 hostflags.push(format!("-Lnative={}", builder.test_helpers_out(compiler.host).display()));
1396 hostflags.extend(builder.lld_flags(compiler.host));
1397 cmd.arg("--host-rustcflags").arg(hostflags.join(" "));
1399 let mut targetflags = flags;
1400 targetflags.push(format!("-Lnative={}", builder.test_helpers_out(target).display()));
1401 targetflags.extend(builder.lld_flags(target));
1402 cmd.arg("--target-rustcflags").arg(targetflags.join(" "));
1404 cmd.arg("--docck-python").arg(builder.python());
1406 if builder.config.build.ends_with("apple-darwin") {
1407 // Force /usr/bin/python3 on macOS for LLDB tests because we're loading the
1408 // LLDB plugin's compiled module which only works with the system python
1409 // (namely not Homebrew-installed python)
1410 cmd.arg("--lldb-python").arg("/usr/bin/python3");
1412 cmd.arg("--lldb-python").arg(builder.python());
1415 if let Some(ref gdb) = builder.config.gdb {
1416 cmd.arg("--gdb").arg(gdb);
1419 let run = |cmd: &mut Command| {
1420 cmd.output().map(|output| {
1421 String::from_utf8_lossy(&output.stdout)
1424 .unwrap_or_else(|| panic!("{:?} failed {:?}", cmd, output))
1428 let lldb_exe = "lldb";
1429 let lldb_version = Command::new(lldb_exe)
1432 .map(|output| String::from_utf8_lossy(&output.stdout).to_string())
1434 if let Some(ref vers) = lldb_version {
1435 cmd.arg("--lldb-version").arg(vers);
1436 let lldb_python_dir = run(Command::new(lldb_exe).arg("-P")).ok();
1437 if let Some(ref dir) = lldb_python_dir {
1438 cmd.arg("--lldb-python-dir").arg(dir);
1442 if util::forcing_clang_based_tests() {
1443 let clang_exe = builder.llvm_out(target).join("bin").join("clang");
1444 cmd.arg("--run-clang-based-tests-with").arg(clang_exe);
1447 // Get paths from cmd args
1448 let paths = match &builder.config.cmd {
1449 Subcommand::Test { ref paths, .. } => &paths[..],
1453 // Get test-args by striping suite path
1454 let mut test_args: Vec<&str> = paths
1456 .filter_map(|p| util::is_valid_test_suite_arg(p, suite_path, builder))
1459 test_args.append(&mut builder.config.cmd.test_args());
1461 cmd.args(&test_args);
1463 if builder.is_verbose() {
1464 cmd.arg("--verbose");
1467 if !builder.config.verbose_tests {
1471 let mut llvm_components_passed = false;
1472 let mut copts_passed = false;
1473 if builder.config.llvm_enabled() {
1474 let llvm_config = builder.ensure(native::Llvm { target: builder.config.build });
1475 if !builder.config.dry_run {
1476 let llvm_version = output(Command::new(&llvm_config).arg("--version"));
1477 let llvm_components = output(Command::new(&llvm_config).arg("--components"));
1478 // Remove trailing newline from llvm-config output.
1479 cmd.arg("--llvm-version")
1480 .arg(llvm_version.trim())
1481 .arg("--llvm-components")
1482 .arg(llvm_components.trim());
1483 llvm_components_passed = true;
1485 if !builder.is_rust_llvm(target) {
1486 cmd.arg("--system-llvm");
1489 // Tests that use compiler libraries may inherit the `-lLLVM` link
1490 // requirement, but the `-L` library path is not propagated across
1491 // separate compilations. We can add LLVM's library path to the
1492 // platform-specific environment variable as a workaround.
1493 if !builder.config.dry_run && suite.ends_with("fulldeps") {
1494 let llvm_libdir = output(Command::new(&llvm_config).arg("--libdir"));
1495 add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cmd);
1498 // Only pass correct values for these flags for the `run-make` suite as it
1499 // requires that a C++ compiler was configured which isn't always the case.
1500 if !builder.config.dry_run && matches!(suite, "run-make" | "run-make-fulldeps") {
1501 // The llvm/bin directory contains many useful cross-platform
1502 // tools. Pass the path to run-make tests so they can use them.
1503 let llvm_bin_path = llvm_config
1505 .expect("Expected llvm-config to be contained in directory");
1506 assert!(llvm_bin_path.is_dir());
1507 cmd.arg("--llvm-bin-dir").arg(llvm_bin_path);
1509 // If LLD is available, add it to the PATH
1510 if builder.config.lld_enabled {
1511 let lld_install_root =
1512 builder.ensure(native::Lld { target: builder.config.build });
1514 let lld_bin_path = lld_install_root.join("bin");
1516 let old_path = env::var_os("PATH").unwrap_or_default();
1517 let new_path = env::join_paths(
1518 std::iter::once(lld_bin_path).chain(env::split_paths(&old_path)),
1520 .expect("Could not add LLD bin path to PATH");
1521 cmd.env("PATH", new_path);
1526 // Only pass correct values for these flags for the `run-make` suite as it
1527 // requires that a C++ compiler was configured which isn't always the case.
1528 if !builder.config.dry_run && matches!(suite, "run-make" | "run-make-fulldeps") {
1530 .arg(builder.cc(target))
1532 .arg(builder.cxx(target).unwrap())
1534 .arg(builder.cflags(target, GitRepo::Rustc, CLang::C).join(" "))
1536 .arg(builder.cflags(target, GitRepo::Rustc, CLang::Cxx).join(" "));
1537 copts_passed = true;
1538 if let Some(ar) = builder.ar(target) {
1539 cmd.arg("--ar").arg(ar);
1543 if !llvm_components_passed {
1544 cmd.arg("--llvm-components").arg("");
1557 if builder.remote_tested(target) {
1558 cmd.arg("--remote-test-client").arg(builder.tool_exe(Tool::RemoteTestClient));
1561 // Running a C compiler on MSVC requires a few env vars to be set, to be
1562 // sure to set them here.
1564 // Note that if we encounter `PATH` we make sure to append to our own `PATH`
1565 // rather than stomp over it.
1566 if target.contains("msvc") {
1567 for &(ref k, ref v) in builder.cc[&target].env() {
1573 cmd.env("RUSTC_BOOTSTRAP", "1");
1574 // Override the rustc version used in symbol hashes to reduce the amount of normalization
1575 // needed when diffing test output.
1576 cmd.env("RUSTC_FORCE_RUSTC_VERSION", "compiletest");
1577 cmd.env("DOC_RUST_LANG_ORG_CHANNEL", builder.doc_rust_lang_org_channel());
1578 builder.add_rust_test_threads(&mut cmd);
1580 if builder.config.sanitizers_enabled(target) {
1581 cmd.env("RUSTC_SANITIZER_SUPPORT", "1");
1584 if builder.config.profiler_enabled(target) {
1585 cmd.env("RUSTC_PROFILER_SUPPORT", "1");
1588 let tmp = builder.out.join("tmp");
1589 std::fs::create_dir_all(&tmp).unwrap();
1590 cmd.env("RUST_TEST_TMPDIR", tmp);
1592 cmd.arg("--adb-path").arg("adb");
1593 cmd.arg("--adb-test-dir").arg(ADB_TEST_DIR);
1594 if target.contains("android") {
1595 // Assume that cc for this target comes from the android sysroot
1596 cmd.arg("--android-cross-path")
1597 .arg(builder.cc(target).parent().unwrap().parent().unwrap());
1599 cmd.arg("--android-cross-path").arg("");
1602 if builder.config.cmd.rustfix_coverage() {
1603 cmd.arg("--rustfix-coverage");
1606 cmd.env("BOOTSTRAP_CARGO", &builder.initial_cargo);
1608 cmd.arg("--channel").arg(&builder.config.channel);
1610 builder.ci_env.force_coloring_in_ci(&mut cmd);
1612 builder.info(&format!(
1613 "Check compiletest suite={} mode={} ({} -> {})",
1614 suite, mode, &compiler.host, target
1616 let _time = util::timeit(&builder);
1617 try_run(builder, &mut cmd);
1619 if let Some(compare_mode) = compare_mode {
1620 cmd.arg("--compare-mode").arg(compare_mode);
1621 builder.info(&format!(
1622 "Check compiletest suite={} mode={} compare_mode={} ({} -> {})",
1623 suite, mode, compare_mode, &compiler.host, target
1625 let _time = util::timeit(&builder);
1626 try_run(builder, &mut cmd);
1631 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1639 impl Step for BookTest {
1641 const ONLY_HOSTS: bool = true;
1643 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1647 /// Runs the documentation tests for a book in `src/doc`.
1649 /// This uses the `rustdoc` that sits next to `compiler`.
1650 fn run(self, builder: &Builder<'_>) {
1651 // External docs are different from local because:
1652 // - Some books need pre-processing by mdbook before being tested.
1653 // - They need to save their state to toolstate.
1654 // - They are only tested on the "checktools" builders.
1656 // The local docs are tested by default, and we don't want to pay the
1657 // cost of building mdbook, so they use `rustdoc --test` directly.
1658 // Also, the unstable book is special because SUMMARY.md is generated,
1659 // so it is easier to just run `rustdoc` on its files.
1660 if self.is_ext_doc {
1661 self.run_ext_doc(builder);
1663 self.run_local_doc(builder);
1669 /// This runs the equivalent of `mdbook test` (via the rustbook wrapper)
1670 /// which in turn runs `rustdoc --test` on each file in the book.
1671 fn run_ext_doc(self, builder: &Builder<'_>) {
1672 let compiler = self.compiler;
1674 builder.ensure(compile::Std { compiler, target: compiler.host });
1676 // mdbook just executes a binary named "rustdoc", so we need to update
1677 // PATH so that it points to our rustdoc.
1678 let mut rustdoc_path = builder.rustdoc(compiler);
1680 let old_path = env::var_os("PATH").unwrap_or_default();
1681 let new_path = env::join_paths(iter::once(rustdoc_path).chain(env::split_paths(&old_path)))
1682 .expect("could not add rustdoc to PATH");
1684 let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
1685 let path = builder.src.join(&self.path);
1686 rustbook_cmd.env("PATH", new_path).arg("test").arg(path);
1687 builder.add_rust_test_threads(&mut rustbook_cmd);
1688 builder.info(&format!("Testing rustbook {}", self.path.display()));
1689 let _time = util::timeit(&builder);
1690 let toolstate = if try_run(builder, &mut rustbook_cmd) {
1695 builder.save_toolstate(self.name, toolstate);
1698 /// This runs `rustdoc --test` on all `.md` files in the path.
1699 fn run_local_doc(self, builder: &Builder<'_>) {
1700 let compiler = self.compiler;
1702 builder.ensure(compile::Std { compiler, target: compiler.host });
1704 // Do a breadth-first traversal of the `src/doc` directory and just run
1705 // tests for all files that end in `*.md`
1706 let mut stack = vec![builder.src.join(self.path)];
1707 let _time = util::timeit(&builder);
1708 let mut files = Vec::new();
1709 while let Some(p) = stack.pop() {
1711 stack.extend(t!(p.read_dir()).map(|p| t!(p).path()));
1715 if p.extension().and_then(|s| s.to_str()) != Some("md") {
1725 markdown_test(builder, compiler, &file);
1730 macro_rules! test_book {
1731 ($($name:ident, $path:expr, $book_name:expr, default=$default:expr;)+) => {
1733 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1738 impl Step for $name {
1740 const DEFAULT: bool = $default;
1741 const ONLY_HOSTS: bool = true;
1743 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1747 fn make_run(run: RunConfig<'_>) {
1748 run.builder.ensure($name {
1749 compiler: run.builder.compiler(run.builder.top_stage, run.target),
1753 fn run(self, builder: &Builder<'_>) {
1754 builder.ensure(BookTest {
1755 compiler: self.compiler,
1756 path: PathBuf::from($path),
1758 is_ext_doc: !$default,
1767 Nomicon, "src/doc/nomicon", "nomicon", default=false;
1768 Reference, "src/doc/reference", "reference", default=false;
1769 RustdocBook, "src/doc/rustdoc", "rustdoc", default=true;
1770 RustcBook, "src/doc/rustc", "rustc", default=true;
1771 RustByExample, "src/doc/rust-by-example", "rust-by-example", default=false;
1772 EmbeddedBook, "src/doc/embedded-book", "embedded-book", default=false;
1773 TheBook, "src/doc/book", "book", default=false;
1774 UnstableBook, "src/doc/unstable-book", "unstable-book", default=true;
1775 EditionGuide, "src/doc/edition-guide", "edition-guide", default=false;
1778 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1779 pub struct ErrorIndex {
1783 impl Step for ErrorIndex {
1785 const DEFAULT: bool = true;
1786 const ONLY_HOSTS: bool = true;
1788 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1789 run.path("src/tools/error_index_generator")
1792 fn make_run(run: RunConfig<'_>) {
1793 // error_index_generator depends on librustdoc. Use the compiler that
1794 // is normally used to build rustdoc for other tests (like compiletest
1795 // tests in src/test/rustdoc) so that it shares the same artifacts.
1796 let compiler = run.builder.compiler(run.builder.top_stage, run.builder.config.build);
1797 run.builder.ensure(ErrorIndex { compiler });
1800 /// Runs the error index generator tool to execute the tests located in the error
1803 /// The `error_index_generator` tool lives in `src/tools` and is used to
1804 /// generate a markdown file from the error indexes of the code base which is
1805 /// then passed to `rustdoc --test`.
1806 fn run(self, builder: &Builder<'_>) {
1807 let compiler = self.compiler;
1809 let dir = testdir(builder, compiler.host);
1810 t!(fs::create_dir_all(&dir));
1811 let output = dir.join("error-index.md");
1813 let mut tool = tool::ErrorIndex::command(builder);
1814 tool.arg("markdown").arg(&output);
1816 builder.info(&format!("Testing error-index stage{}", compiler.stage));
1817 let _time = util::timeit(&builder);
1818 builder.run_quiet(&mut tool);
1819 // The tests themselves need to link to std, so make sure it is
1821 builder.ensure(compile::Std { compiler, target: compiler.host });
1822 markdown_test(builder, compiler, &output);
1826 fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) -> bool {
1827 if let Ok(contents) = fs::read_to_string(markdown) {
1828 if !contents.contains("```") {
1833 builder.info(&format!("doc tests for: {}", markdown.display()));
1834 let mut cmd = builder.rustdoc_cmd(compiler);
1835 builder.add_rust_test_threads(&mut cmd);
1836 // allow for unstable options such as new editions
1838 cmd.arg("unstable-options");
1841 cmd.env("RUSTC_BOOTSTRAP", "1");
1843 let test_args = builder.config.cmd.test_args().join(" ");
1844 cmd.arg("--test-args").arg(test_args);
1846 if builder.config.verbose_tests {
1847 try_run(builder, &mut cmd)
1849 try_run_quiet(builder, &mut cmd)
1853 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1854 pub struct RustcGuide;
1856 impl Step for RustcGuide {
1858 const DEFAULT: bool = false;
1859 const ONLY_HOSTS: bool = true;
1861 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1862 run.path("src/doc/rustc-dev-guide")
1865 fn make_run(run: RunConfig<'_>) {
1866 run.builder.ensure(RustcGuide);
1869 fn run(self, builder: &Builder<'_>) {
1870 let relative_path = Path::new("src").join("doc").join("rustc-dev-guide");
1871 builder.update_submodule(&relative_path);
1873 let src = builder.src.join(relative_path);
1874 let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
1875 let toolstate = if try_run(builder, rustbook_cmd.arg("linkcheck").arg(&src)) {
1880 builder.save_toolstate("rustc-dev-guide", toolstate);
1884 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1885 pub struct CrateLibrustc {
1887 target: TargetSelection,
1888 test_kind: TestKind,
1889 krate: Interned<String>,
1892 impl Step for CrateLibrustc {
1894 const DEFAULT: bool = true;
1895 const ONLY_HOSTS: bool = true;
1897 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1898 run.krate("rustc-main")
1901 fn make_run(run: RunConfig<'_>) {
1902 let builder = run.builder;
1903 let compiler = builder.compiler(builder.top_stage, run.build_triple());
1905 for krate in builder.in_tree_crates("rustc-main", Some(run.target)) {
1906 if krate.path.ends_with(&run.path) {
1907 let test_kind = builder.kind.into();
1909 builder.ensure(CrateLibrustc {
1919 fn run(self, builder: &Builder<'_>) {
1920 builder.ensure(Crate {
1921 compiler: self.compiler,
1922 target: self.target,
1924 test_kind: self.test_kind,
1930 #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
1932 pub compiler: Compiler,
1933 pub target: TargetSelection,
1935 pub test_kind: TestKind,
1936 pub krate: Interned<String>,
1939 impl Step for Crate {
1941 const DEFAULT: bool = true;
1943 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1947 fn make_run(run: RunConfig<'_>) {
1948 let builder = run.builder;
1949 let compiler = builder.compiler(builder.top_stage, run.build_triple());
1951 let make = |mode: Mode, krate: &CargoCrate| {
1952 let test_kind = builder.kind.into();
1954 builder.ensure(Crate {
1963 for krate in builder.in_tree_crates("test", Some(run.target)) {
1964 if krate.path.ends_with(&run.path) {
1965 make(Mode::Std, krate);
1970 /// Runs all unit tests plus documentation tests for a given crate defined
1971 /// by a `Cargo.toml` (single manifest)
1973 /// This is what runs tests for crates like the standard library, compiler, etc.
1974 /// It essentially is the driver for running `cargo test`.
1976 /// Currently this runs all tests for a DAG by passing a bunch of `-p foo`
1977 /// arguments, and those arguments are discovered from `cargo metadata`.
1978 fn run(self, builder: &Builder<'_>) {
1979 let compiler = self.compiler;
1980 let target = self.target;
1981 let mode = self.mode;
1982 let test_kind = self.test_kind;
1983 let krate = self.krate;
1985 builder.ensure(compile::Std { compiler, target });
1986 builder.ensure(RemoteCopyLibs { compiler, target });
1988 // If we're not doing a full bootstrap but we're testing a stage2
1989 // version of libstd, then what we're actually testing is the libstd
1990 // produced in stage1. Reflect that here by updating the compiler that
1991 // we're working with automatically.
1992 let compiler = builder.compiler_for(compiler.stage, compiler.host, target);
1995 builder.cargo(compiler, mode, SourceType::InTree, target, test_kind.subcommand());
1998 compile::std_cargo(builder, target, compiler.stage, &mut cargo);
2001 compile::rustc_cargo(builder, &mut cargo, target);
2003 _ => panic!("can only test libraries"),
2006 // Build up the base `cargo test` command.
2008 // Pass in some standard flags then iterate over the graph we've discovered
2009 // in `cargo metadata` with the maps above and figure out what `-p`
2010 // arguments need to get passed.
2011 if test_kind.subcommand() == "test" && !builder.fail_fast {
2012 cargo.arg("--no-fail-fast");
2014 match builder.doc_tests {
2019 cargo.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]);
2024 cargo.arg("-p").arg(krate);
2026 // The tests are going to run with the *target* libraries, so we need to
2027 // ensure that those libraries show up in the LD_LIBRARY_PATH equivalent.
2029 // Note that to run the compiler we need to run with the *host* libraries,
2030 // but our wrapper scripts arrange for that to be the case anyway.
2031 let mut dylib_path = dylib_path();
2032 dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target)));
2033 cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
2036 cargo.args(&builder.config.cmd.test_args());
2038 if !builder.config.verbose_tests {
2039 cargo.arg("--quiet");
2042 if target.contains("emscripten") {
2044 format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)),
2045 builder.config.nodejs.as_ref().expect("nodejs not configured"),
2047 } else if target.starts_with("wasm32") {
2048 let node = builder.config.nodejs.as_ref().expect("nodejs not configured");
2050 format!("{} {}/src/etc/wasm32-shim.js", node.display(), builder.src.display());
2051 cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), &runner);
2052 } else if builder.remote_tested(target) {
2054 format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)),
2055 format!("{} run 0", builder.tool_exe(Tool::RemoteTestClient).display()),
2059 builder.info(&format!(
2060 "{} {} stage{} ({} -> {})",
2061 test_kind, krate, compiler.stage, &compiler.host, target
2063 let _time = util::timeit(&builder);
2064 try_run(builder, &mut cargo.into());
2068 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2069 pub struct CrateRustdoc {
2070 host: TargetSelection,
2071 test_kind: TestKind,
2074 impl Step for CrateRustdoc {
2076 const DEFAULT: bool = true;
2077 const ONLY_HOSTS: bool = true;
2079 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2080 run.paths(&["src/librustdoc", "src/tools/rustdoc"])
2083 fn make_run(run: RunConfig<'_>) {
2084 let builder = run.builder;
2086 let test_kind = builder.kind.into();
2088 builder.ensure(CrateRustdoc { host: run.target, test_kind });
2091 fn run(self, builder: &Builder<'_>) {
2092 let test_kind = self.test_kind;
2093 let target = self.host;
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);
2100 builder.ensure(compile::Rustc { compiler, target });
2102 let mut cargo = tool::prepare_tool_cargo(
2107 test_kind.subcommand(),
2108 "src/tools/rustdoc",
2112 if test_kind.subcommand() == "test" && !builder.fail_fast {
2113 cargo.arg("--no-fail-fast");
2116 cargo.arg("-p").arg("rustdoc:0.0.0");
2119 cargo.args(&builder.config.cmd.test_args());
2121 if self.host.contains("musl") {
2122 cargo.arg("'-Ctarget-feature=-crt-static'");
2125 // This is needed for running doctests on librustdoc. This is a bit of
2126 // an unfortunate interaction with how bootstrap works and how cargo
2127 // sets up the dylib path, and the fact that the doctest (in
2128 // html/markdown.rs) links to rustc-private libs. For stage1, the
2129 // compiler host dylibs (in stage1/lib) are not the same as the target
2130 // dylibs (in stage1/lib/rustlib/...). This is different from a normal
2131 // rust distribution where they are the same.
2133 // On the cargo side, normal tests use `target_process` which handles
2134 // setting up the dylib for a *target* (stage1/lib/rustlib/... in this
2135 // case). However, for doctests it uses `rustdoc_process` which only
2136 // sets up the dylib path for the *host* (stage1/lib), which is the
2139 // It should be considered to just stop running doctests on
2140 // librustdoc. There is only one test, and it doesn't look too
2141 // important. There might be other ways to avoid this, but it seems
2142 // pretty convoluted.
2144 // See also https://github.com/rust-lang/rust/issues/13983 where the
2145 // host vs target dylibs for rustdoc are consistently tricky to deal
2147 let mut dylib_path = dylib_path();
2148 dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target)));
2149 cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
2151 if !builder.config.verbose_tests {
2152 cargo.arg("--quiet");
2155 builder.info(&format!(
2156 "{} rustdoc stage{} ({} -> {})",
2157 test_kind, compiler.stage, &compiler.host, target
2159 let _time = util::timeit(&builder);
2161 try_run(builder, &mut cargo.into());
2165 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2166 pub struct CrateRustdocJsonTypes {
2167 host: TargetSelection,
2168 test_kind: TestKind,
2171 impl Step for CrateRustdocJsonTypes {
2173 const DEFAULT: bool = true;
2174 const ONLY_HOSTS: bool = true;
2176 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2177 run.path("src/rustdoc-json-types")
2180 fn make_run(run: RunConfig<'_>) {
2181 let builder = run.builder;
2183 let test_kind = builder.kind.into();
2185 builder.ensure(CrateRustdocJsonTypes { host: run.target, test_kind });
2188 fn run(self, builder: &Builder<'_>) {
2189 let test_kind = self.test_kind;
2190 let target = self.host;
2192 // Use the previous stage compiler to reuse the artifacts that are
2193 // created when running compiletest for src/test/rustdoc. If this used
2194 // `compiler`, then it would cause rustdoc to be built *again*, which
2195 // isn't really necessary.
2196 let compiler = builder.compiler_for(builder.top_stage, target, target);
2197 builder.ensure(compile::Rustc { compiler, target });
2199 let mut cargo = tool::prepare_tool_cargo(
2204 test_kind.subcommand(),
2205 "src/rustdoc-json-types",
2209 if test_kind.subcommand() == "test" && !builder.fail_fast {
2210 cargo.arg("--no-fail-fast");
2213 cargo.arg("-p").arg("rustdoc-json-types");
2216 cargo.args(&builder.config.cmd.test_args());
2218 if self.host.contains("musl") {
2219 cargo.arg("'-Ctarget-feature=-crt-static'");
2222 if !builder.config.verbose_tests {
2223 cargo.arg("--quiet");
2226 builder.info(&format!(
2227 "{} rustdoc-json-types stage{} ({} -> {})",
2228 test_kind, compiler.stage, &compiler.host, target
2230 let _time = util::timeit(&builder);
2232 try_run(builder, &mut cargo.into());
2236 /// Some test suites are run inside emulators or on remote devices, and most
2237 /// of our test binaries are linked dynamically which means we need to ship
2238 /// the standard library and such to the emulator ahead of time. This step
2239 /// represents this and is a dependency of all test suites.
2241 /// Most of the time this is a no-op. For some steps such as shipping data to
2242 /// QEMU we have to build our own tools so we've got conditional dependencies
2243 /// on those programs as well. Note that the remote test client is built for
2244 /// the build target (us) and the server is built for the target.
2245 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2246 pub struct RemoteCopyLibs {
2248 target: TargetSelection,
2251 impl Step for RemoteCopyLibs {
2254 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2258 fn run(self, builder: &Builder<'_>) {
2259 let compiler = self.compiler;
2260 let target = self.target;
2261 if !builder.remote_tested(target) {
2265 builder.ensure(compile::Std { compiler, target });
2267 builder.info(&format!("REMOTE copy libs to emulator ({})", target));
2268 t!(fs::create_dir_all(builder.out.join("tmp")));
2270 let server = builder.ensure(tool::RemoteTestServer { compiler, target });
2272 // Spawn the emulator and wait for it to come online
2273 let tool = builder.tool_exe(Tool::RemoteTestClient);
2274 let mut cmd = Command::new(&tool);
2275 cmd.arg("spawn-emulator").arg(target.triple).arg(&server).arg(builder.out.join("tmp"));
2276 if let Some(rootfs) = builder.qemu_rootfs(target) {
2279 builder.run(&mut cmd);
2281 // Push all our dylibs to the emulator
2282 for f in t!(builder.sysroot_libdir(compiler, target).read_dir()) {
2284 let name = f.file_name().into_string().unwrap();
2285 if util::is_dylib(&name) {
2286 builder.run(Command::new(&tool).arg("push").arg(f.path()));
2292 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2293 pub struct Distcheck;
2295 impl Step for Distcheck {
2298 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2299 run.path("distcheck")
2302 fn make_run(run: RunConfig<'_>) {
2303 run.builder.ensure(Distcheck);
2306 /// Runs "distcheck", a 'make check' from a tarball
2307 fn run(self, builder: &Builder<'_>) {
2308 builder.info("Distcheck");
2309 let dir = builder.out.join("tmp").join("distcheck");
2310 let _ = fs::remove_dir_all(&dir);
2311 t!(fs::create_dir_all(&dir));
2313 // Guarantee that these are built before we begin running.
2314 builder.ensure(dist::PlainSourceTarball);
2315 builder.ensure(dist::Src);
2317 let mut cmd = Command::new("tar");
2319 .arg(builder.ensure(dist::PlainSourceTarball).tarball())
2320 .arg("--strip-components=1")
2322 builder.run(&mut cmd);
2324 Command::new("./configure")
2325 .args(&builder.config.configure_args)
2326 .arg("--enable-vendor")
2330 Command::new(util::make(&builder.config.build.triple)).arg("check").current_dir(&dir),
2333 // Now make sure that rust-src has all of libstd's dependencies
2334 builder.info("Distcheck rust-src");
2335 let dir = builder.out.join("tmp").join("distcheck-src");
2336 let _ = fs::remove_dir_all(&dir);
2337 t!(fs::create_dir_all(&dir));
2339 let mut cmd = Command::new("tar");
2341 .arg(builder.ensure(dist::Src).tarball())
2342 .arg("--strip-components=1")
2344 builder.run(&mut cmd);
2346 let toml = dir.join("rust-src/lib/rustlib/src/rust/library/std/Cargo.toml");
2348 Command::new(&builder.initial_cargo)
2349 .arg("generate-lockfile")
2350 .arg("--manifest-path")
2357 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2358 pub struct Bootstrap;
2360 impl Step for Bootstrap {
2362 const DEFAULT: bool = true;
2363 const ONLY_HOSTS: bool = true;
2365 /// Tests the build system itself.
2366 fn run(self, builder: &Builder<'_>) {
2367 let mut cmd = Command::new(&builder.initial_cargo);
2369 .current_dir(builder.src.join("src/bootstrap"))
2370 .env("RUSTFLAGS", "-Cdebuginfo=2")
2371 .env("CARGO_TARGET_DIR", builder.out.join("bootstrap"))
2372 // HACK: bootstrap's tests want to know the output directory, but there's no way to set
2373 // it except through config.toml. Set it through an env variable instead.
2374 .env("BOOTSTRAP_OUTPUT_DIRECTORY", &builder.config.out)
2375 .env("BOOTSTRAP_INITIAL_CARGO", &builder.config.initial_cargo)
2376 .env("RUSTC_BOOTSTRAP", "1")
2377 .env("RUSTC", &builder.initial_rustc);
2378 if let Some(flags) = option_env!("RUSTFLAGS") {
2379 // Use the same rustc flags for testing as for "normal" compilation,
2380 // so that Cargo doesn’t recompile the entire dependency graph every time:
2381 // https://github.com/rust-lang/rust/issues/49215
2382 cmd.env("RUSTFLAGS", flags);
2384 if !builder.fail_fast {
2385 cmd.arg("--no-fail-fast");
2387 cmd.arg("--").args(&builder.config.cmd.test_args());
2388 // rustbuild tests are racy on directory creation so just run them one at a time.
2389 // Since there's not many this shouldn't be a problem.
2390 cmd.arg("--test-threads=1");
2391 try_run(builder, &mut cmd);
2394 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2395 run.path("src/bootstrap")
2398 fn make_run(run: RunConfig<'_>) {
2399 run.builder.ensure(Bootstrap);
2403 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2404 pub struct TierCheck {
2405 pub compiler: Compiler,
2408 impl Step for TierCheck {
2410 const DEFAULT: bool = true;
2411 const ONLY_HOSTS: bool = true;
2413 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2414 run.path("src/tools/tier-check")
2417 fn make_run(run: RunConfig<'_>) {
2419 run.builder.compiler_for(run.builder.top_stage, run.builder.build.build, run.target);
2420 run.builder.ensure(TierCheck { compiler });
2423 /// Tests the Platform Support page in the rustc book.
2424 fn run(self, builder: &Builder<'_>) {
2425 builder.ensure(compile::Std { compiler: self.compiler, target: self.compiler.host });
2426 let mut cargo = tool::prepare_tool_cargo(
2432 "src/tools/tier-check",
2436 cargo.arg(builder.src.join("src/doc/rustc/src/platform-support.md"));
2437 cargo.arg(&builder.rustc(self.compiler));
2438 if builder.is_verbose() {
2439 cargo.arg("--verbose");
2442 builder.info("platform support check");
2443 try_run(builder, &mut cargo.into());
2447 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2448 pub struct LintDocs {
2449 pub compiler: Compiler,
2450 pub target: TargetSelection,
2453 impl Step for LintDocs {
2455 const DEFAULT: bool = true;
2456 const ONLY_HOSTS: bool = true;
2458 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2459 run.path("src/tools/lint-docs")
2462 fn make_run(run: RunConfig<'_>) {
2463 run.builder.ensure(LintDocs {
2464 compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
2469 /// Tests that the lint examples in the rustc book generate the correct
2470 /// lints and have the expected format.
2471 fn run(self, builder: &Builder<'_>) {
2472 builder.ensure(crate::doc::RustcBook {
2473 compiler: self.compiler,
2474 target: self.target,