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 build_helper::{self, output, t};
16 use crate::builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
17 use crate::cache::Interned;
19 use crate::config::TargetSelection;
21 use crate::flags::Subcommand;
23 use crate::tool::{self, SourceType, Tool};
24 use crate::toolstate::ToolState;
25 use crate::util::{self, add_link_lib_path, dylib_path, dylib_path_var};
26 use crate::Crate as CargoCrate;
27 use crate::{envify, DocTests, GitRepo, Mode};
29 const ADB_TEST_DIR: &str = "/data/tmp/work";
31 /// The two modes of the test runner; tests or benchmarks.
32 #[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, PartialOrd, Ord)]
36 /// Run `cargo bench`.
40 impl From<Kind> for TestKind {
41 fn from(kind: Kind) -> Self {
43 Kind::Test => TestKind::Test,
44 Kind::Bench => TestKind::Bench,
45 _ => panic!("unexpected kind in crate: {:?}", kind),
51 // Return the cargo subcommand for this test kind
52 fn subcommand(self) -> &'static str {
54 TestKind::Test => "test",
55 TestKind::Bench => "bench",
60 impl fmt::Display for TestKind {
61 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
62 f.write_str(match *self {
63 TestKind::Test => "Testing",
64 TestKind::Bench => "Benchmarking",
69 fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool {
70 if !builder.fail_fast {
71 if !builder.try_run(cmd) {
72 let mut failures = builder.delayed_failures.borrow_mut();
73 failures.push(format!("{:?}", cmd));
82 fn try_run_quiet(builder: &Builder<'_>, cmd: &mut Command) -> bool {
83 if !builder.fail_fast {
84 if !builder.try_run_quiet(cmd) {
85 let mut failures = builder.delayed_failures.borrow_mut();
86 failures.push(format!("{:?}", cmd));
90 builder.run_quiet(cmd);
95 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
96 pub struct Linkcheck {
97 host: TargetSelection,
100 impl Step for Linkcheck {
102 const ONLY_HOSTS: bool = true;
103 const DEFAULT: bool = true;
105 /// Runs the `linkchecker` tool as compiled in `stage` by the `host` compiler.
107 /// This tool in `src/tools` will verify the validity of all our links in the
108 /// documentation to ensure we don't have a bunch of dead ones.
109 fn run(self, builder: &Builder<'_>) {
110 let host = self.host;
111 let hosts = &builder.hosts;
112 let targets = &builder.targets;
114 // if we have different hosts and targets, some things may be built for
115 // the host (e.g. rustc) and others for the target (e.g. std). The
116 // documentation built for each will contain broken links to
117 // docs built for the other platform (e.g. rustc linking to cargo)
118 if (hosts != targets) && !hosts.is_empty() && !targets.is_empty() {
120 "Linkcheck currently does not support builds with different hosts and targets.
121 You can skip linkcheck with --exclude src/tools/linkchecker"
125 builder.info(&format!("Linkcheck ({})", host));
127 // Test the linkchecker itself.
128 let bootstrap_host = builder.config.build;
129 let compiler = builder.compiler(0, bootstrap_host);
130 let cargo = tool::prepare_tool_cargo(
136 "src/tools/linkchecker",
140 try_run(builder, &mut cargo.into());
142 // Build all the default documentation.
143 builder.default_doc(&[]);
145 // Run the linkchecker.
146 let _time = util::timeit(&builder);
149 builder.tool_cmd(Tool::Linkchecker).arg(builder.out.join(host.triple).join("doc")),
153 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
154 let builder = run.builder;
155 let run = run.path("src/tools/linkchecker");
156 run.default_condition(builder.config.docs)
159 fn make_run(run: RunConfig<'_>) {
160 run.builder.ensure(Linkcheck { host: run.target });
164 fn check_if_tidy_is_installed() -> bool {
167 .stdout(Stdio::null())
169 .map_or(false, |status| status.success())
172 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
173 pub struct HtmlCheck {
174 target: TargetSelection,
177 impl Step for HtmlCheck {
179 const DEFAULT: bool = true;
180 const ONLY_HOSTS: bool = true;
182 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
183 let run = run.path("src/tools/html-checker");
184 run.lazy_default_condition(Box::new(check_if_tidy_is_installed))
187 fn make_run(run: RunConfig<'_>) {
188 run.builder.ensure(HtmlCheck { target: run.target });
191 fn run(self, builder: &Builder<'_>) {
192 if !check_if_tidy_is_installed() {
193 eprintln!("not running HTML-check tool because `tidy` is missing");
195 "Note that `tidy` is not the in-tree `src/tools/tidy` but needs to be installed"
197 panic!("Cannot run html-check tests");
199 // Ensure that a few different kinds of documentation are available.
200 builder.default_doc(&[]);
201 builder.ensure(crate::doc::Rustc { target: self.target, stage: builder.top_stage });
203 try_run(builder, builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target)));
207 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
208 pub struct Cargotest {
210 host: TargetSelection,
213 impl Step for Cargotest {
215 const ONLY_HOSTS: bool = true;
217 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
218 run.path("src/tools/cargotest")
221 fn make_run(run: RunConfig<'_>) {
222 run.builder.ensure(Cargotest { stage: run.builder.top_stage, host: run.target });
225 /// Runs the `cargotest` tool as compiled in `stage` by the `host` compiler.
227 /// This tool in `src/tools` will check out a few Rust projects and run `cargo
228 /// test` to ensure that we don't regress the test suites there.
229 fn run(self, builder: &Builder<'_>) {
230 let compiler = builder.compiler(self.stage, self.host);
231 builder.ensure(compile::Rustc { compiler, target: compiler.host });
232 let cargo = builder.ensure(tool::Cargo { compiler, target: compiler.host });
234 // Note that this is a short, cryptic, and not scoped directory name. This
235 // is currently to minimize the length of path on Windows where we otherwise
236 // quickly run into path name limit constraints.
237 let out_dir = builder.out.join("ct");
238 t!(fs::create_dir_all(&out_dir));
240 let _time = util::timeit(&builder);
241 let mut cmd = builder.tool_cmd(Tool::CargoTest);
246 .args(builder.config.cmd.test_args())
247 .env("RUSTC", builder.rustc(compiler))
248 .env("RUSTDOC", builder.rustdoc(compiler)),
253 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
256 host: TargetSelection,
259 impl Step for Cargo {
261 const ONLY_HOSTS: bool = true;
263 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
264 run.path("src/tools/cargo")
267 fn make_run(run: RunConfig<'_>) {
268 run.builder.ensure(Cargo { stage: run.builder.top_stage, host: run.target });
271 /// Runs `cargo test` for `cargo` packaged with Rust.
272 fn run(self, builder: &Builder<'_>) {
273 let compiler = builder.compiler(self.stage, self.host);
275 builder.ensure(tool::Cargo { compiler, target: self.host });
276 let mut cargo = tool::prepare_tool_cargo(
283 SourceType::Submodule,
287 if !builder.fail_fast {
288 cargo.arg("--no-fail-fast");
290 cargo.arg("--").args(builder.config.cmd.test_args());
292 // Don't run cross-compile tests, we may not have cross-compiled libstd libs
294 cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
295 // Disable a test that has issues with mingw.
296 cargo.env("CARGO_TEST_DISABLE_GIT_CLI", "1");
297 // Forcibly disable tests using nightly features since any changes to
298 // those features won't be able to land.
299 cargo.env("CARGO_TEST_DISABLE_NIGHTLY", "1");
301 cargo.env("PATH", &path_for_cargo(builder, compiler));
303 try_run(builder, &mut cargo.into());
307 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
310 host: TargetSelection,
315 const ONLY_HOSTS: bool = true;
317 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
318 run.path("src/tools/rls")
321 fn make_run(run: RunConfig<'_>) {
322 run.builder.ensure(Rls { stage: run.builder.top_stage, host: run.target });
325 /// Runs `cargo test` for the rls.
326 fn run(self, builder: &Builder<'_>) {
327 let stage = self.stage;
328 let host = self.host;
329 let compiler = builder.compiler(stage, host);
332 builder.ensure(tool::Rls { compiler, target: self.host, extra_features: Vec::new() });
333 if build_result.is_none() {
334 eprintln!("failed to test rls: could not build");
338 let mut cargo = tool::prepare_tool_cargo(
345 SourceType::Submodule,
349 cargo.add_rustc_lib_path(builder, compiler);
350 cargo.arg("--").args(builder.config.cmd.test_args());
352 if try_run(builder, &mut cargo.into()) {
353 builder.save_toolstate("rls", ToolState::TestPass);
358 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
361 host: TargetSelection,
364 impl Step for Rustfmt {
366 const ONLY_HOSTS: bool = true;
368 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
369 run.path("src/tools/rustfmt")
372 fn make_run(run: RunConfig<'_>) {
373 run.builder.ensure(Rustfmt { stage: run.builder.top_stage, host: run.target });
376 /// Runs `cargo test` for rustfmt.
377 fn run(self, builder: &Builder<'_>) {
378 let stage = self.stage;
379 let host = self.host;
380 let compiler = builder.compiler(stage, host);
383 .ensure(tool::Rustfmt { compiler, target: self.host, extra_features: Vec::new() })
384 .expect("in-tree tool");
386 let mut cargo = tool::prepare_tool_cargo(
393 SourceType::Submodule,
397 let dir = testdir(builder, compiler.host);
398 t!(fs::create_dir_all(&dir));
399 cargo.env("RUSTFMT_TEST_DIR", dir);
401 cargo.add_rustc_lib_path(builder, compiler);
403 builder.run(&mut cargo.into());
407 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
408 pub struct RustDemangler {
410 host: TargetSelection,
413 impl Step for RustDemangler {
415 const ONLY_HOSTS: bool = true;
417 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
418 run.path("src/tools/rust-demangler")
421 fn make_run(run: RunConfig<'_>) {
422 run.builder.ensure(RustDemangler { stage: run.builder.top_stage, host: run.target });
425 /// Runs `cargo test` for rust-demangler.
426 fn run(self, builder: &Builder<'_>) {
427 let stage = self.stage;
428 let host = self.host;
429 let compiler = builder.compiler(stage, host);
431 let rust_demangler = builder
432 .ensure(tool::RustDemangler { compiler, target: self.host, extra_features: Vec::new() })
433 .expect("in-tree tool");
434 let mut cargo = tool::prepare_tool_cargo(
440 "src/tools/rust-demangler",
445 let dir = testdir(builder, compiler.host);
446 t!(fs::create_dir_all(&dir));
448 cargo.env("RUST_DEMANGLER_DRIVER_PATH", rust_demangler);
450 cargo.arg("--").args(builder.config.cmd.test_args());
452 cargo.add_rustc_lib_path(builder, compiler);
454 builder.run(&mut cargo.into());
458 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
461 host: TargetSelection,
466 const ONLY_HOSTS: bool = true;
468 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
469 run.path("src/tools/miri")
472 fn make_run(run: RunConfig<'_>) {
473 run.builder.ensure(Miri { stage: run.builder.top_stage, host: run.target });
476 /// Runs `cargo test` for miri.
477 fn run(self, builder: &Builder<'_>) {
478 let stage = self.stage;
479 let host = self.host;
480 let compiler = builder.compiler(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 if let (Some(miri), Some(_cargo_miri)) = (miri, cargo_miri) {
491 builder.cargo(compiler, Mode::ToolRustc, SourceType::Submodule, host, "install");
493 // Configure `cargo install` path. cargo adds a `bin/`.
494 cargo.env("CARGO_INSTALL_ROOT", &builder.out);
496 let mut cargo = Command::from(cargo);
497 if !try_run(builder, &mut cargo) {
501 // # Run `cargo miri setup`.
502 let mut cargo = tool::prepare_tool_cargo(
508 "src/tools/miri/cargo-miri",
509 SourceType::Submodule,
512 cargo.add_rustc_lib_path(builder, compiler);
513 cargo.arg("--").arg("miri").arg("setup");
515 // Tell `cargo miri setup` where to find the sources.
516 cargo.env("XARGO_RUST_SRC", builder.src.join("library"));
517 // Tell it where to find Miri.
518 cargo.env("MIRI", &miri);
520 cargo.env("RUST_BACKTRACE", "1");
521 // Let cargo-miri know where xargo ended up.
522 cargo.env("XARGO_CHECK", builder.out.join("bin").join("xargo-check"));
524 let mut cargo = Command::from(cargo);
525 if !try_run(builder, &mut cargo) {
529 // # Determine where Miri put its sysroot.
530 // To this end, we run `cargo miri setup --print-sysroot` and capture the output.
531 // (We do this separately from the above so that when the setup actually
532 // happens we get some output.)
533 // We re-use the `cargo` from above.
534 cargo.arg("--print-sysroot");
536 // FIXME: Is there a way in which we can re-use the usual `run` helpers?
537 let miri_sysroot = if builder.config.dry_run {
540 builder.verbose(&format!("running: {:?}", cargo));
543 .expect("We already ran `cargo miri setup` before and that worked");
544 assert!(out.status.success(), "`cargo miri setup` returned with non-0 exit code");
545 // Output is "<sysroot>\n".
546 let stdout = String::from_utf8(out.stdout)
547 .expect("`cargo miri setup` stdout is not valid UTF-8");
548 let sysroot = stdout.trim_end();
549 builder.verbose(&format!("`cargo miri setup --print-sysroot` said: {:?}", sysroot));
553 // # Run `cargo test`.
554 let mut cargo = tool::prepare_tool_cargo(
561 SourceType::Submodule,
564 cargo.add_rustc_lib_path(builder, compiler);
566 // miri tests need to know about the stage sysroot
567 cargo.env("MIRI_SYSROOT", miri_sysroot);
568 cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
569 cargo.env("MIRI", miri);
571 cargo.arg("--").args(builder.config.cmd.test_args());
573 let mut cargo = Command::from(cargo);
574 if !try_run(builder, &mut cargo) {
578 // # Run `cargo test` with `-Zmir-opt-level=4`.
579 cargo.env("MIRIFLAGS", "-O -Zmir-opt-level=4");
580 if !try_run(builder, &mut cargo) {
585 builder.save_toolstate("miri", ToolState::TestPass);
587 eprintln!("failed to test miri: could not build");
592 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
593 pub struct CompiletestTest {
594 host: TargetSelection,
597 impl Step for CompiletestTest {
600 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
601 run.path("src/tools/compiletest")
604 fn make_run(run: RunConfig<'_>) {
605 run.builder.ensure(CompiletestTest { host: run.target });
608 /// Runs `cargo test` for compiletest.
609 fn run(self, builder: &Builder<'_>) {
610 let host = self.host;
611 let compiler = builder.compiler(0, host);
613 // We need `ToolStd` for the locally-built sysroot because
614 // compiletest uses unstable features of the `test` crate.
615 builder.ensure(compile::Std { compiler, target: host });
616 let cargo = tool::prepare_tool_cargo(
622 "src/tools/compiletest",
627 try_run(builder, &mut cargo.into());
631 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
634 host: TargetSelection,
637 impl Step for Clippy {
639 const ONLY_HOSTS: bool = true;
640 const DEFAULT: bool = false;
642 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
643 run.path("src/tools/clippy")
646 fn make_run(run: RunConfig<'_>) {
647 run.builder.ensure(Clippy { stage: run.builder.top_stage, host: run.target });
650 /// Runs `cargo test` for clippy.
651 fn run(self, builder: &Builder<'_>) {
652 let stage = self.stage;
653 let host = self.host;
654 let compiler = builder.compiler(stage, host);
657 .ensure(tool::Clippy { compiler, target: self.host, extra_features: Vec::new() })
658 .expect("in-tree tool");
659 let mut cargo = tool::prepare_tool_cargo(
670 // clippy tests need to know about the stage sysroot
671 cargo.env("SYSROOT", builder.sysroot(compiler));
672 cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
673 cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
674 let host_libs = builder.stage_out(compiler, Mode::ToolRustc).join(builder.cargo_dir());
675 let target_libs = builder
676 .stage_out(compiler, Mode::ToolRustc)
677 .join(&self.host.triple)
678 .join(builder.cargo_dir());
679 cargo.env("HOST_LIBS", host_libs);
680 cargo.env("TARGET_LIBS", target_libs);
681 // clippy tests need to find the driver
682 cargo.env("CLIPPY_DRIVER_PATH", clippy);
684 cargo.arg("--").args(builder.config.cmd.test_args());
686 cargo.add_rustc_lib_path(builder, compiler);
688 if builder.try_run(&mut cargo.into()) {
689 // The tests succeeded; nothing to do.
693 if !builder.config.cmd.bless() {
694 std::process::exit(1);
697 let mut cargo = builder.cargo(compiler, Mode::ToolRustc, SourceType::InTree, host, "run");
698 cargo.arg("-p").arg("clippy_dev");
699 // clippy_dev gets confused if it can't find `clippy/Cargo.toml`
700 cargo.current_dir(&builder.src.join("src").join("tools").join("clippy"));
701 if builder.config.rust_optimize {
702 cargo.env("PROFILE", "release");
704 cargo.env("PROFILE", "debug");
708 builder.run(&mut cargo.into());
712 fn path_for_cargo(builder: &Builder<'_>, compiler: Compiler) -> OsString {
713 // Configure PATH to find the right rustc. NB. we have to use PATH
714 // and not RUSTC because the Cargo test suite has tests that will
715 // fail if rustc is not spelled `rustc`.
716 let path = builder.sysroot(compiler).join("bin");
717 let old_path = env::var_os("PATH").unwrap_or_default();
718 env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("")
721 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
722 pub struct RustdocTheme {
723 pub compiler: Compiler,
726 impl Step for RustdocTheme {
728 const DEFAULT: bool = true;
729 const ONLY_HOSTS: bool = true;
731 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
732 run.path("src/tools/rustdoc-themes")
735 fn make_run(run: RunConfig<'_>) {
736 let compiler = run.builder.compiler(run.builder.top_stage, run.target);
738 run.builder.ensure(RustdocTheme { compiler });
741 fn run(self, builder: &Builder<'_>) {
742 let rustdoc = builder.out.join("bootstrap/debug/rustdoc");
743 let mut cmd = builder.tool_cmd(Tool::RustdocTheme);
744 cmd.arg(rustdoc.to_str().unwrap())
745 .arg(builder.src.join("src/librustdoc/html/static/css/themes").to_str().unwrap())
746 .env("RUSTC_STAGE", self.compiler.stage.to_string())
747 .env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
748 .env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host))
749 .env("CFG_RELEASE_CHANNEL", &builder.config.channel)
750 .env("RUSTDOC_REAL", builder.rustdoc(self.compiler))
751 .env("RUSTC_BOOTSTRAP", "1");
752 if let Some(linker) = builder.linker(self.compiler.host) {
753 cmd.env("RUSTDOC_LINKER", linker);
755 if builder.is_fuse_ld_lld(self.compiler.host) {
756 cmd.env("RUSTDOC_FUSE_LD_LLD", "1");
758 try_run(builder, &mut cmd);
762 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
763 pub struct RustdocJSStd {
764 pub target: TargetSelection,
767 impl Step for RustdocJSStd {
769 const DEFAULT: bool = true;
770 const ONLY_HOSTS: bool = true;
772 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
773 run.path("src/test/rustdoc-js-std")
776 fn make_run(run: RunConfig<'_>) {
777 run.builder.ensure(RustdocJSStd { target: run.target });
780 fn run(self, builder: &Builder<'_>) {
781 if let Some(ref nodejs) = builder.config.nodejs {
782 let mut command = Command::new(nodejs);
784 .arg(builder.src.join("src/tools/rustdoc-js/tester.js"))
787 .arg("--resource-suffix")
788 .arg(&builder.version)
790 .arg(builder.doc_out(self.target))
791 .arg("--test-folder")
792 .arg(builder.src.join("src/test/rustdoc-js-std"));
793 builder.ensure(crate::doc::Std { target: self.target, stage: builder.top_stage });
794 builder.run(&mut command);
796 builder.info("No nodejs found, skipping \"src/test/rustdoc-js-std\" tests");
801 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
802 pub struct RustdocJSNotStd {
803 pub target: TargetSelection,
804 pub compiler: Compiler,
807 impl Step for RustdocJSNotStd {
809 const DEFAULT: bool = true;
810 const ONLY_HOSTS: bool = true;
812 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
813 run.path("src/test/rustdoc-js")
816 fn make_run(run: RunConfig<'_>) {
817 let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
818 run.builder.ensure(RustdocJSNotStd { target: run.target, compiler });
821 fn run(self, builder: &Builder<'_>) {
822 if builder.config.nodejs.is_some() {
823 builder.ensure(Compiletest {
824 compiler: self.compiler,
828 path: "src/test/rustdoc-js",
832 builder.info("No nodejs found, skipping \"src/test/rustdoc-js\" tests");
837 fn check_if_browser_ui_test_is_installed_global(npm: &Path, global: bool) -> bool {
838 let mut command = Command::new(&npm);
839 command.arg("list").arg("--depth=0");
841 command.arg("--global");
845 .map(|output| String::from_utf8_lossy(&output.stdout).into_owned())
846 .unwrap_or(String::new());
847 lines.contains(&" browser-ui-test@")
850 fn check_if_browser_ui_test_is_installed(npm: &Path) -> bool {
851 check_if_browser_ui_test_is_installed_global(npm, false)
852 || check_if_browser_ui_test_is_installed_global(npm, true)
855 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
856 pub struct RustdocGUI {
857 pub target: TargetSelection,
858 pub compiler: Compiler,
861 impl Step for RustdocGUI {
863 const DEFAULT: bool = true;
864 const ONLY_HOSTS: bool = true;
866 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
867 let builder = run.builder;
868 let run = run.suite_path("src/test/rustdoc-gui");
869 run.lazy_default_condition(Box::new(move || {
870 builder.config.nodejs.is_some()
875 .map(|p| check_if_browser_ui_test_is_installed(p))
880 fn make_run(run: RunConfig<'_>) {
881 let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
882 run.builder.ensure(RustdocGUI { target: run.target, compiler });
885 fn run(self, builder: &Builder<'_>) {
886 let nodejs = builder.config.nodejs.as_ref().expect("nodejs isn't available");
887 let npm = builder.config.npm.as_ref().expect("npm isn't available");
889 builder.ensure(compile::Std { compiler: self.compiler, target: self.target });
891 // The goal here is to check if the necessary packages are installed, and if not, we
893 if !check_if_browser_ui_test_is_installed(&npm) {
895 "error: rustdoc-gui test suite cannot be run because npm `browser-ui-test` \
896 dependency is missing",
899 "If you want to install the `{0}` dependency, run `npm install {0}`",
902 panic!("Cannot run rustdoc-gui tests");
905 let out_dir = builder.test_out(self.target).join("rustdoc-gui");
907 // We remove existing folder to be sure there won't be artifacts remaining.
908 let _ = fs::remove_dir_all(&out_dir);
910 let mut nb_generated = 0;
911 // We generate docs for the libraries present in the rustdoc-gui's src folder.
912 let libs_dir = builder.build.src.join("src/test/rustdoc-gui/src");
913 for entry in libs_dir.read_dir().expect("read_dir call failed") {
914 let entry = entry.expect("invalid entry");
915 let path = entry.path();
916 if path.extension().map(|e| e == "rs").unwrap_or(false) {
917 let mut command = builder.rustdoc_cmd(self.compiler);
918 command.arg(path).arg("-o").arg(&out_dir);
919 builder.run(&mut command);
923 assert!(nb_generated > 0, "no documentation was generated...");
925 // We now run GUI tests.
926 let mut command = Command::new(&nodejs);
928 .arg(builder.build.src.join("src/tools/rustdoc-gui/tester.js"))
931 .arg("--tests-folder")
932 .arg(builder.build.src.join("src/test/rustdoc-gui"));
933 for path in &builder.paths {
934 if let Some(name) = path.file_name().and_then(|f| f.to_str()) {
935 if name.ends_with(".goml") {
936 command.arg("--file").arg(name);
940 for test_arg in builder.config.cmd.test_args() {
941 command.arg(test_arg);
943 builder.run(&mut command);
947 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
952 const DEFAULT: bool = true;
953 const ONLY_HOSTS: bool = true;
955 /// Runs the `tidy` tool.
957 /// This tool in `src/tools` checks up on various bits and pieces of style and
958 /// otherwise just implements a few lint-like checks that are specific to the
961 /// Once tidy passes, this step also runs `fmt --check` if tests are being run
962 /// for the `dev` or `nightly` channels.
963 fn run(self, builder: &Builder<'_>) {
964 let mut cmd = builder.tool_cmd(Tool::Tidy);
965 cmd.arg(&builder.src);
966 cmd.arg(&builder.initial_cargo);
967 cmd.arg(&builder.out);
968 cmd.arg(builder.jobs().to_string());
969 if builder.is_verbose() {
970 cmd.arg("--verbose");
973 builder.info("tidy check");
974 try_run(builder, &mut cmd);
976 if builder.config.channel == "dev" || builder.config.channel == "nightly" {
977 builder.info("fmt check");
978 if builder.config.initial_rustfmt.is_none() {
979 let inferred_rustfmt_dir = builder.config.initial_rustc.parent().unwrap();
982 error: no `rustfmt` binary found in {PATH}
983 info: `rust.channel` is currently set to \"{CHAN}\"
984 help: if you are testing a beta branch, set `rust.channel` to \"beta\" in the `config.toml` file
985 help: to skip test's attempt to check tidiness, pass `--exclude src/tools/tidy` to `x.py test`",
986 PATH = inferred_rustfmt_dir.display(),
987 CHAN = builder.config.channel,
989 std::process::exit(1);
991 crate::format::format(&builder.build, !builder.config.cmd.bless(), &[]);
995 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
996 run.path("src/tools/tidy")
999 fn make_run(run: RunConfig<'_>) {
1000 run.builder.ensure(Tidy);
1004 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1005 pub struct ExpandYamlAnchors;
1007 impl Step for ExpandYamlAnchors {
1009 const ONLY_HOSTS: bool = true;
1011 /// Ensure the `generate-ci-config` tool was run locally.
1013 /// The tool in `src/tools` reads the CI definition in `src/ci/builders.yml` and generates the
1014 /// appropriate configuration for all our CI providers. This step ensures the tool was called
1015 /// by the user before committing CI changes.
1016 fn run(self, builder: &Builder<'_>) {
1017 builder.info("Ensuring the YAML anchors in the GitHub Actions config were expanded");
1020 &mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("check").arg(&builder.src),
1024 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1025 run.path("src/tools/expand-yaml-anchors")
1028 fn make_run(run: RunConfig<'_>) {
1029 run.builder.ensure(ExpandYamlAnchors);
1033 fn testdir(builder: &Builder<'_>, host: TargetSelection) -> PathBuf {
1034 builder.out.join(host.triple).join("test")
1037 macro_rules! default_test {
1038 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr }) => {
1039 test!($name { path: $path, mode: $mode, suite: $suite, default: true, host: false });
1043 macro_rules! default_test_with_compare_mode {
1044 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr,
1045 compare_mode: $compare_mode:expr }) => {
1046 test_with_compare_mode!($name {
1052 compare_mode: $compare_mode
1057 macro_rules! host_test {
1058 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr }) => {
1059 test!($name { path: $path, mode: $mode, suite: $suite, default: true, host: true });
1064 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr, default: $default:expr,
1065 host: $host:expr }) => {
1066 test_definitions!($name {
1077 macro_rules! test_with_compare_mode {
1078 ($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr, default: $default:expr,
1079 host: $host:expr, compare_mode: $compare_mode:expr }) => {
1080 test_definitions!($name {
1086 compare_mode: Some($compare_mode)
1091 macro_rules! test_definitions {
1096 default: $default:expr,
1098 compare_mode: $compare_mode:expr
1100 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1102 pub compiler: Compiler,
1103 pub target: TargetSelection,
1106 impl Step for $name {
1108 const DEFAULT: bool = $default;
1109 const ONLY_HOSTS: bool = $host;
1111 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1112 run.suite_path($path)
1115 fn make_run(run: RunConfig<'_>) {
1116 let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
1118 run.builder.ensure($name { compiler, target: run.target });
1121 fn run(self, builder: &Builder<'_>) {
1122 builder.ensure(Compiletest {
1123 compiler: self.compiler,
1124 target: self.target,
1128 compare_mode: $compare_mode,
1135 default_test_with_compare_mode!(Ui {
1136 path: "src/test/ui",
1142 default_test!(RunPassValgrind {
1143 path: "src/test/run-pass-valgrind",
1144 mode: "run-pass-valgrind",
1145 suite: "run-pass-valgrind"
1148 default_test!(MirOpt { path: "src/test/mir-opt", mode: "mir-opt", suite: "mir-opt" });
1150 default_test!(Codegen { path: "src/test/codegen", mode: "codegen", suite: "codegen" });
1152 default_test!(CodegenUnits {
1153 path: "src/test/codegen-units",
1154 mode: "codegen-units",
1155 suite: "codegen-units"
1158 default_test!(Incremental {
1159 path: "src/test/incremental",
1160 mode: "incremental",
1161 suite: "incremental"
1164 default_test_with_compare_mode!(Debuginfo {
1165 path: "src/test/debuginfo",
1168 compare_mode: "split-dwarf"
1171 host_test!(UiFullDeps { path: "src/test/ui-fulldeps", mode: "ui", suite: "ui-fulldeps" });
1173 host_test!(Rustdoc { path: "src/test/rustdoc", mode: "rustdoc", suite: "rustdoc" });
1174 host_test!(RustdocUi { path: "src/test/rustdoc-ui", mode: "ui", suite: "rustdoc-ui" });
1176 host_test!(RustdocJson {
1177 path: "src/test/rustdoc-json",
1178 mode: "rustdoc-json",
1179 suite: "rustdoc-json"
1182 host_test!(Pretty { path: "src/test/pretty", mode: "pretty", suite: "pretty" });
1184 default_test!(RunMake { path: "src/test/run-make", mode: "run-make", suite: "run-make" });
1186 host_test!(RunMakeFullDeps {
1187 path: "src/test/run-make-fulldeps",
1189 suite: "run-make-fulldeps"
1192 default_test!(Assembly { path: "src/test/assembly", mode: "assembly", suite: "assembly" });
1194 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1195 struct Compiletest {
1197 target: TargetSelection,
1199 suite: &'static str,
1201 compare_mode: Option<&'static str>,
1204 impl Step for Compiletest {
1207 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1211 /// Executes the `compiletest` tool to run a suite of tests.
1213 /// Compiles all tests with `compiler` for `target` with the specified
1214 /// compiletest `mode` and `suite` arguments. For example `mode` can be
1215 /// "run-pass" or `suite` can be something like `debuginfo`.
1216 fn run(self, builder: &Builder<'_>) {
1217 if builder.top_stage == 0 && env::var("COMPILETEST_FORCE_STAGE0").is_err() {
1219 error: `--stage 0` runs compiletest on the beta compiler, not your local changes, and will almost always cause tests to fail
1220 help: to test the compiler, use `--stage 1` instead
1221 help: to test the standard library, use `--stage 0 library/std` instead
1222 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`."
1224 std::process::exit(1);
1227 let compiler = self.compiler;
1228 let target = self.target;
1229 let mode = self.mode;
1230 let suite = self.suite;
1232 // Path for test suite
1233 let suite_path = self.path;
1235 // Skip codegen tests if they aren't enabled in configuration.
1236 if !builder.config.codegen_tests && suite == "codegen" {
1240 if suite == "debuginfo" {
1242 .ensure(dist::DebuggerScripts { sysroot: builder.sysroot(compiler), host: target });
1245 if suite.ends_with("fulldeps") {
1246 builder.ensure(compile::Rustc { compiler, target });
1249 builder.ensure(compile::Std { compiler, target });
1250 // ensure that `libproc_macro` is available on the host.
1251 builder.ensure(compile::Std { compiler, target: compiler.host });
1253 // Also provide `rust_test_helpers` for the host.
1254 builder.ensure(native::TestHelpers { target: compiler.host });
1256 // As well as the target, except for plain wasm32, which can't build it
1257 if !target.contains("wasm32") || target.contains("emscripten") {
1258 builder.ensure(native::TestHelpers { target });
1261 builder.ensure(RemoteCopyLibs { compiler, target });
1263 let mut cmd = builder.tool_cmd(Tool::Compiletest);
1265 // compiletest currently has... a lot of arguments, so let's just pass all
1268 cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler));
1269 cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target));
1270 cmd.arg("--rustc-path").arg(builder.rustc(compiler));
1272 let is_rustdoc = suite.ends_with("rustdoc-ui") || suite.ends_with("rustdoc-js");
1274 // Avoid depending on rustdoc when we don't need it.
1275 if mode == "rustdoc"
1276 || mode == "run-make"
1277 || (mode == "ui" && is_rustdoc)
1278 || mode == "js-doc-test"
1279 || mode == "rustdoc-json"
1281 cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler));
1284 if mode == "rustdoc-json" {
1285 // Use the beta compiler for jsondocck
1286 let json_compiler = compiler.with_stage(0);
1287 cmd.arg("--jsondocck-path")
1288 .arg(builder.ensure(tool::JsonDocCk { compiler: json_compiler, target }));
1291 if mode == "run-make" && suite.ends_with("fulldeps") {
1292 let rust_demangler = builder
1293 .ensure(tool::RustDemangler { compiler, target, extra_features: Vec::new() })
1294 .expect("in-tree tool");
1295 cmd.arg("--rust-demangler-path").arg(rust_demangler);
1298 cmd.arg("--src-base").arg(builder.src.join("src/test").join(suite));
1299 cmd.arg("--build-base").arg(testdir(builder, compiler.host).join(suite));
1300 cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
1301 cmd.arg("--suite").arg(suite);
1302 cmd.arg("--mode").arg(mode);
1303 cmd.arg("--target").arg(target.rustc_target_arg());
1304 cmd.arg("--host").arg(&*compiler.host.triple);
1305 cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.build));
1307 if builder.config.cmd.bless() {
1312 builder.config.cmd.compare_mode().or_else(|| {
1313 if builder.config.test_compare_mode { self.compare_mode } else { None }
1316 if let Some(ref pass) = builder.config.cmd.pass() {
1321 if let Some(ref run) = builder.config.cmd.run() {
1326 if let Some(ref nodejs) = builder.config.nodejs {
1327 cmd.arg("--nodejs").arg(nodejs);
1329 if let Some(ref npm) = builder.config.npm {
1330 cmd.arg("--npm").arg(npm);
1333 let mut flags = if is_rustdoc { Vec::new() } else { vec!["-Crpath".to_string()] };
1335 if builder.config.rust_optimize_tests {
1336 flags.push("-O".to_string());
1339 flags.push(format!("-Cdebuginfo={}", builder.config.rust_debuginfo_level_tests));
1340 flags.push(builder.config.cmd.rustc_args().join(" "));
1342 if let Some(linker) = builder.linker(target) {
1343 cmd.arg("--linker").arg(linker);
1346 let mut hostflags = flags.clone();
1347 hostflags.push(format!("-Lnative={}", builder.test_helpers_out(compiler.host).display()));
1348 hostflags.extend(builder.lld_flags(compiler.host));
1349 cmd.arg("--host-rustcflags").arg(hostflags.join(" "));
1351 let mut targetflags = flags;
1352 targetflags.push(format!("-Lnative={}", builder.test_helpers_out(target).display()));
1353 targetflags.extend(builder.lld_flags(target));
1354 cmd.arg("--target-rustcflags").arg(targetflags.join(" "));
1356 cmd.arg("--docck-python").arg(builder.python());
1358 if builder.config.build.ends_with("apple-darwin") {
1359 // Force /usr/bin/python3 on macOS for LLDB tests because we're loading the
1360 // LLDB plugin's compiled module which only works with the system python
1361 // (namely not Homebrew-installed python)
1362 cmd.arg("--lldb-python").arg("/usr/bin/python3");
1364 cmd.arg("--lldb-python").arg(builder.python());
1367 if let Some(ref gdb) = builder.config.gdb {
1368 cmd.arg("--gdb").arg(gdb);
1371 let run = |cmd: &mut Command| {
1372 cmd.output().map(|output| {
1373 String::from_utf8_lossy(&output.stdout)
1376 .unwrap_or_else(|| panic!("{:?} failed {:?}", cmd, output))
1380 let lldb_exe = "lldb";
1381 let lldb_version = Command::new(lldb_exe)
1384 .map(|output| String::from_utf8_lossy(&output.stdout).to_string())
1386 if let Some(ref vers) = lldb_version {
1387 cmd.arg("--lldb-version").arg(vers);
1388 let lldb_python_dir = run(Command::new(lldb_exe).arg("-P")).ok();
1389 if let Some(ref dir) = lldb_python_dir {
1390 cmd.arg("--lldb-python-dir").arg(dir);
1394 if util::forcing_clang_based_tests() {
1395 let clang_exe = builder.llvm_out(target).join("bin").join("clang");
1396 cmd.arg("--run-clang-based-tests-with").arg(clang_exe);
1399 // Get paths from cmd args
1400 let paths = match &builder.config.cmd {
1401 Subcommand::Test { ref paths, .. } => &paths[..],
1405 // Get test-args by striping suite path
1406 let mut test_args: Vec<&str> = paths
1408 .map(|p| match p.strip_prefix(".") {
1412 .filter(|p| p.starts_with(suite_path))
1414 let exists = p.is_dir() || p.is_file();
1416 if let Some(p) = p.to_str() {
1417 builder.info(&format!(
1418 "Warning: Skipping \"{}\": not a regular file or directory",
1426 // Since test suite paths are themselves directories, if we don't
1427 // specify a directory or file, we'll get an empty string here
1428 // (the result of the test suite directory without its suite prefix).
1429 // Therefore, we need to filter these out, as only the first --test-args
1430 // flag is respected, so providing an empty --test-args conflicts with
1431 // any following it.
1432 match p.strip_prefix(suite_path).ok().and_then(|p| p.to_str()) {
1433 Some(s) if !s.is_empty() => Some(s),
1439 test_args.append(&mut builder.config.cmd.test_args());
1441 cmd.args(&test_args);
1443 if builder.is_verbose() {
1444 cmd.arg("--verbose");
1447 if !builder.config.verbose_tests {
1451 let mut llvm_components_passed = false;
1452 let mut copts_passed = false;
1453 if builder.config.llvm_enabled() {
1454 let llvm_config = builder.ensure(native::Llvm { target: builder.config.build });
1455 if !builder.config.dry_run {
1456 let llvm_version = output(Command::new(&llvm_config).arg("--version"));
1457 let llvm_components = output(Command::new(&llvm_config).arg("--components"));
1458 // Remove trailing newline from llvm-config output.
1459 cmd.arg("--llvm-version")
1460 .arg(llvm_version.trim())
1461 .arg("--llvm-components")
1462 .arg(llvm_components.trim());
1463 llvm_components_passed = true;
1465 if !builder.is_rust_llvm(target) {
1466 cmd.arg("--system-llvm");
1469 // Tests that use compiler libraries may inherit the `-lLLVM` link
1470 // requirement, but the `-L` library path is not propagated across
1471 // separate compilations. We can add LLVM's library path to the
1472 // platform-specific environment variable as a workaround.
1473 if !builder.config.dry_run && suite.ends_with("fulldeps") {
1474 let llvm_libdir = output(Command::new(&llvm_config).arg("--libdir"));
1475 add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cmd);
1478 // Only pass correct values for these flags for the `run-make` suite as it
1479 // requires that a C++ compiler was configured which isn't always the case.
1480 if !builder.config.dry_run && matches!(suite, "run-make" | "run-make-fulldeps") {
1481 // The llvm/bin directory contains many useful cross-platform
1482 // tools. Pass the path to run-make tests so they can use them.
1483 let llvm_bin_path = llvm_config
1485 .expect("Expected llvm-config to be contained in directory");
1486 assert!(llvm_bin_path.is_dir());
1487 cmd.arg("--llvm-bin-dir").arg(llvm_bin_path);
1489 // If LLD is available, add it to the PATH
1490 if builder.config.lld_enabled {
1491 let lld_install_root =
1492 builder.ensure(native::Lld { target: builder.config.build });
1494 let lld_bin_path = lld_install_root.join("bin");
1496 let old_path = env::var_os("PATH").unwrap_or_default();
1497 let new_path = env::join_paths(
1498 std::iter::once(lld_bin_path).chain(env::split_paths(&old_path)),
1500 .expect("Could not add LLD bin path to PATH");
1501 cmd.env("PATH", new_path);
1506 // Only pass correct values for these flags for the `run-make` suite as it
1507 // requires that a C++ compiler was configured which isn't always the case.
1508 if !builder.config.dry_run && matches!(suite, "run-make" | "run-make-fulldeps") {
1510 .arg(builder.cc(target))
1512 .arg(builder.cxx(target).unwrap())
1514 .arg(builder.cflags(target, GitRepo::Rustc).join(" "));
1515 copts_passed = true;
1516 if let Some(ar) = builder.ar(target) {
1517 cmd.arg("--ar").arg(ar);
1521 if !llvm_components_passed {
1522 cmd.arg("--llvm-components").arg("");
1525 cmd.arg("--cc").arg("").arg("--cxx").arg("").arg("--cflags").arg("");
1528 if builder.remote_tested(target) {
1529 cmd.arg("--remote-test-client").arg(builder.tool_exe(Tool::RemoteTestClient));
1532 // Running a C compiler on MSVC requires a few env vars to be set, to be
1533 // sure to set them here.
1535 // Note that if we encounter `PATH` we make sure to append to our own `PATH`
1536 // rather than stomp over it.
1537 if target.contains("msvc") {
1538 for &(ref k, ref v) in builder.cc[&target].env() {
1544 cmd.env("RUSTC_BOOTSTRAP", "1");
1545 cmd.env("DOC_RUST_LANG_ORG_CHANNEL", builder.doc_rust_lang_org_channel());
1546 builder.add_rust_test_threads(&mut cmd);
1548 if builder.config.sanitizers_enabled(target) {
1549 cmd.env("RUSTC_SANITIZER_SUPPORT", "1");
1552 if builder.config.profiler_enabled(target) {
1553 cmd.env("RUSTC_PROFILER_SUPPORT", "1");
1556 let tmp = builder.out.join("tmp");
1557 std::fs::create_dir_all(&tmp).unwrap();
1558 cmd.env("RUST_TEST_TMPDIR", tmp);
1560 cmd.arg("--adb-path").arg("adb");
1561 cmd.arg("--adb-test-dir").arg(ADB_TEST_DIR);
1562 if target.contains("android") {
1563 // Assume that cc for this target comes from the android sysroot
1564 cmd.arg("--android-cross-path")
1565 .arg(builder.cc(target).parent().unwrap().parent().unwrap());
1567 cmd.arg("--android-cross-path").arg("");
1570 if builder.config.cmd.rustfix_coverage() {
1571 cmd.arg("--rustfix-coverage");
1574 cmd.env("BOOTSTRAP_CARGO", &builder.initial_cargo);
1576 cmd.arg("--channel").arg(&builder.config.channel);
1578 builder.ci_env.force_coloring_in_ci(&mut cmd);
1580 builder.info(&format!(
1581 "Check compiletest suite={} mode={} ({} -> {})",
1582 suite, mode, &compiler.host, target
1584 let _time = util::timeit(&builder);
1585 try_run(builder, &mut cmd);
1587 if let Some(compare_mode) = compare_mode {
1588 cmd.arg("--compare-mode").arg(compare_mode);
1589 builder.info(&format!(
1590 "Check compiletest suite={} mode={} compare_mode={} ({} -> {})",
1591 suite, mode, compare_mode, &compiler.host, target
1593 let _time = util::timeit(&builder);
1594 try_run(builder, &mut cmd);
1599 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1607 impl Step for BookTest {
1609 const ONLY_HOSTS: bool = true;
1611 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1615 /// Runs the documentation tests for a book in `src/doc`.
1617 /// This uses the `rustdoc` that sits next to `compiler`.
1618 fn run(self, builder: &Builder<'_>) {
1619 // External docs are different from local because:
1620 // - Some books need pre-processing by mdbook before being tested.
1621 // - They need to save their state to toolstate.
1622 // - They are only tested on the "checktools" builders.
1624 // The local docs are tested by default, and we don't want to pay the
1625 // cost of building mdbook, so they use `rustdoc --test` directly.
1626 // Also, the unstable book is special because SUMMARY.md is generated,
1627 // so it is easier to just run `rustdoc` on its files.
1628 if self.is_ext_doc {
1629 self.run_ext_doc(builder);
1631 self.run_local_doc(builder);
1637 /// This runs the equivalent of `mdbook test` (via the rustbook wrapper)
1638 /// which in turn runs `rustdoc --test` on each file in the book.
1639 fn run_ext_doc(self, builder: &Builder<'_>) {
1640 let compiler = self.compiler;
1642 builder.ensure(compile::Std { compiler, target: compiler.host });
1644 // mdbook just executes a binary named "rustdoc", so we need to update
1645 // PATH so that it points to our rustdoc.
1646 let mut rustdoc_path = builder.rustdoc(compiler);
1648 let old_path = env::var_os("PATH").unwrap_or_default();
1649 let new_path = env::join_paths(iter::once(rustdoc_path).chain(env::split_paths(&old_path)))
1650 .expect("could not add rustdoc to PATH");
1652 let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
1653 let path = builder.src.join(&self.path);
1654 rustbook_cmd.env("PATH", new_path).arg("test").arg(path);
1655 builder.add_rust_test_threads(&mut rustbook_cmd);
1656 builder.info(&format!("Testing rustbook {}", self.path.display()));
1657 let _time = util::timeit(&builder);
1658 let toolstate = if try_run(builder, &mut rustbook_cmd) {
1663 builder.save_toolstate(self.name, toolstate);
1666 /// This runs `rustdoc --test` on all `.md` files in the path.
1667 fn run_local_doc(self, builder: &Builder<'_>) {
1668 let compiler = self.compiler;
1670 builder.ensure(compile::Std { compiler, target: compiler.host });
1672 // Do a breadth-first traversal of the `src/doc` directory and just run
1673 // tests for all files that end in `*.md`
1674 let mut stack = vec![builder.src.join(self.path)];
1675 let _time = util::timeit(&builder);
1676 let mut files = Vec::new();
1677 while let Some(p) = stack.pop() {
1679 stack.extend(t!(p.read_dir()).map(|p| t!(p).path()));
1683 if p.extension().and_then(|s| s.to_str()) != Some("md") {
1693 markdown_test(builder, compiler, &file);
1698 macro_rules! test_book {
1699 ($($name:ident, $path:expr, $book_name:expr, default=$default:expr;)+) => {
1701 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1706 impl Step for $name {
1708 const DEFAULT: bool = $default;
1709 const ONLY_HOSTS: bool = true;
1711 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1715 fn make_run(run: RunConfig<'_>) {
1716 run.builder.ensure($name {
1717 compiler: run.builder.compiler(run.builder.top_stage, run.target),
1721 fn run(self, builder: &Builder<'_>) {
1722 builder.ensure(BookTest {
1723 compiler: self.compiler,
1724 path: PathBuf::from($path),
1726 is_ext_doc: !$default,
1735 Nomicon, "src/doc/nomicon", "nomicon", default=false;
1736 Reference, "src/doc/reference", "reference", default=false;
1737 RustdocBook, "src/doc/rustdoc", "rustdoc", default=true;
1738 RustcBook, "src/doc/rustc", "rustc", default=true;
1739 RustByExample, "src/doc/rust-by-example", "rust-by-example", default=false;
1740 EmbeddedBook, "src/doc/embedded-book", "embedded-book", default=false;
1741 TheBook, "src/doc/book", "book", default=false;
1742 UnstableBook, "src/doc/unstable-book", "unstable-book", default=true;
1743 EditionGuide, "src/doc/edition-guide", "edition-guide", default=false;
1746 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1747 pub struct ErrorIndex {
1751 impl Step for ErrorIndex {
1753 const DEFAULT: bool = true;
1754 const ONLY_HOSTS: bool = true;
1756 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1757 run.path("src/tools/error_index_generator")
1760 fn make_run(run: RunConfig<'_>) {
1761 // error_index_generator depends on librustdoc. Use the compiler that
1762 // is normally used to build rustdoc for other tests (like compiletest
1763 // tests in src/test/rustdoc) so that it shares the same artifacts.
1764 let compiler = run.builder.compiler(run.builder.top_stage, run.builder.config.build);
1765 run.builder.ensure(ErrorIndex { compiler });
1768 /// Runs the error index generator tool to execute the tests located in the error
1771 /// The `error_index_generator` tool lives in `src/tools` and is used to
1772 /// generate a markdown file from the error indexes of the code base which is
1773 /// then passed to `rustdoc --test`.
1774 fn run(self, builder: &Builder<'_>) {
1775 let compiler = self.compiler;
1777 let dir = testdir(builder, compiler.host);
1778 t!(fs::create_dir_all(&dir));
1779 let output = dir.join("error-index.md");
1781 let mut tool = tool::ErrorIndex::command(builder);
1782 tool.arg("markdown").arg(&output);
1784 builder.info(&format!("Testing error-index stage{}", compiler.stage));
1785 let _time = util::timeit(&builder);
1786 builder.run_quiet(&mut tool);
1787 // The tests themselves need to link to std, so make sure it is
1789 builder.ensure(compile::Std { compiler, target: compiler.host });
1790 markdown_test(builder, compiler, &output);
1794 fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) -> bool {
1795 if let Ok(contents) = fs::read_to_string(markdown) {
1796 if !contents.contains("```") {
1801 builder.info(&format!("doc tests for: {}", markdown.display()));
1802 let mut cmd = builder.rustdoc_cmd(compiler);
1803 builder.add_rust_test_threads(&mut cmd);
1804 // allow for unstable options such as new editions
1806 cmd.arg("unstable-options");
1809 cmd.env("RUSTC_BOOTSTRAP", "1");
1811 let test_args = builder.config.cmd.test_args().join(" ");
1812 cmd.arg("--test-args").arg(test_args);
1814 if builder.config.verbose_tests {
1815 try_run(builder, &mut cmd)
1817 try_run_quiet(builder, &mut cmd)
1821 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1822 pub struct RustcGuide;
1824 impl Step for RustcGuide {
1826 const DEFAULT: bool = false;
1827 const ONLY_HOSTS: bool = true;
1829 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1830 run.path("src/doc/rustc-dev-guide")
1833 fn make_run(run: RunConfig<'_>) {
1834 run.builder.ensure(RustcGuide);
1837 fn run(self, builder: &Builder<'_>) {
1838 let src = builder.src.join("src/doc/rustc-dev-guide");
1839 let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
1840 let toolstate = if try_run(builder, rustbook_cmd.arg("linkcheck").arg(&src)) {
1845 builder.save_toolstate("rustc-dev-guide", toolstate);
1849 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1850 pub struct CrateLibrustc {
1852 target: TargetSelection,
1853 test_kind: TestKind,
1854 krate: Interned<String>,
1857 impl Step for CrateLibrustc {
1859 const DEFAULT: bool = true;
1860 const ONLY_HOSTS: bool = true;
1862 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1863 run.krate("rustc-main")
1866 fn make_run(run: RunConfig<'_>) {
1867 let builder = run.builder;
1868 let compiler = builder.compiler(builder.top_stage, run.build_triple());
1870 for krate in builder.in_tree_crates("rustc-main", Some(run.target)) {
1871 if krate.path.ends_with(&run.path) {
1872 let test_kind = builder.kind.into();
1874 builder.ensure(CrateLibrustc {
1884 fn run(self, builder: &Builder<'_>) {
1885 builder.ensure(Crate {
1886 compiler: self.compiler,
1887 target: self.target,
1889 test_kind: self.test_kind,
1895 #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
1897 pub compiler: Compiler,
1898 pub target: TargetSelection,
1900 pub test_kind: TestKind,
1901 pub krate: Interned<String>,
1904 impl Step for Crate {
1906 const DEFAULT: bool = true;
1908 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1912 fn make_run(run: RunConfig<'_>) {
1913 let builder = run.builder;
1914 let compiler = builder.compiler(builder.top_stage, run.build_triple());
1916 let make = |mode: Mode, krate: &CargoCrate| {
1917 let test_kind = builder.kind.into();
1919 builder.ensure(Crate {
1928 for krate in builder.in_tree_crates("test", Some(run.target)) {
1929 if krate.path.ends_with(&run.path) {
1930 make(Mode::Std, krate);
1935 /// Runs all unit tests plus documentation tests for a given crate defined
1936 /// by a `Cargo.toml` (single manifest)
1938 /// This is what runs tests for crates like the standard library, compiler, etc.
1939 /// It essentially is the driver for running `cargo test`.
1941 /// Currently this runs all tests for a DAG by passing a bunch of `-p foo`
1942 /// arguments, and those arguments are discovered from `cargo metadata`.
1943 fn run(self, builder: &Builder<'_>) {
1944 let compiler = self.compiler;
1945 let target = self.target;
1946 let mode = self.mode;
1947 let test_kind = self.test_kind;
1948 let krate = self.krate;
1950 builder.ensure(compile::Std { compiler, target });
1951 builder.ensure(RemoteCopyLibs { compiler, target });
1953 // If we're not doing a full bootstrap but we're testing a stage2
1954 // version of libstd, then what we're actually testing is the libstd
1955 // produced in stage1. Reflect that here by updating the compiler that
1956 // we're working with automatically.
1957 let compiler = builder.compiler_for(compiler.stage, compiler.host, target);
1960 builder.cargo(compiler, mode, SourceType::InTree, target, test_kind.subcommand());
1963 compile::std_cargo(builder, target, compiler.stage, &mut cargo);
1966 builder.ensure(compile::Rustc { compiler, target });
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 cargo.arg("-p").arg(krate);
1992 // The tests are going to run with the *target* libraries, so we need to
1993 // ensure that those libraries show up in the LD_LIBRARY_PATH equivalent.
1995 // Note that to run the compiler we need to run with the *host* libraries,
1996 // but our wrapper scripts arrange for that to be the case anyway.
1997 let mut dylib_path = dylib_path();
1998 dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target)));
1999 cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
2002 cargo.args(&builder.config.cmd.test_args());
2004 if !builder.config.verbose_tests {
2005 cargo.arg("--quiet");
2008 if target.contains("emscripten") {
2010 format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)),
2011 builder.config.nodejs.as_ref().expect("nodejs not configured"),
2013 } else if target.starts_with("wasm32") {
2014 let node = builder.config.nodejs.as_ref().expect("nodejs not configured");
2016 format!("{} {}/src/etc/wasm32-shim.js", node.display(), builder.src.display());
2017 cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), &runner);
2018 } else if builder.remote_tested(target) {
2020 format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)),
2021 format!("{} run 0", builder.tool_exe(Tool::RemoteTestClient).display()),
2025 builder.info(&format!(
2026 "{} {} stage{} ({} -> {})",
2027 test_kind, krate, compiler.stage, &compiler.host, target
2029 let _time = util::timeit(&builder);
2030 try_run(builder, &mut cargo.into());
2034 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2035 pub struct CrateRustdoc {
2036 host: TargetSelection,
2037 test_kind: TestKind,
2040 impl Step for CrateRustdoc {
2042 const DEFAULT: bool = true;
2043 const ONLY_HOSTS: bool = true;
2045 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2046 run.paths(&["src/librustdoc", "src/tools/rustdoc"])
2049 fn make_run(run: RunConfig<'_>) {
2050 let builder = run.builder;
2052 let test_kind = builder.kind.into();
2054 builder.ensure(CrateRustdoc { host: run.target, test_kind });
2057 fn run(self, builder: &Builder<'_>) {
2058 let test_kind = self.test_kind;
2059 let target = self.host;
2061 // Use the previous stage compiler to reuse the artifacts that are
2062 // created when running compiletest for src/test/rustdoc. If this used
2063 // `compiler`, then it would cause rustdoc to be built *again*, which
2064 // isn't really necessary.
2065 let compiler = builder.compiler_for(builder.top_stage, target, target);
2066 builder.ensure(compile::Rustc { compiler, target });
2068 let mut cargo = tool::prepare_tool_cargo(
2073 test_kind.subcommand(),
2074 "src/tools/rustdoc",
2078 if test_kind.subcommand() == "test" && !builder.fail_fast {
2079 cargo.arg("--no-fail-fast");
2082 cargo.arg("-p").arg("rustdoc:0.0.0");
2085 cargo.args(&builder.config.cmd.test_args());
2087 if self.host.contains("musl") {
2088 cargo.arg("'-Ctarget-feature=-crt-static'");
2091 // This is needed for running doctests on librustdoc. This is a bit of
2092 // an unfortunate interaction with how bootstrap works and how cargo
2093 // sets up the dylib path, and the fact that the doctest (in
2094 // html/markdown.rs) links to rustc-private libs. For stage1, the
2095 // compiler host dylibs (in stage1/lib) are not the same as the target
2096 // dylibs (in stage1/lib/rustlib/...). This is different from a normal
2097 // rust distribution where they are the same.
2099 // On the cargo side, normal tests use `target_process` which handles
2100 // setting up the dylib for a *target* (stage1/lib/rustlib/... in this
2101 // case). However, for doctests it uses `rustdoc_process` which only
2102 // sets up the dylib path for the *host* (stage1/lib), which is the
2105 // It should be considered to just stop running doctests on
2106 // librustdoc. There is only one test, and it doesn't look too
2107 // important. There might be other ways to avoid this, but it seems
2108 // pretty convoluted.
2110 // See also https://github.com/rust-lang/rust/issues/13983 where the
2111 // host vs target dylibs for rustdoc are consistently tricky to deal
2113 let mut dylib_path = dylib_path();
2114 dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target)));
2115 cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
2117 if !builder.config.verbose_tests {
2118 cargo.arg("--quiet");
2121 builder.info(&format!(
2122 "{} rustdoc stage{} ({} -> {})",
2123 test_kind, compiler.stage, &compiler.host, target
2125 let _time = util::timeit(&builder);
2127 try_run(builder, &mut cargo.into());
2131 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2132 pub struct CrateRustdocJsonTypes {
2133 host: TargetSelection,
2134 test_kind: TestKind,
2137 impl Step for CrateRustdocJsonTypes {
2139 const DEFAULT: bool = true;
2140 const ONLY_HOSTS: bool = true;
2142 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2143 run.path("src/rustdoc-json-types")
2146 fn make_run(run: RunConfig<'_>) {
2147 let builder = run.builder;
2149 let test_kind = builder.kind.into();
2151 builder.ensure(CrateRustdocJsonTypes { host: run.target, test_kind });
2154 fn run(self, builder: &Builder<'_>) {
2155 let test_kind = self.test_kind;
2156 let target = self.host;
2158 // Use the previous stage compiler to reuse the artifacts that are
2159 // created when running compiletest for src/test/rustdoc. If this used
2160 // `compiler`, then it would cause rustdoc to be built *again*, which
2161 // isn't really necessary.
2162 let compiler = builder.compiler_for(builder.top_stage, target, target);
2163 builder.ensure(compile::Rustc { compiler, target });
2165 let mut cargo = tool::prepare_tool_cargo(
2170 test_kind.subcommand(),
2171 "src/rustdoc-json-types",
2175 if test_kind.subcommand() == "test" && !builder.fail_fast {
2176 cargo.arg("--no-fail-fast");
2179 cargo.arg("-p").arg("rustdoc-json-types");
2182 cargo.args(&builder.config.cmd.test_args());
2184 if self.host.contains("musl") {
2185 cargo.arg("'-Ctarget-feature=-crt-static'");
2188 if !builder.config.verbose_tests {
2189 cargo.arg("--quiet");
2192 builder.info(&format!(
2193 "{} rustdoc-json-types stage{} ({} -> {})",
2194 test_kind, compiler.stage, &compiler.host, target
2196 let _time = util::timeit(&builder);
2198 try_run(builder, &mut cargo.into());
2202 /// Some test suites are run inside emulators or on remote devices, and most
2203 /// of our test binaries are linked dynamically which means we need to ship
2204 /// the standard library and such to the emulator ahead of time. This step
2205 /// represents this and is a dependency of all test suites.
2207 /// Most of the time this is a no-op. For some steps such as shipping data to
2208 /// QEMU we have to build our own tools so we've got conditional dependencies
2209 /// on those programs as well. Note that the remote test client is built for
2210 /// the build target (us) and the server is built for the target.
2211 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2212 pub struct RemoteCopyLibs {
2214 target: TargetSelection,
2217 impl Step for RemoteCopyLibs {
2220 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2224 fn run(self, builder: &Builder<'_>) {
2225 let compiler = self.compiler;
2226 let target = self.target;
2227 if !builder.remote_tested(target) {
2231 builder.ensure(compile::Std { compiler, target });
2233 builder.info(&format!("REMOTE copy libs to emulator ({})", target));
2234 t!(fs::create_dir_all(builder.out.join("tmp")));
2236 let server = builder.ensure(tool::RemoteTestServer { compiler, target });
2238 // Spawn the emulator and wait for it to come online
2239 let tool = builder.tool_exe(Tool::RemoteTestClient);
2240 let mut cmd = Command::new(&tool);
2241 cmd.arg("spawn-emulator").arg(target.triple).arg(&server).arg(builder.out.join("tmp"));
2242 if let Some(rootfs) = builder.qemu_rootfs(target) {
2245 builder.run(&mut cmd);
2247 // Push all our dylibs to the emulator
2248 for f in t!(builder.sysroot_libdir(compiler, target).read_dir()) {
2250 let name = f.file_name().into_string().unwrap();
2251 if util::is_dylib(&name) {
2252 builder.run(Command::new(&tool).arg("push").arg(f.path()));
2258 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2259 pub struct Distcheck;
2261 impl Step for Distcheck {
2264 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2265 run.path("distcheck")
2268 fn make_run(run: RunConfig<'_>) {
2269 run.builder.ensure(Distcheck);
2272 /// Runs "distcheck", a 'make check' from a tarball
2273 fn run(self, builder: &Builder<'_>) {
2274 builder.info("Distcheck");
2275 let dir = builder.out.join("tmp").join("distcheck");
2276 let _ = fs::remove_dir_all(&dir);
2277 t!(fs::create_dir_all(&dir));
2279 // Guarantee that these are built before we begin running.
2280 builder.ensure(dist::PlainSourceTarball);
2281 builder.ensure(dist::Src);
2283 let mut cmd = Command::new("tar");
2285 .arg(builder.ensure(dist::PlainSourceTarball).tarball())
2286 .arg("--strip-components=1")
2288 builder.run(&mut cmd);
2290 Command::new("./configure")
2291 .args(&builder.config.configure_args)
2292 .arg("--enable-vendor")
2296 Command::new(build_helper::make(&builder.config.build.triple))
2301 // Now make sure that rust-src has all of libstd's dependencies
2302 builder.info("Distcheck rust-src");
2303 let dir = builder.out.join("tmp").join("distcheck-src");
2304 let _ = fs::remove_dir_all(&dir);
2305 t!(fs::create_dir_all(&dir));
2307 let mut cmd = Command::new("tar");
2309 .arg(builder.ensure(dist::Src).tarball())
2310 .arg("--strip-components=1")
2312 builder.run(&mut cmd);
2314 let toml = dir.join("rust-src/lib/rustlib/src/rust/library/std/Cargo.toml");
2316 Command::new(&builder.initial_cargo)
2317 .arg("generate-lockfile")
2318 .arg("--manifest-path")
2325 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2326 pub struct Bootstrap;
2328 impl Step for Bootstrap {
2330 const DEFAULT: bool = true;
2331 const ONLY_HOSTS: bool = true;
2333 /// Tests the build system itself.
2334 fn run(self, builder: &Builder<'_>) {
2335 let mut cmd = Command::new(&builder.initial_cargo);
2337 .current_dir(builder.src.join("src/bootstrap"))
2338 .env("RUSTFLAGS", "-Cdebuginfo=2")
2339 .env("CARGO_TARGET_DIR", builder.out.join("bootstrap"))
2340 .env("BOOTSTRAP_OUTPUT_DIRECTORY", &builder.config.out)
2341 .env("BOOTSTRAP_INITIAL_CARGO", &builder.config.initial_cargo)
2342 .env("RUSTC_BOOTSTRAP", "1")
2343 .env("RUSTC", &builder.initial_rustc);
2344 if let Some(flags) = option_env!("RUSTFLAGS") {
2345 // Use the same rustc flags for testing as for "normal" compilation,
2346 // so that Cargo doesn’t recompile the entire dependency graph every time:
2347 // https://github.com/rust-lang/rust/issues/49215
2348 cmd.env("RUSTFLAGS", flags);
2350 if !builder.fail_fast {
2351 cmd.arg("--no-fail-fast");
2353 cmd.arg("--").args(&builder.config.cmd.test_args());
2354 // rustbuild tests are racy on directory creation so just run them one at a time.
2355 // Since there's not many this shouldn't be a problem.
2356 cmd.arg("--test-threads=1");
2357 try_run(builder, &mut cmd);
2360 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2361 run.path("src/bootstrap")
2364 fn make_run(run: RunConfig<'_>) {
2365 run.builder.ensure(Bootstrap);
2369 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2370 pub struct TierCheck {
2371 pub compiler: Compiler,
2374 impl Step for TierCheck {
2376 const DEFAULT: bool = true;
2377 const ONLY_HOSTS: bool = true;
2379 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2380 run.path("src/tools/tier-check")
2383 fn make_run(run: RunConfig<'_>) {
2385 run.builder.compiler_for(run.builder.top_stage, run.builder.build.build, run.target);
2386 run.builder.ensure(TierCheck { compiler });
2389 /// Tests the Platform Support page in the rustc book.
2390 fn run(self, builder: &Builder<'_>) {
2391 builder.ensure(compile::Std { compiler: self.compiler, target: self.compiler.host });
2392 let mut cargo = tool::prepare_tool_cargo(
2398 "src/tools/tier-check",
2402 cargo.arg(builder.src.join("src/doc/rustc/src/platform-support.md"));
2403 cargo.arg(&builder.rustc(self.compiler));
2404 if builder.is_verbose() {
2405 cargo.arg("--verbose");
2408 builder.info("platform support check");
2409 try_run(builder, &mut cargo.into());
2413 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2414 pub struct LintDocs {
2415 pub compiler: Compiler,
2416 pub target: TargetSelection,
2419 impl Step for LintDocs {
2421 const DEFAULT: bool = true;
2422 const ONLY_HOSTS: bool = true;
2424 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2425 run.path("src/tools/lint-docs")
2428 fn make_run(run: RunConfig<'_>) {
2429 run.builder.ensure(LintDocs {
2430 compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
2435 /// Tests that the lint examples in the rustc book generate the correct
2436 /// lints and have the expected format.
2437 fn run(self, builder: &Builder<'_>) {
2438 builder.ensure(crate::doc::RustcBook {
2439 compiler: self.compiler,
2440 target: self.target,