From 33583c8c141f6f1909c2777e35939acb22ea89d1 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Thu, 18 Sep 2025 15:46:39 +1000 Subject: [PATCH] Move the `tests::snapshot` submodule into its own file Having these tests in an inline module made it harder to navigate both the snapshot tests and the surrounding module. --- src/bootstrap/src/core/builder/tests.rs | 2420 +---------------- .../src/core/builder/tests/snapshot.rs | 2416 ++++++++++++++++ 2 files changed, 2418 insertions(+), 2418 deletions(-) create mode 100644 src/bootstrap/src/core/builder/tests/snapshot.rs diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index 229adf714598b..14bb748f1efe9 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -13,6 +13,8 @@ use crate::utils::helpers::get_host_target; use crate::utils::tests::git::{GitCtx, git_test}; use crate::utils::tests::{ConfigBuilder, TestCtx}; +mod snapshot; + static TEST_TRIPLE_1: &str = "i686-unknown-haiku"; static TEST_TRIPLE_2: &str = "i686-unknown-hurd-gnu"; static TEST_TRIPLE_3: &str = "i686-unknown-netbsd"; @@ -515,2424 +517,6 @@ fn any_debug() { assert_eq!(x.downcast_ref::(), Some(&MyStruct { x: 7 })); } -/// These tests use insta for snapshot testing. -/// See bootstrap's README on how to bless the snapshots. -mod snapshot { - use std::path::PathBuf; - - use crate::core::build_steps::{compile, dist, doc, test, tool}; - use crate::core::builder::tests::{ - RenderConfig, TEST_TRIPLE_1, TEST_TRIPLE_2, TEST_TRIPLE_3, configure, first, host_target, - render_steps, run_build, - }; - use crate::core::builder::{Builder, Kind, StepDescription, StepMetadata}; - use crate::core::config::TargetSelection; - use crate::core::config::toml::rust::with_lld_opt_in_targets; - use crate::utils::cache::Cache; - use crate::utils::helpers::get_host_target; - use crate::utils::tests::{ConfigBuilder, TestCtx}; - use crate::{Build, Compiler, Config, Flags, Subcommand}; - - #[test] - fn build_default() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustdoc 1 - "); - } - - #[test] - fn build_cross_compile() { - let ctx = TestCtx::new(); - - insta::assert_snapshot!( - ctx.config("build") - // Cross-compilation fails on stage 1, as we don't have a stage0 std available - // for non-host targets. - .stage(2) - .hosts(&[&host_target(), TEST_TRIPLE_1]) - .targets(&[&host_target(), TEST_TRIPLE_1]) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [build] rustc 2 -> std 2 - [build] rustc 1 -> std 1 - [build] rustc 2 -> std 2 - [build] rustdoc 2 - [build] llvm - [build] rustc 1 -> rustc 2 - [build] rustdoc 2 - "); - } - - #[test] - fn build_with_empty_host() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx - .config("build") - .hosts(&[]) - .targets(&[TEST_TRIPLE_1]) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - " - ); - } - - #[test] - fn build_compiler_no_explicit_stage() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("compiler") - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - "); - } - - #[test] - fn build_rustc_no_explicit_stage() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("rustc") - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - "); - } - - #[test] - #[should_panic] - fn build_compiler_stage_0() { - let ctx = TestCtx::new(); - ctx.config("build").path("compiler").stage(0).run(); - } - - #[test] - fn build_compiler_stage_1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("compiler") - .stage(1) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - "); - } - - #[test] - fn build_compiler_stage_2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("compiler") - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - "); - } - - #[test] - fn build_compiler_stage_3() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("compiler") - .stage(3) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [build] rustc 2 -> std 2 - [build] rustc 2 -> rustc 3 - "); - } - - #[test] - fn build_compiler_stage_3_cross() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("compiler") - .hosts(&[TEST_TRIPLE_1]) - .stage(3) - .render_steps(), @r" - [build] llvm - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> std 1 - [build] rustc 2 -> std 2 - [build] rustc 2 -> std 2 - [build] rustc 2 -> rustc 3 - "); - } - - #[test] - fn build_compiler_stage_3_full_bootstrap() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("compiler") - .stage(3) - .args(&["--set", "build.full-bootstrap=true"]) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [build] rustc 2 -> std 2 - [build] rustc 2 -> rustc 3 - "); - } - - #[test] - fn build_compiler_stage_3_cross_full_bootstrap() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("compiler") - .stage(3) - .hosts(&[TEST_TRIPLE_1]) - .args(&["--set", "build.full-bootstrap=true"]) - .render_steps(), @r" - [build] llvm - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [build] rustc 2 -> std 2 - [build] rustc 2 -> std 2 - [build] rustc 2 -> rustc 3 - "); - } - - #[test] - fn build_compiler_codegen_backend() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx - .config("build") - .args(&["--set", "rust.codegen-backends=['llvm', 'cranelift']"]) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 0 -> rustc_codegen_cranelift 1 - [build] rustc 1 -> std 1 - [build] rustdoc 1 - " - ); - } - - #[test] - fn build_compiler_tools() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx - .config("build") - .stage(2) - .args(&["--set", "rust.lld=true", "--set", "rust.llvm-bitcode-linker=true"]) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 0 -> LldWrapper 1 - [build] rustc 0 -> LlvmBitcodeLinker 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> LldWrapper 2 - [build] rustc 1 -> LlvmBitcodeLinker 2 - [build] rustc 2 -> std 2 - [build] rustdoc 2 - " - ); - } - - #[test] - fn build_compiler_tools_cross() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx - .config("build") - .stage(2) - .args(&["--set", "rust.lld=true", "--set", "rust.llvm-bitcode-linker=true"]) - .hosts(&[TEST_TRIPLE_1]) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 0 -> LldWrapper 1 - [build] rustc 0 -> LlvmBitcodeLinker 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> LldWrapper 2 - [build] rustc 1 -> LlvmBitcodeLinker 2 - [build] rustc 1 -> std 1 - [build] rustc 2 -> std 2 - [build] llvm - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> LldWrapper 2 - [build] rustc 1 -> LlvmBitcodeLinker 2 - [build] rustdoc 2 - " - ); - } - - #[test] - fn build_compiler_lld_opt_in() { - with_lld_opt_in_targets(vec![host_target()], || { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("compiler") - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 0 -> LldWrapper 1 - "); - }); - } - - #[test] - fn build_library_no_explicit_stage() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("library") - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - "); - } - - #[test] - #[should_panic] - fn build_library_stage_0() { - let ctx = TestCtx::new(); - ctx.config("build").path("library").stage(0).run(); - } - - #[test] - fn build_library_stage_0_local_rebuild() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("library") - .stage(0) - .targets(&[TEST_TRIPLE_1]) - .args(&["--set", "build.local-rebuild=true"]) - .render_steps(), @"[build] rustc 0 -> std 0 "); - } - - #[test] - fn build_library_stage_1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("library") - .stage(1) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - "); - } - - #[test] - fn build_library_stage_2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("library") - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [build] rustc 2 -> std 2 - "); - } - - #[test] - fn build_miri_no_explicit_stage() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("miri") - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 0 -> miri 1 - "); - } - - #[test] - #[should_panic] - fn build_miri_stage_0() { - let ctx = TestCtx::new(); - ctx.config("build").path("miri").stage(0).run(); - } - - #[test] - fn build_miri_stage_1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("miri") - .stage(1) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 0 -> miri 1 - "); - } - - #[test] - fn build_miri_stage_2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("miri") - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> miri 2 - "); - } - - #[test] - fn build_error_index() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("error_index_generator") - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 0 -> error-index 1 - "); - } - - #[test] - fn build_bootstrap_tool_no_explicit_stage() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("opt-dist") - .render_steps(), @"[build] rustc 0 -> OptimizedDist 1 "); - } - - #[test] - #[should_panic] - fn build_bootstrap_tool_stage_0() { - let ctx = TestCtx::new(); - ctx.config("build").path("opt-dist").stage(0).run(); - } - - #[test] - fn build_bootstrap_tool_stage_1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("opt-dist") - .stage(1) - .render_steps(), @"[build] rustc 0 -> OptimizedDist 1 "); - } - - #[test] - fn build_bootstrap_tool_stage_2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .path("opt-dist") - .stage(2) - .render_steps(), @"[build] rustc 0 -> OptimizedDist 1 "); - } - - #[test] - fn build_default_stage() { - let ctx = TestCtx::new(); - assert_eq!(ctx.config("build").path("compiler").create_config().stage, 1); - } - - /// Ensure that if someone passes both a single crate and `library`, all - /// library crates get built. - #[test] - fn alias_and_path_for_library() { - let ctx = TestCtx::new(); - insta::assert_snapshot!(ctx.config("build") - .paths(&["library", "core"]) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - "); - - insta::assert_snapshot!(ctx.config("build") - .paths(&["std"]) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - "); - - insta::assert_snapshot!(ctx.config("build") - .paths(&["core"]) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - "); - - insta::assert_snapshot!(ctx.config("build") - .paths(&["alloc"]) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - "); - - insta::assert_snapshot!(ctx.config("doc") - .paths(&["library", "core"]) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustdoc 1 - [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - "); - } - - #[test] - fn build_all() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .stage(2) - .paths(&["compiler/rustc", "library"]) - .hosts(&[&host_target(), TEST_TRIPLE_1]) - .targets(&[&host_target(), TEST_TRIPLE_1, TEST_TRIPLE_2]) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [build] llvm - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [build] rustc 2 -> std 2 - [build] rustc 2 -> std 2 - [build] rustc 1 -> std 1 - [build] rustc 2 -> std 2 - "); - } - - #[test] - fn build_cargo() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .paths(&["cargo"]) - .render_steps(), @"[build] rustc 0 -> cargo 1 "); - } - - #[test] - fn build_cargo_cross() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("build") - .paths(&["cargo"]) - .hosts(&[TEST_TRIPLE_1]) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> cargo 2 - "); - } - - #[test] - fn dist_default_stage() { - let ctx = TestCtx::new(); - assert_eq!(ctx.config("dist").path("compiler").create_config().stage, 2); - } - - #[test] - fn dist_baseline() { - let ctx = TestCtx::new(); - // Note that stdlib is uplifted, that is why `[dist] rustc 1 -> std ` is in - // the output. - insta::assert_snapshot!( - ctx - .config("dist") - .render_steps(), @r" - [build] rustc 0 -> UnstableBookGen 1 - [build] rustc 0 -> Rustbook 1 - [doc] unstable-book (book) - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [doc] book (book) - [doc] book/first-edition (book) - [doc] book/second-edition (book) - [doc] book/2018-edition (book) - [build] rustdoc 1 - [doc] rustc 1 -> standalone 2 - [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> error-index 2 - [doc] rustc 1 -> error-index 2 - [doc] nomicon (book) - [doc] rustc 1 -> reference (book) 2 - [doc] rustdoc (book) - [doc] rust-by-example (book) - [build] rustc 0 -> LintDocs 1 - [doc] rustc (book) - [doc] cargo (book) - [doc] clippy (book) - [doc] embedded-book (book) - [doc] edition-guide (book) - [doc] style-guide (book) - [doc] rustc 1 -> releases 2 - [build] rustc 0 -> RustInstaller 1 - [dist] docs - [doc] rustc 1 -> std 1 crates=[] - [dist] rustc 1 -> json-docs 2 - [dist] mingw - [build] rustdoc 2 - [build] rustc 0 -> GenerateCopyright 1 - [dist] rustc - [dist] rustc 1 -> std 1 - [dist] rustc 1 -> rustc-dev 2 - [dist] src <> - [dist] reproducible-artifacts - " - ); - } - - #[test] - fn dist_compiler_docs() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("dist") - .path("rustc-docs") - .args(&["--set", "build.compiler-docs=true"]) - .render_steps(), @r" - [build] rustc 0 -> UnstableBookGen 1 - [build] rustc 0 -> Rustbook 1 - [doc] unstable-book (book) - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [doc] book (book) - [doc] book/first-edition (book) - [doc] book/second-edition (book) - [doc] book/2018-edition (book) - [build] rustdoc 1 - [doc] rustc 1 -> standalone 2 - [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - [doc] rustc 1 -> rustc 2 - [build] rustc 1 -> rustc 2 - [doc] rustc 1 -> Rustdoc 2 - [doc] rustc 1 -> Rustfmt 2 - [build] rustc 1 -> error-index 2 - [doc] rustc 1 -> error-index 2 - [doc] nomicon (book) - [doc] rustc 1 -> reference (book) 2 - [doc] rustdoc (book) - [doc] rust-by-example (book) - [build] rustc 0 -> LintDocs 1 - [doc] rustc (book) - [doc] rustc 1 -> Cargo 2 - [doc] cargo (book) - [doc] rustc 1 -> Clippy 2 - [doc] clippy (book) - [doc] rustc 1 -> Miri 2 - [doc] embedded-book (book) - [doc] edition-guide (book) - [doc] style-guide (book) - [build] rustdoc 0 - [doc] rustc 0 -> Tidy 1 - [doc] rustc 0 -> Bootstrap 1 - [doc] rustc 1 -> releases 2 - [doc] rustc 0 -> RunMakeSupport 1 - [doc] rustc 0 -> BuildHelper 1 - [doc] rustc 0 -> Compiletest 1 - [build] rustc 0 -> RustInstaller 1 - " - ); - } - - #[test] - fn dist_extended() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("dist") - .args(&[ - "--set", - "build.extended=true", - "--set", - "rust.llvm-bitcode-linker=true", - "--set", - "rust.lld=true", - ]) - .render_steps(), @r" - [build] rustc 0 -> UnstableBookGen 1 - [build] rustc 0 -> Rustbook 1 - [doc] unstable-book (book) - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 0 -> LldWrapper 1 - [build] rustc 0 -> WasmComponentLd 1 - [build] rustc 0 -> LlvmBitcodeLinker 1 - [build] rustc 1 -> std 1 - [doc] book (book) - [doc] book/first-edition (book) - [doc] book/second-edition (book) - [doc] book/2018-edition (book) - [build] rustdoc 1 - [doc] rustc 1 -> standalone 2 - [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> LldWrapper 2 - [build] rustc 1 -> WasmComponentLd 2 - [build] rustc 1 -> LlvmBitcodeLinker 2 - [build] rustc 1 -> error-index 2 - [doc] rustc 1 -> error-index 2 - [doc] nomicon (book) - [doc] rustc 1 -> reference (book) 2 - [doc] rustdoc (book) - [doc] rust-by-example (book) - [build] rustc 0 -> LintDocs 1 - [doc] rustc (book) - [doc] cargo (book) - [doc] clippy (book) - [doc] embedded-book (book) - [doc] edition-guide (book) - [doc] style-guide (book) - [doc] rustc 1 -> releases 2 - [build] rustc 0 -> RustInstaller 1 - [dist] docs - [doc] rustc 1 -> std 1 crates=[] - [dist] rustc 1 -> json-docs 2 - [dist] mingw - [build] rustdoc 2 - [build] rustc 1 -> rust-analyzer-proc-macro-srv 2 - [build] rustc 0 -> GenerateCopyright 1 - [dist] rustc - [dist] rustc 1 -> std 1 - [dist] rustc 1 -> rustc-dev 2 - [dist] rustc 1 -> analysis 2 - [dist] src <> - [build] rustc 1 -> cargo 2 - [dist] rustc 1 -> cargo 2 - [build] rustc 1 -> rust-analyzer 2 - [dist] rustc 1 -> rust-analyzer 2 - [build] rustc 1 -> rustfmt 2 - [build] rustc 1 -> cargo-fmt 2 - [dist] rustc 1 -> rustfmt 2 - [build] rustc 1 -> clippy-driver 2 - [build] rustc 1 -> cargo-clippy 2 - [dist] rustc 1 -> clippy 2 - [build] rustc 1 -> miri 2 - [build] rustc 1 -> cargo-miri 2 - [dist] rustc 1 -> miri 2 - [doc] rustc 2 -> std 2 crates=[] - [dist] rustc 2 -> json-docs 3 - [dist] rustc 1 -> extended 2 - [dist] reproducible-artifacts - "); - } - - #[test] - fn dist_with_targets() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx - .config("dist") - .hosts(&[&host_target()]) - .targets(&[&host_target(), TEST_TRIPLE_1]) - .render_steps(), @r" - [build] rustc 0 -> UnstableBookGen 1 - [build] rustc 0 -> Rustbook 1 - [doc] unstable-book (book) - [doc] unstable-book (book) - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [doc] book (book) - [doc] book/first-edition (book) - [doc] book/second-edition (book) - [doc] book/2018-edition (book) - [build] rustdoc 1 - [build] rustc 1 -> std 1 - [doc] book (book) - [doc] book/first-edition (book) - [doc] book/second-edition (book) - [doc] book/2018-edition (book) - [doc] rustc 1 -> standalone 2 - [doc] rustc 1 -> standalone 2 - [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> error-index 2 - [doc] rustc 1 -> error-index 2 - [doc] nomicon (book) - [doc] nomicon (book) - [doc] rustc 1 -> reference (book) 2 - [doc] rustc 1 -> reference (book) 2 - [doc] rustdoc (book) - [doc] rustdoc (book) - [doc] rust-by-example (book) - [doc] rust-by-example (book) - [build] rustc 0 -> LintDocs 1 - [doc] rustc (book) - [doc] cargo (book) - [doc] cargo (book) - [doc] clippy (book) - [doc] clippy (book) - [doc] embedded-book (book) - [doc] embedded-book (book) - [doc] edition-guide (book) - [doc] edition-guide (book) - [doc] style-guide (book) - [doc] style-guide (book) - [doc] rustc 1 -> releases 2 - [doc] rustc 1 -> releases 2 - [build] rustc 0 -> RustInstaller 1 - [dist] docs - [dist] docs - [doc] rustc 1 -> std 1 crates=[] - [dist] rustc 1 -> json-docs 2 - [doc] rustc 1 -> std 1 crates=[] - [dist] rustc 1 -> json-docs 2 - [dist] mingw - [dist] mingw - [build] rustdoc 2 - [build] rustc 0 -> GenerateCopyright 1 - [dist] rustc - [dist] rustc 1 -> std 1 - [dist] rustc 1 -> std 1 - [dist] rustc 1 -> rustc-dev 2 - [dist] src <> - [dist] reproducible-artifacts - " - ); - } - - #[test] - fn dist_with_hosts() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx - .config("dist") - .hosts(&[&host_target(), TEST_TRIPLE_1]) - .targets(&[&host_target()]) - .render_steps(), @r" - [build] rustc 0 -> UnstableBookGen 1 - [build] rustc 0 -> Rustbook 1 - [doc] unstable-book (book) - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [doc] book (book) - [doc] book/first-edition (book) - [doc] book/second-edition (book) - [doc] book/2018-edition (book) - [build] rustdoc 1 - [doc] rustc 1 -> standalone 2 - [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> error-index 2 - [doc] rustc 1 -> error-index 2 - [build] llvm - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> error-index 2 - [doc] rustc 1 -> error-index 2 - [doc] nomicon (book) - [doc] rustc 1 -> reference (book) 2 - [doc] rustdoc (book) - [doc] rust-by-example (book) - [build] rustc 0 -> LintDocs 1 - [doc] rustc (book) - [doc] rustc (book) - [doc] cargo (book) - [doc] clippy (book) - [doc] embedded-book (book) - [doc] edition-guide (book) - [doc] style-guide (book) - [doc] rustc 1 -> releases 2 - [build] rustc 0 -> RustInstaller 1 - [dist] docs - [doc] rustc 1 -> std 1 crates=[] - [dist] rustc 1 -> json-docs 2 - [dist] mingw - [build] rustdoc 2 - [build] rustc 0 -> GenerateCopyright 1 - [dist] rustc - [build] rustdoc 2 - [dist] rustc - [dist] rustc 1 -> std 1 - [dist] rustc 1 -> rustc-dev 2 - [dist] rustc 1 -> rustc-dev 2 - [dist] src <> - [dist] reproducible-artifacts - [dist] reproducible-artifacts - " - ); - } - - #[test] - fn dist_with_targets_and_hosts() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx - .config("dist") - .hosts(&[&host_target(), TEST_TRIPLE_1]) - .targets(&[&host_target(), TEST_TRIPLE_1]) - .render_steps(), @r" - [build] rustc 0 -> UnstableBookGen 1 - [build] rustc 0 -> Rustbook 1 - [doc] unstable-book (book) - [doc] unstable-book (book) - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [doc] book (book) - [doc] book/first-edition (book) - [doc] book/second-edition (book) - [doc] book/2018-edition (book) - [build] rustdoc 1 - [build] rustc 1 -> std 1 - [doc] book (book) - [doc] book/first-edition (book) - [doc] book/second-edition (book) - [doc] book/2018-edition (book) - [doc] rustc 1 -> standalone 2 - [doc] rustc 1 -> standalone 2 - [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> error-index 2 - [doc] rustc 1 -> error-index 2 - [build] llvm - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> error-index 2 - [doc] rustc 1 -> error-index 2 - [doc] nomicon (book) - [doc] nomicon (book) - [doc] rustc 1 -> reference (book) 2 - [doc] rustc 1 -> reference (book) 2 - [doc] rustdoc (book) - [doc] rustdoc (book) - [doc] rust-by-example (book) - [doc] rust-by-example (book) - [build] rustc 0 -> LintDocs 1 - [doc] rustc (book) - [doc] rustc (book) - [doc] cargo (book) - [doc] cargo (book) - [doc] clippy (book) - [doc] clippy (book) - [doc] embedded-book (book) - [doc] embedded-book (book) - [doc] edition-guide (book) - [doc] edition-guide (book) - [doc] style-guide (book) - [doc] style-guide (book) - [doc] rustc 1 -> releases 2 - [doc] rustc 1 -> releases 2 - [build] rustc 0 -> RustInstaller 1 - [dist] docs - [dist] docs - [doc] rustc 1 -> std 1 crates=[] - [dist] rustc 1 -> json-docs 2 - [doc] rustc 1 -> std 1 crates=[] - [dist] rustc 1 -> json-docs 2 - [dist] mingw - [dist] mingw - [build] rustdoc 2 - [build] rustc 0 -> GenerateCopyright 1 - [dist] rustc - [build] rustdoc 2 - [dist] rustc - [dist] rustc 1 -> std 1 - [dist] rustc 1 -> std 1 - [dist] rustc 1 -> rustc-dev 2 - [dist] rustc 1 -> rustc-dev 2 - [dist] src <> - [dist] reproducible-artifacts - [dist] reproducible-artifacts - " - ); - } - - #[test] - fn dist_with_empty_host() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx - .config("dist") - .hosts(&[]) - .targets(&[TEST_TRIPLE_1]) - .render_steps(), @r" - [build] rustc 0 -> UnstableBookGen 1 - [build] rustc 0 -> Rustbook 1 - [doc] unstable-book (book) - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [doc] book (book) - [doc] book/first-edition (book) - [doc] book/second-edition (book) - [doc] book/2018-edition (book) - [build] rustdoc 1 - [build] rustc 1 -> std 1 - [doc] rustc 1 -> standalone 2 - [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - [doc] nomicon (book) - [doc] rustc 1 -> reference (book) 2 - [doc] rustdoc (book) - [doc] rust-by-example (book) - [doc] cargo (book) - [doc] clippy (book) - [doc] embedded-book (book) - [doc] edition-guide (book) - [doc] style-guide (book) - [doc] rustc 1 -> releases 2 - [build] rustc 0 -> RustInstaller 1 - [dist] docs - [doc] rustc 1 -> std 1 crates=[] - [dist] rustc 1 -> json-docs 2 - [dist] mingw - [dist] rustc 1 -> std 1 - "); - } - - #[test] - fn dist_all_cross_extended() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx - .config("dist") - .hosts(&[TEST_TRIPLE_1]) - .targets(&[TEST_TRIPLE_1]) - .args(&["--set", "rust.channel=nightly", "--set", "build.extended=true"]) - .render_steps(), @r" - [build] rustc 0 -> UnstableBookGen 1 - [build] rustc 0 -> Rustbook 1 - [doc] unstable-book (book) - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 0 -> WasmComponentLd 1 - [build] rustc 1 -> std 1 - [doc] book (book) - [doc] book/first-edition (book) - [doc] book/second-edition (book) - [doc] book/2018-edition (book) - [build] rustdoc 1 - [build] rustc 1 -> std 1 - [doc] rustc 1 -> standalone 2 - [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - [build] llvm - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> WasmComponentLd 2 - [build] rustc 1 -> error-index 2 - [doc] rustc 1 -> error-index 2 - [doc] nomicon (book) - [doc] rustc 1 -> reference (book) 2 - [doc] rustdoc (book) - [doc] rust-by-example (book) - [build] rustc 0 -> LintDocs 1 - [doc] rustc (book) - [doc] cargo (book) - [doc] clippy (book) - [doc] embedded-book (book) - [doc] edition-guide (book) - [doc] style-guide (book) - [doc] rustc 1 -> releases 2 - [build] rustc 0 -> RustInstaller 1 - [dist] docs - [doc] rustc 1 -> std 1 crates=[] - [dist] rustc 1 -> json-docs 2 - [dist] mingw - [build] rustdoc 2 - [build] rustc 1 -> rust-analyzer-proc-macro-srv 2 - [build] rustc 0 -> GenerateCopyright 1 - [dist] rustc - [dist] rustc 1 -> std 1 - [dist] rustc 1 -> rustc-dev 2 - [dist] rustc 1 -> analysis 2 - [dist] src <> - [build] rustc 1 -> cargo 2 - [dist] rustc 1 -> cargo 2 - [build] rustc 1 -> rust-analyzer 2 - [dist] rustc 1 -> rust-analyzer 2 - [build] rustc 1 -> rustfmt 2 - [build] rustc 1 -> cargo-fmt 2 - [dist] rustc 1 -> rustfmt 2 - [build] rustc 1 -> clippy-driver 2 - [build] rustc 1 -> cargo-clippy 2 - [dist] rustc 1 -> clippy 2 - [build] rustc 1 -> miri 2 - [build] rustc 1 -> cargo-miri 2 - [dist] rustc 1 -> miri 2 - [build] rustc 1 -> LlvmBitcodeLinker 2 - [doc] rustc 2 -> std 2 crates=[] - [dist] rustc 2 -> json-docs 3 - [dist] rustc 1 -> extended 2 - [dist] reproducible-artifacts - "); - } - - /// Simulates e.g. the powerpc64 builder, which is fully cross-compiled from x64, but it does - /// not build docs. Crucially, it shouldn't build host stage 2 rustc. - /// - /// This is a regression test for - /// and . - #[test] - fn dist_all_cross_extended_no_docs() { - let ctx = TestCtx::new(); - let steps = ctx - .config("dist") - .hosts(&[TEST_TRIPLE_1]) - .targets(&[TEST_TRIPLE_1]) - .args(&[ - "--set", - "rust.channel=nightly", - "--set", - "build.extended=true", - "--set", - "build.docs=false", - ]) - .get_steps(); - - // Make sure that we don't build stage2 host rustc - steps.assert_no_match(|m| { - m.name == "rustc" - && m.built_by.map(|b| b.stage) == Some(1) - && *m.target.triple == host_target() - }); - - insta::assert_snapshot!( - steps.render(), @r" - [dist] mingw - [build] llvm - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 0 -> WasmComponentLd 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> WasmComponentLd 2 - [build] rustdoc 2 - [build] rustc 1 -> rust-analyzer-proc-macro-srv 2 - [build] rustc 0 -> GenerateCopyright 1 - [build] rustc 0 -> RustInstaller 1 - [dist] rustc - [dist] rustc 1 -> std 1 - [dist] rustc 1 -> rustc-dev 2 - [dist] rustc 1 -> analysis 2 - [dist] src <> - [build] rustc 1 -> cargo 2 - [dist] rustc 1 -> cargo 2 - [build] rustc 1 -> rust-analyzer 2 - [dist] rustc 1 -> rust-analyzer 2 - [build] rustc 1 -> rustfmt 2 - [build] rustc 1 -> cargo-fmt 2 - [dist] rustc 1 -> rustfmt 2 - [build] rustc 1 -> clippy-driver 2 - [build] rustc 1 -> cargo-clippy 2 - [dist] rustc 1 -> clippy 2 - [build] rustc 1 -> miri 2 - [build] rustc 1 -> cargo-miri 2 - [dist] rustc 1 -> miri 2 - [build] rustc 1 -> LlvmBitcodeLinker 2 - [dist] rustc 1 -> extended 2 - [dist] reproducible-artifacts - "); - } - - /// Enable dist cranelift tarball by default with `x dist` if cranelift is enabled in - /// `rust.codegen-backends`. - #[test] - fn dist_cranelift_by_default() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx - .config("dist") - .args(&["--set", "rust.codegen-backends=['llvm', 'cranelift']"]) - .render_steps(), @r" - [build] rustc 0 -> UnstableBookGen 1 - [build] rustc 0 -> Rustbook 1 - [doc] unstable-book (book) - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 0 -> rustc_codegen_cranelift 1 - [build] rustc 1 -> std 1 - [doc] book (book) - [doc] book/first-edition (book) - [doc] book/second-edition (book) - [doc] book/2018-edition (book) - [build] rustdoc 1 - [doc] rustc 1 -> standalone 2 - [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> rustc_codegen_cranelift 2 - [build] rustc 1 -> error-index 2 - [doc] rustc 1 -> error-index 2 - [doc] nomicon (book) - [doc] rustc 1 -> reference (book) 2 - [doc] rustdoc (book) - [doc] rust-by-example (book) - [build] rustc 0 -> LintDocs 1 - [doc] rustc (book) - [doc] cargo (book) - [doc] clippy (book) - [doc] embedded-book (book) - [doc] edition-guide (book) - [doc] style-guide (book) - [doc] rustc 1 -> releases 2 - [build] rustc 0 -> RustInstaller 1 - [dist] docs - [doc] rustc 1 -> std 1 crates=[] - [dist] rustc 1 -> json-docs 2 - [dist] mingw - [build] rustdoc 2 - [build] rustc 0 -> GenerateCopyright 1 - [dist] rustc - [dist] rustc 1 -> rustc_codegen_cranelift 2 - [dist] rustc 1 -> std 1 - [dist] rustc 1 -> rustc-dev 2 - [dist] src <> - [dist] reproducible-artifacts - "); - } - - #[test] - fn dist_bootstrap() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx - .config("dist") - .path("bootstrap") - .render_steps(), @r" - [build] rustc 0 -> RustInstaller 1 - [dist] bootstrap - "); - } - - #[test] - fn dist_library_stage_0_local_rebuild() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("dist") - .path("rust-std") - .stage(0) - .targets(&[TEST_TRIPLE_1]) - .args(&["--set", "build.local-rebuild=true"]) - .render_steps(), @r" - [build] rustc 0 -> std 0 - [build] rustc 0 -> RustInstaller 1 - [dist] rustc 0 -> std 0 - "); - } - - #[test] - fn dist_rustc_docs() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx - .config("dist") - .path("rustc-docs") - .render_steps(), @r" - [build] rustc 0 -> UnstableBookGen 1 - [build] rustc 0 -> Rustbook 1 - [doc] unstable-book (book) - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [doc] book (book) - [doc] book/first-edition (book) - [doc] book/second-edition (book) - [doc] book/2018-edition (book) - [build] rustdoc 1 - [doc] rustc 1 -> standalone 2 - [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> error-index 2 - [doc] rustc 1 -> error-index 2 - [doc] nomicon (book) - [doc] rustc 1 -> reference (book) 2 - [doc] rustdoc (book) - [doc] rust-by-example (book) - [build] rustc 0 -> LintDocs 1 - [doc] rustc (book) - [doc] cargo (book) - [doc] clippy (book) - [doc] embedded-book (book) - [doc] edition-guide (book) - [doc] style-guide (book) - [doc] rustc 1 -> releases 2 - [build] rustc 0 -> RustInstaller 1 - "); - } - - #[test] - fn check_compiler_no_explicit_stage() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("check") - .path("compiler") - .render_steps(), @"[check] rustc 0 -> rustc 1 (75 crates)"); - } - - #[test] - fn check_rustc_no_explicit_stage() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("check") - .path("rustc") - .render_steps(), @"[check] rustc 0 -> rustc 1 (1 crates)"); - } - - #[test] - #[should_panic] - fn check_compiler_stage_0() { - let ctx = TestCtx::new(); - ctx.config("check").path("compiler").stage(0).run(); - } - - #[test] - fn check_compiler_stage_1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("check") - .path("compiler") - .stage(1) - .render_steps(), @"[check] rustc 0 -> rustc 1 (75 crates)"); - } - - #[test] - fn check_compiler_stage_2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("check") - .path("compiler") - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [check] rustc 1 -> rustc 2 (75 crates) - "); - } - - #[test] - fn check_cross_compile() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("check") - .targets(&[TEST_TRIPLE_1]) - .hosts(&[TEST_TRIPLE_1]) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [check] rustc 1 -> std 1 - [check] rustc 1 -> rustc 2 (75 crates) - [check] rustc 1 -> rustc 2 - [check] rustc 1 -> Rustdoc 2 - [check] rustc 1 -> rustc_codegen_cranelift 2 - [check] rustc 1 -> rustc_codegen_gcc 2 - [check] rustc 1 -> Clippy 2 - [check] rustc 1 -> Miri 2 - [check] rustc 1 -> CargoMiri 2 - [check] rustc 1 -> Rustfmt 2 - [check] rustc 1 -> RustAnalyzer 2 - [check] rustc 1 -> TestFloatParse 2 - [check] rustc 1 -> std 1 - "); - } - - #[test] - fn check_library_no_explicit_stage() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("check") - .path("library") - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [check] rustc 1 -> std 1 - "); - } - - #[test] - #[should_panic] - fn check_library_stage_0() { - let ctx = TestCtx::new(); - ctx.config("check").path("library").stage(0).run(); - } - - #[test] - fn check_library_stage_1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("check") - .path("library") - .stage(1) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [check] rustc 1 -> std 1 - "); - } - - #[test] - fn check_library_stage_2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("check") - .path("library") - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [check] rustc 2 -> std 2 - "); - } - - #[test] - fn check_library_cross_compile() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("check") - .paths(&["core", "alloc", "std"]) - .targets(&[TEST_TRIPLE_1, TEST_TRIPLE_2]) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [check] rustc 1 -> std 1 - [check] rustc 1 -> std 1 - "); - } - - /// Make sure that we don't check library when download-rustc is disabled - /// when `--skip-std-check-if-no-download-rustc` was passed. - #[test] - fn check_library_skip_without_download_rustc() { - let ctx = TestCtx::new(); - let args = ["--set", "rust.download-rustc=false", "--skip-std-check-if-no-download-rustc"]; - insta::assert_snapshot!( - ctx.config("check") - .paths(&["library"]) - .args(&args) - .render_steps(), @""); - - insta::assert_snapshot!( - ctx.config("check") - .paths(&["library", "compiler"]) - .args(&args) - .render_steps(), @"[check] rustc 0 -> rustc 1 (75 crates)"); - } - - #[test] - fn check_miri_no_explicit_stage() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("check") - .path("miri") - .render_steps(), @r" - [check] rustc 0 -> rustc 1 - [check] rustc 0 -> Miri 1 - "); - } - - #[test] - #[should_panic] - fn check_miri_stage_0() { - let ctx = TestCtx::new(); - ctx.config("check").path("miri").stage(0).run(); - } - - #[test] - fn check_miri_stage_1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("check") - .path("miri") - .stage(1) - .render_steps(), @r" - [check] rustc 0 -> rustc 1 - [check] rustc 0 -> Miri 1 - "); - } - - #[test] - fn check_miri_stage_2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("check") - .path("miri") - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [check] rustc 1 -> rustc 2 - [check] rustc 1 -> Miri 2 - "); - } - - #[test] - fn check_compiletest() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("check") - .path("compiletest") - .render_steps(), @"[check] rustc 0 -> Compiletest 1 "); - } - - #[test] - fn check_compiletest_stage1_libtest() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("check") - .path("compiletest") - .args(&["--set", "build.compiletest-use-stage0-libtest=false"]) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [check] rustc 1 -> Compiletest 2 - "); - } - - #[test] - fn check_codegen() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("check") - .path("rustc_codegen_cranelift") - .render_steps(), @r" - [check] rustc 0 -> rustc 1 - [check] rustc 0 -> rustc_codegen_cranelift 1 - "); - } - - #[test] - fn check_rust_analyzer() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("check") - .path("rust-analyzer") - .render_steps(), @r" - [check] rustc 0 -> rustc 1 - [check] rustc 0 -> RustAnalyzer 1 - "); - } - - #[test] - fn check_bootstrap_tool() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("check") - .path("run-make-support") - .render_steps(), @"[check] rustc 0 -> RunMakeSupport 1 "); - } - - fn prepare_test_config(ctx: &TestCtx) -> ConfigBuilder { - ctx.config("test") - // Bootstrap only runs by default on CI, so we have to emulate that also locally. - .args(&["--ci", "true"]) - // These rustdoc tests requires nodejs to be present. - // We can't easily opt out of it, so if it is present on the local PC, the test - // would have different result on CI, where nodejs might be missing. - .args(&["--skip", "rustdoc-js-std"]) - .args(&["--skip", "rustdoc-js"]) - .args(&["--skip", "rustdoc-gui"]) - } - - #[test] - fn test_all_stage_1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - prepare_test_config(&ctx) - .render_steps(), @r" - [build] rustc 0 -> Tidy 1 - [test] tidy <> - [build] rustdoc 0 - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 0 -> Compiletest 1 - [test] compiletest-ui 1 - [test] compiletest-crashes 1 - [build] rustc 0 -> CoverageDump 1 - [test] compiletest-coverage 1 - [test] compiletest-coverage 1 - [build] rustc 1 -> std 1 - [test] compiletest-mir-opt 1 - [test] compiletest-codegen-llvm 1 - [test] compiletest-codegen-units 1 - [test] compiletest-assembly-llvm 1 - [test] compiletest-incremental 1 - [test] compiletest-debuginfo 1 - [test] compiletest-ui-fulldeps 1 - [build] rustdoc 1 - [test] compiletest-rustdoc 1 - [test] compiletest-coverage-run-rustdoc 1 - [test] compiletest-pretty 1 - [build] rustc 1 -> std 1 - [build] rustc 0 -> std 0 - [test] rustc 0 -> CrateLibrustc 1 - [build] rustc 1 -> rustc 2 - [test] crate-bootstrap src/tools/coverage-dump - [test] crate-bootstrap src/tools/jsondoclint - [test] crate-bootstrap src/tools/replace-version-placeholder - [test] crate-bootstrap tidyselftest - [build] rustc 0 -> UnstableBookGen 1 - [build] rustc 0 -> Rustbook 1 - [doc] unstable-book (book) - [doc] book (book) - [doc] book/first-edition (book) - [doc] book/second-edition (book) - [doc] book/2018-edition (book) - [doc] rustc 0 -> standalone 1 - [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - [build] rustc 0 -> error-index 1 - [doc] rustc 0 -> error-index 1 - [doc] nomicon (book) - [doc] rustc 1 -> reference (book) 2 - [doc] rustdoc (book) - [doc] rust-by-example (book) - [build] rustc 0 -> LintDocs 1 - [doc] rustc (book) - [doc] cargo (book) - [doc] clippy (book) - [doc] embedded-book (book) - [doc] edition-guide (book) - [doc] style-guide (book) - [doc] rustc 0 -> releases 1 - [build] rustc 0 -> Linkchecker 1 - [test] link-check - [test] tier-check - [test] rustc 0 -> rust-analyzer 1 - [build] rustc 0 -> RustdocTheme 1 - [test] rustdoc-theme 1 - [test] compiletest-rustdoc-ui 1 - [build] rustc 0 -> JsonDocCk 1 - [build] rustc 0 -> JsonDocLint 1 - [test] compiletest-rustdoc-json 1 - [doc] rustc 0 -> rustc 1 - [build] rustc 0 -> HtmlChecker 1 - [test] html-check - [build] rustc 0 -> RunMakeSupport 1 - [test] compiletest-run-make 1 - [build] rustc 0 -> cargo 1 - [test] compiletest-run-make-cargo 1 - "); - } - - #[test] - fn test_compiletest_suites_stage1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("test") - .args(&["ui", "ui-fulldeps", "run-make", "rustdoc", "rustdoc-gui", "incremental"]) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 0 -> Compiletest 1 - [test] compiletest-ui 1 - [test] compiletest-ui-fulldeps 1 - [build] rustc 0 -> RunMakeSupport 1 - [build] rustdoc 1 - [test] compiletest-run-make 1 - [test] compiletest-rustdoc 1 - [build] rustc 0 -> RustdocGUITest 1 - [test] rustdoc-gui 1 - [test] compiletest-incremental 1 - [build] rustc 1 -> rustc 2 - "); - } - - #[test] - fn test_compiletest_suites_stage2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("test") - .args(&["ui", "ui-fulldeps", "run-make", "rustdoc", "rustdoc-gui", "incremental"]) - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [build] rustc 2 -> std 2 - [build] rustc 0 -> Compiletest 1 - [test] compiletest-ui 2 - [build] rustc 2 -> rustc 3 - [test] compiletest-ui-fulldeps 2 - [build] rustc 0 -> RunMakeSupport 1 - [build] rustdoc 2 - [test] compiletest-run-make 2 - [test] compiletest-rustdoc 2 - [build] rustc 0 -> RustdocGUITest 1 - [test] rustdoc-gui 2 - [test] compiletest-incremental 2 - [build] rustdoc 1 - "); - } - - #[test] - fn test_compiletest_suites_stage2_cross() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("test") - .hosts(&[TEST_TRIPLE_1]) - .targets(&[TEST_TRIPLE_1]) - .args(&["ui", "ui-fulldeps", "run-make", "rustdoc", "rustdoc-gui", "incremental"]) - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [build] rustc 2 -> std 2 - [build] rustc 0 -> Compiletest 1 - [build] rustc 1 -> std 1 - [build] rustc 2 -> std 2 - [test] compiletest-ui 2 - [build] llvm - [build] rustc 2 -> rustc 3 - [test] compiletest-ui-fulldeps 2 - [build] rustc 0 -> RunMakeSupport 1 - [build] rustdoc 2 - [test] compiletest-run-make 2 - [test] compiletest-rustdoc 2 - [build] rustc 0 -> RustdocGUITest 1 - [test] rustdoc-gui 2 - [test] compiletest-incremental 2 - [build] rustc 1 -> rustc 2 - [build] rustdoc 1 - [build] rustc 2 -> std 2 - [build] rustdoc 2 - "); - } - - #[test] - fn test_all_stage_2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - prepare_test_config(&ctx) - .stage(2) - .render_steps(), @r" - [build] rustc 0 -> Tidy 1 - [test] tidy <> - [build] rustdoc 0 - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [build] rustc 2 -> std 2 - [build] rustc 0 -> Compiletest 1 - [test] compiletest-ui 2 - [test] compiletest-crashes 2 - [build] rustc 0 -> CoverageDump 1 - [test] compiletest-coverage 2 - [test] compiletest-coverage 2 - [build] rustc 2 -> std 2 - [test] compiletest-mir-opt 2 - [test] compiletest-codegen-llvm 2 - [test] compiletest-codegen-units 2 - [test] compiletest-assembly-llvm 2 - [test] compiletest-incremental 2 - [test] compiletest-debuginfo 2 - [build] rustc 2 -> rustc 3 - [test] compiletest-ui-fulldeps 2 - [build] rustdoc 2 - [test] compiletest-rustdoc 2 - [test] compiletest-coverage-run-rustdoc 2 - [test] compiletest-pretty 2 - [build] rustc 2 -> std 2 - [build] rustc 1 -> std 1 - [build] rustdoc 1 - [test] rustc 1 -> CrateLibrustc 2 - [test] crate-bootstrap src/tools/coverage-dump - [test] crate-bootstrap src/tools/jsondoclint - [test] crate-bootstrap src/tools/replace-version-placeholder - [test] crate-bootstrap tidyselftest - [build] rustc 0 -> UnstableBookGen 1 - [build] rustc 0 -> Rustbook 1 - [doc] unstable-book (book) - [doc] book (book) - [doc] book/first-edition (book) - [doc] book/second-edition (book) - [doc] book/2018-edition (book) - [doc] rustc 1 -> standalone 2 - [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - [build] rustc 1 -> error-index 2 - [doc] rustc 1 -> error-index 2 - [doc] nomicon (book) - [doc] rustc 1 -> reference (book) 2 - [doc] rustdoc (book) - [doc] rust-by-example (book) - [build] rustc 0 -> LintDocs 1 - [doc] rustc (book) - [doc] cargo (book) - [doc] clippy (book) - [doc] embedded-book (book) - [doc] edition-guide (book) - [doc] style-guide (book) - [doc] rustc 1 -> releases 2 - [build] rustc 0 -> Linkchecker 1 - [test] link-check - [test] tier-check - [test] rustc 1 -> rust-analyzer 2 - [doc] rustc (book) - [test] rustc 1 -> lint-docs 2 - [build] rustc 0 -> RustdocTheme 1 - [test] rustdoc-theme 2 - [test] compiletest-rustdoc-ui 2 - [build] rustc 0 -> JsonDocCk 1 - [build] rustc 0 -> JsonDocLint 1 - [test] compiletest-rustdoc-json 2 - [doc] rustc 1 -> rustc 2 - [build] rustc 0 -> HtmlChecker 1 - [test] html-check - [build] rustc 0 -> RunMakeSupport 1 - [test] compiletest-run-make 2 - [build] rustc 1 -> cargo 2 - [test] compiletest-run-make-cargo 2 - "); - } - - #[test] - fn test_compiler_stage_1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("test") - .path("compiler") - .stage(1) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 0 -> std 0 - [build] rustdoc 0 - [test] rustc 0 -> CrateLibrustc 1 - "); - } - - #[test] - fn test_compiler_stage_2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("test") - .path("compiler") - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> std 1 - [build] rustdoc 1 - [test] rustc 1 -> CrateLibrustc 2 - "); - } - - #[test] - fn test_exclude() { - let ctx = TestCtx::new(); - let steps = ctx.config("test").args(&["--skip", "src/tools/tidy"]).get_steps(); - - let host = TargetSelection::from_user(&host_target()); - steps.assert_contains(StepMetadata::test("compiletest-rustdoc-ui", host).stage(1)); - steps.assert_not_contains(test::Tidy); - } - - #[test] - fn test_exclude_kind() { - let ctx = TestCtx::new(); - let host = TargetSelection::from_user(&host_target()); - - let get_steps = |args: &[&str]| ctx.config("test").args(args).get_steps(); - - let rustc_metadata = - || StepMetadata::test("CrateLibrustc", host).built_by(Compiler::new(0, host)); - // Ensure our test is valid, and `test::Rustc` would be run without the exclude. - get_steps(&[]).assert_contains(rustc_metadata()); - - let steps = get_steps(&["--skip", "compiler/rustc_data_structures"]); - - // Ensure tests for rustc are not skipped. - steps.assert_contains(rustc_metadata()); - steps.assert_contains_fuzzy(StepMetadata::build("rustc", host)); - } - - #[test] - fn test_cargo_stage_1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("test") - .path("cargo") - .render_steps(), @r" - [build] rustc 0 -> cargo 1 - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustdoc 1 - [build] rustdoc 0 - [test] rustc 0 -> cargo 1 - "); - } - - #[test] - fn test_cargo_stage_2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("test") - .path("cargo") - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> cargo 2 - [build] rustc 1 -> rustc 2 - [build] rustc 2 -> std 2 - [build] rustdoc 2 - [build] rustdoc 1 - [test] rustc 1 -> cargo 2 - "); - } - - #[test] - fn test_cargotest() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("test") - .path("cargotest") - .render_steps(), @r" - [build] rustc 0 -> cargo 1 - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 0 -> CargoTest 1 - [build] rustdoc 1 - [test] cargotest 1 - "); - } - - #[test] - fn test_tier_check() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("test") - .path("tier-check") - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [test] tier-check - "); - } - - // Differential snapshots for `./x test run-make` run `./x test run-make-cargo`: only - // `run-make-cargo` should build an in-tree cargo, running `./x test run-make` should not. - #[test] - fn test_run_make_no_cargo() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("test") - .path("run-make") - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 0 -> RunMakeSupport 1 - [build] rustc 1 -> std 1 - [build] rustc 0 -> Compiletest 1 - [build] rustdoc 1 - [test] compiletest-run-make 1 - "); - } - - #[test] - fn test_run_make_cargo_builds_cargo() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("test") - .path("run-make-cargo") - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 0 -> RunMakeSupport 1 - [build] rustc 1 -> std 1 - [build] rustc 0 -> Compiletest 1 - [build] rustc 0 -> cargo 1 - [build] rustdoc 1 - [test] compiletest-run-make-cargo 1 - "); - } - - #[test] - fn doc_all() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("doc") - .render_steps(), @r" - [build] rustc 0 -> UnstableBookGen 1 - [build] rustc 0 -> Rustbook 1 - [doc] unstable-book (book) - [doc] book (book) - [doc] book/first-edition (book) - [doc] book/second-edition (book) - [doc] book/2018-edition (book) - [build] rustdoc 0 - [doc] rustc 0 -> standalone 1 - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustdoc 1 - [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - [build] rustc 0 -> error-index 1 - [doc] rustc 0 -> error-index 1 - [doc] nomicon (book) - [build] rustc 1 -> std 1 - [doc] rustc 1 -> reference (book) 2 - [doc] rustdoc (book) - [doc] rust-by-example (book) - [build] rustc 0 -> LintDocs 1 - [doc] rustc (book) - [doc] cargo (book) - [doc] clippy (book) - [doc] embedded-book (book) - [doc] edition-guide (book) - [doc] style-guide (book) - [doc] rustc 0 -> releases 1 - "); - } - - #[test] - fn doc_library() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("doc") - .path("library") - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustdoc 1 - [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - "); - } - - #[test] - fn doc_cargo_stage_1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("doc") - .path("cargo") - .render_steps(), @r" - [build] rustdoc 0 - [doc] rustc 0 -> Cargo 1 - "); - } - #[test] - fn doc_cargo_stage_2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("doc") - .path("cargo") - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustdoc 1 - [doc] rustc 1 -> Cargo 2 - "); - } - - #[test] - fn doc_core() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("doc") - .path("core") - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustdoc 1 - [doc] rustc 1 -> std 1 crates=[core] - "); - } - - #[test] - fn doc_core_no_std_target() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("doc") - .path("core") - .override_target_no_std(&host_target()) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustdoc 1 - [doc] rustc 1 -> std 1 crates=[core] - "); - } - - #[test] - fn doc_library_no_std_target() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("doc") - .path("library") - .override_target_no_std(&host_target()) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustdoc 1 - [doc] rustc 1 -> std 1 crates=[alloc,core] - "); - } - - #[test] - fn doc_library_no_std_target_cross_compile() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("doc") - .path("library") - .targets(&[TEST_TRIPLE_1]) - .override_target_no_std(TEST_TRIPLE_1) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustdoc 1 - [doc] rustc 1 -> std 1 crates=[alloc,core] - "); - } - - #[test] - #[should_panic] - fn doc_compiler_stage_0() { - let ctx = TestCtx::new(); - ctx.config("doc").path("compiler").stage(0).run(); - } - - #[test] - fn doc_compiler_stage_1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("doc") - .path("compiler") - .stage(1) - .render_steps(), @r" - [build] rustdoc 0 - [build] llvm - [doc] rustc 0 -> rustc 1 - "); - } - - #[test] - fn doc_compiler_stage_2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("doc") - .path("compiler") - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustdoc 1 - [doc] rustc 1 -> rustc 2 - "); - } - - #[test] - #[should_panic] - fn doc_compiletest_stage_0() { - let ctx = TestCtx::new(); - ctx.config("doc").path("src/tools/compiletest").stage(0).run(); - } - - #[test] - fn doc_compiletest_stage_1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("doc") - .path("src/tools/compiletest") - .stage(1) - .render_steps(), @r" - [build] rustdoc 0 - [doc] rustc 0 -> Compiletest 1 - "); - } - - #[test] - fn doc_compiletest_stage_2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("doc") - .path("src/tools/compiletest") - .stage(2) - .render_steps(), @r" - [build] rustdoc 0 - [doc] rustc 0 -> Compiletest 1 - "); - } - - // Reference should be auto-bumped to stage 2. - #[test] - fn doc_reference() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("doc") - .path("reference") - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 0 -> Rustbook 1 - [doc] rustc 1 -> reference (book) 2 - "); - } - - #[test] - fn clippy_ci() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("clippy") - .path("ci") - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 0 -> clippy-driver 1 - [build] rustc 0 -> cargo-clippy 1 - [clippy] rustc 1 -> bootstrap 2 - [clippy] rustc 1 -> std 1 - [clippy] rustc 1 -> rustc 2 - [check] rustc 1 -> rustc 2 - [clippy] rustc 1 -> rustc_codegen_gcc 2 - "); - } - - #[test] - fn clippy_compiler_stage1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("clippy") - .path("compiler") - .render_steps(), @r" - [build] llvm - [clippy] rustc 0 -> rustc 1 - "); - } - - #[test] - fn clippy_compiler_stage2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("clippy") - .path("compiler") - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 0 -> clippy-driver 1 - [build] rustc 0 -> cargo-clippy 1 - [clippy] rustc 1 -> rustc 2 - "); - } - - #[test] - fn clippy_std_stage1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("clippy") - .path("std") - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 0 -> clippy-driver 1 - [build] rustc 0 -> cargo-clippy 1 - [clippy] rustc 1 -> std 1 - "); - } - - #[test] - fn clippy_std_stage2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("clippy") - .path("std") - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> clippy-driver 2 - [build] rustc 1 -> cargo-clippy 2 - [clippy] rustc 2 -> std 2 - "); - } - - #[test] - fn clippy_miri_stage1() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("clippy") - .path("miri") - .stage(1) - .render_steps(), @r" - [build] llvm - [check] rustc 0 -> rustc 1 - [clippy] rustc 0 -> miri 1 - "); - } - - #[test] - fn clippy_miri_stage2() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("clippy") - .path("miri") - .stage(2) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 1 -> std 1 - [check] rustc 1 -> rustc 2 - [build] rustc 0 -> clippy-driver 1 - [build] rustc 0 -> cargo-clippy 1 - [clippy] rustc 1 -> miri 2 - "); - } - - #[test] - fn clippy_bootstrap() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("clippy") - .path("bootstrap") - .render_steps(), @"[clippy] rustc 0 -> bootstrap 1 "); - } - - #[test] - fn install_extended() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("install") - .args(&[ - // Using backslashes fails with `--set` - "--set", &format!("install.prefix={}", ctx.dir().display()).replace("\\", "/"), - "--set", &format!("install.sysconfdir={}", ctx.dir().display()).replace("\\", "/"), - "--set", "build.extended=true" - ]) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 0 -> WasmComponentLd 1 - [build] rustc 0 -> UnstableBookGen 1 - [build] rustc 0 -> Rustbook 1 - [doc] unstable-book (book) - [build] rustc 1 -> std 1 - [doc] book (book) - [doc] book/first-edition (book) - [doc] book/second-edition (book) - [doc] book/2018-edition (book) - [build] rustdoc 1 - [doc] rustc 1 -> standalone 2 - [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] - [build] rustc 1 -> rustc 2 - [build] rustc 1 -> WasmComponentLd 2 - [build] rustc 1 -> error-index 2 - [doc] rustc 1 -> error-index 2 - [doc] nomicon (book) - [doc] rustc 1 -> reference (book) 2 - [doc] rustdoc (book) - [doc] rust-by-example (book) - [build] rustc 0 -> LintDocs 1 - [doc] rustc (book) - [doc] cargo (book) - [doc] clippy (book) - [doc] embedded-book (book) - [doc] edition-guide (book) - [doc] style-guide (book) - [doc] rustc 1 -> releases 2 - [build] rustc 0 -> RustInstaller 1 - [dist] docs - [dist] rustc 1 -> std 1 - [build] rustdoc 2 - [build] rustc 1 -> rust-analyzer-proc-macro-srv 2 - [build] rustc 0 -> GenerateCopyright 1 - [dist] rustc - [build] rustc 1 -> cargo 2 - [dist] rustc 1 -> cargo 2 - [build] rustc 1 -> rust-analyzer 2 - [dist] rustc 1 -> rust-analyzer 2 - [build] rustc 1 -> rustfmt 2 - [build] rustc 1 -> cargo-fmt 2 - [dist] rustc 1 -> rustfmt 2 - [build] rustc 1 -> clippy-driver 2 - [build] rustc 1 -> cargo-clippy 2 - [dist] rustc 1 -> clippy 2 - [build] rustc 1 -> miri 2 - [build] rustc 1 -> cargo-miri 2 - [dist] rustc 1 -> miri 2 - [dist] src <> - "); - } - - // Check that `x run miri --target FOO` actually builds miri for the host. - #[test] - fn run_miri() { - let ctx = TestCtx::new(); - insta::assert_snapshot!( - ctx.config("run") - .path("miri") - .stage(1) - .targets(&[TEST_TRIPLE_1]) - .render_steps(), @r" - [build] llvm - [build] rustc 0 -> rustc 1 - [build] rustc 0 -> miri 1 - [build] rustc 0 -> cargo-miri 1 - [run] rustc 0 -> miri 1 - "); - } -} - struct ExecutedSteps { steps: Vec, } diff --git a/src/bootstrap/src/core/builder/tests/snapshot.rs b/src/bootstrap/src/core/builder/tests/snapshot.rs new file mode 100644 index 0000000000000..b7062f383009b --- /dev/null +++ b/src/bootstrap/src/core/builder/tests/snapshot.rs @@ -0,0 +1,2416 @@ +//! These tests use insta for snapshot testing. +//! See bootstrap's README on how to bless the snapshots. + +use std::path::PathBuf; + +use crate::core::build_steps::{compile, dist, doc, test, tool}; +use crate::core::builder::tests::{ + RenderConfig, TEST_TRIPLE_1, TEST_TRIPLE_2, TEST_TRIPLE_3, configure, first, host_target, + render_steps, run_build, +}; +use crate::core::builder::{Builder, Kind, StepDescription, StepMetadata}; +use crate::core::config::TargetSelection; +use crate::core::config::toml::rust::with_lld_opt_in_targets; +use crate::utils::cache::Cache; +use crate::utils::helpers::get_host_target; +use crate::utils::tests::{ConfigBuilder, TestCtx}; +use crate::{Build, Compiler, Config, Flags, Subcommand}; + +#[test] +fn build_default() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustdoc 1 + "); +} + +#[test] +fn build_cross_compile() { + let ctx = TestCtx::new(); + + insta::assert_snapshot!( + ctx.config("build") + // Cross-compilation fails on stage 1, as we don't have a stage0 std available + // for non-host targets. + .stage(2) + .hosts(&[&host_target(), TEST_TRIPLE_1]) + .targets(&[&host_target(), TEST_TRIPLE_1]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + [build] rustc 2 -> std 2 + [build] rustc 1 -> std 1 + [build] rustc 2 -> std 2 + [build] rustdoc 2 + [build] llvm + [build] rustc 1 -> rustc 2 + [build] rustdoc 2 + "); +} + +#[test] +fn build_with_empty_host() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx + .config("build") + .hosts(&[]) + .targets(&[TEST_TRIPLE_1]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + " + ); +} + +#[test] +fn build_compiler_no_explicit_stage() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("compiler") + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + "); +} + +#[test] +fn build_rustc_no_explicit_stage() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("rustc") + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + "); +} + +#[test] +#[should_panic] +fn build_compiler_stage_0() { + let ctx = TestCtx::new(); + ctx.config("build").path("compiler").stage(0).run(); +} + +#[test] +fn build_compiler_stage_1() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("compiler") + .stage(1) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + "); +} + +#[test] +fn build_compiler_stage_2() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("compiler") + .stage(2) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + "); +} + +#[test] +fn build_compiler_stage_3() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("compiler") + .stage(3) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + [build] rustc 2 -> std 2 + [build] rustc 2 -> rustc 3 + "); +} + +#[test] +fn build_compiler_stage_3_cross() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("compiler") + .hosts(&[TEST_TRIPLE_1]) + .stage(3) + .render_steps(), @r" + [build] llvm + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + [build] rustc 1 -> std 1 + [build] rustc 2 -> std 2 + [build] rustc 2 -> std 2 + [build] rustc 2 -> rustc 3 + "); +} + +#[test] +fn build_compiler_stage_3_full_bootstrap() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("compiler") + .stage(3) + .args(&["--set", "build.full-bootstrap=true"]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + [build] rustc 2 -> std 2 + [build] rustc 2 -> rustc 3 + "); +} + +#[test] +fn build_compiler_stage_3_cross_full_bootstrap() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("compiler") + .stage(3) + .hosts(&[TEST_TRIPLE_1]) + .args(&["--set", "build.full-bootstrap=true"]) + .render_steps(), @r" + [build] llvm + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + [build] rustc 2 -> std 2 + [build] rustc 2 -> std 2 + [build] rustc 2 -> rustc 3 + "); +} + +#[test] +fn build_compiler_codegen_backend() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx + .config("build") + .args(&["--set", "rust.codegen-backends=['llvm', 'cranelift']"]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 0 -> rustc_codegen_cranelift 1 + [build] rustc 1 -> std 1 + [build] rustdoc 1 + " + ); +} + +#[test] +fn build_compiler_tools() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx + .config("build") + .stage(2) + .args(&["--set", "rust.lld=true", "--set", "rust.llvm-bitcode-linker=true"]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 0 -> LldWrapper 1 + [build] rustc 0 -> LlvmBitcodeLinker 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + [build] rustc 1 -> LldWrapper 2 + [build] rustc 1 -> LlvmBitcodeLinker 2 + [build] rustc 2 -> std 2 + [build] rustdoc 2 + " + ); +} + +#[test] +fn build_compiler_tools_cross() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx + .config("build") + .stage(2) + .args(&["--set", "rust.lld=true", "--set", "rust.llvm-bitcode-linker=true"]) + .hosts(&[TEST_TRIPLE_1]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 0 -> LldWrapper 1 + [build] rustc 0 -> LlvmBitcodeLinker 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + [build] rustc 1 -> LldWrapper 2 + [build] rustc 1 -> LlvmBitcodeLinker 2 + [build] rustc 1 -> std 1 + [build] rustc 2 -> std 2 + [build] llvm + [build] rustc 1 -> rustc 2 + [build] rustc 1 -> LldWrapper 2 + [build] rustc 1 -> LlvmBitcodeLinker 2 + [build] rustdoc 2 + " + ); +} + +#[test] +fn build_compiler_lld_opt_in() { + with_lld_opt_in_targets(vec![host_target()], || { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("compiler") + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 0 -> LldWrapper 1 + "); + }); +} + +#[test] +fn build_library_no_explicit_stage() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("library") + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + "); +} + +#[test] +#[should_panic] +fn build_library_stage_0() { + let ctx = TestCtx::new(); + ctx.config("build").path("library").stage(0).run(); +} + +#[test] +fn build_library_stage_0_local_rebuild() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("library") + .stage(0) + .targets(&[TEST_TRIPLE_1]) + .args(&["--set", "build.local-rebuild=true"]) + .render_steps(), @"[build] rustc 0 -> std 0 "); +} + +#[test] +fn build_library_stage_1() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("library") + .stage(1) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + "); +} + +#[test] +fn build_library_stage_2() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("library") + .stage(2) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + [build] rustc 2 -> std 2 + "); +} + +#[test] +fn build_miri_no_explicit_stage() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("miri") + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 0 -> miri 1 + "); +} + +#[test] +#[should_panic] +fn build_miri_stage_0() { + let ctx = TestCtx::new(); + ctx.config("build").path("miri").stage(0).run(); +} + +#[test] +fn build_miri_stage_1() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("miri") + .stage(1) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 0 -> miri 1 + "); +} + +#[test] +fn build_miri_stage_2() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("miri") + .stage(2) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + [build] rustc 1 -> miri 2 + "); +} + +#[test] +fn build_error_index() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("error_index_generator") + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 0 -> error-index 1 + "); +} + +#[test] +fn build_bootstrap_tool_no_explicit_stage() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("opt-dist") + .render_steps(), @"[build] rustc 0 -> OptimizedDist 1 "); +} + +#[test] +#[should_panic] +fn build_bootstrap_tool_stage_0() { + let ctx = TestCtx::new(); + ctx.config("build").path("opt-dist").stage(0).run(); +} + +#[test] +fn build_bootstrap_tool_stage_1() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("opt-dist") + .stage(1) + .render_steps(), @"[build] rustc 0 -> OptimizedDist 1 "); +} + +#[test] +fn build_bootstrap_tool_stage_2() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .path("opt-dist") + .stage(2) + .render_steps(), @"[build] rustc 0 -> OptimizedDist 1 "); +} + +#[test] +fn build_default_stage() { + let ctx = TestCtx::new(); + assert_eq!(ctx.config("build").path("compiler").create_config().stage, 1); +} + +/// Ensure that if someone passes both a single crate and `library`, all +/// library crates get built. +#[test] +fn alias_and_path_for_library() { + let ctx = TestCtx::new(); + insta::assert_snapshot!(ctx.config("build") + .paths(&["library", "core"]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + "); + + insta::assert_snapshot!(ctx.config("build") + .paths(&["std"]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + "); + + insta::assert_snapshot!(ctx.config("build") + .paths(&["core"]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + "); + + insta::assert_snapshot!(ctx.config("build") + .paths(&["alloc"]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + "); + + insta::assert_snapshot!(ctx.config("doc") + .paths(&["library", "core"]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustdoc 1 + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + "); +} + +#[test] +fn build_all() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .stage(2) + .paths(&["compiler/rustc", "library"]) + .hosts(&[&host_target(), TEST_TRIPLE_1]) + .targets(&[&host_target(), TEST_TRIPLE_1, TEST_TRIPLE_2]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + [build] llvm + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + [build] rustc 2 -> std 2 + [build] rustc 2 -> std 2 + [build] rustc 1 -> std 1 + [build] rustc 2 -> std 2 + "); +} + +#[test] +fn build_cargo() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .paths(&["cargo"]) + .render_steps(), @"[build] rustc 0 -> cargo 1 "); +} + +#[test] +fn build_cargo_cross() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("build") + .paths(&["cargo"]) + .hosts(&[TEST_TRIPLE_1]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> cargo 2 + "); +} + +#[test] +fn dist_default_stage() { + let ctx = TestCtx::new(); + assert_eq!(ctx.config("dist").path("compiler").create_config().stage, 2); +} + +#[test] +fn dist_baseline() { + let ctx = TestCtx::new(); + // Note that stdlib is uplifted, that is why `[dist] rustc 1 -> std ` is in + // the output. + insta::assert_snapshot!( + ctx + .config("dist") + .render_steps(), @r" + [build] rustc 0 -> UnstableBookGen 1 + [build] rustc 0 -> Rustbook 1 + [doc] unstable-book (book) + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [doc] book (book) + [doc] book/first-edition (book) + [doc] book/second-edition (book) + [doc] book/2018-edition (book) + [build] rustdoc 1 + [doc] rustc 1 -> standalone 2 + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [build] rustc 1 -> rustc 2 + [build] rustc 1 -> error-index 2 + [doc] rustc 1 -> error-index 2 + [doc] nomicon (book) + [doc] rustc 1 -> reference (book) 2 + [doc] rustdoc (book) + [doc] rust-by-example (book) + [build] rustc 0 -> LintDocs 1 + [doc] rustc (book) + [doc] cargo (book) + [doc] clippy (book) + [doc] embedded-book (book) + [doc] edition-guide (book) + [doc] style-guide (book) + [doc] rustc 1 -> releases 2 + [build] rustc 0 -> RustInstaller 1 + [dist] docs + [doc] rustc 1 -> std 1 crates=[] + [dist] rustc 1 -> json-docs 2 + [dist] mingw + [build] rustdoc 2 + [build] rustc 0 -> GenerateCopyright 1 + [dist] rustc + [dist] rustc 1 -> std 1 + [dist] rustc 1 -> rustc-dev 2 + [dist] src <> + [dist] reproducible-artifacts + " + ); +} + +#[test] +fn dist_compiler_docs() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("dist") + .path("rustc-docs") + .args(&["--set", "build.compiler-docs=true"]) + .render_steps(), @r" + [build] rustc 0 -> UnstableBookGen 1 + [build] rustc 0 -> Rustbook 1 + [doc] unstable-book (book) + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [doc] book (book) + [doc] book/first-edition (book) + [doc] book/second-edition (book) + [doc] book/2018-edition (book) + [build] rustdoc 1 + [doc] rustc 1 -> standalone 2 + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [doc] rustc 1 -> rustc 2 + [build] rustc 1 -> rustc 2 + [doc] rustc 1 -> Rustdoc 2 + [doc] rustc 1 -> Rustfmt 2 + [build] rustc 1 -> error-index 2 + [doc] rustc 1 -> error-index 2 + [doc] nomicon (book) + [doc] rustc 1 -> reference (book) 2 + [doc] rustdoc (book) + [doc] rust-by-example (book) + [build] rustc 0 -> LintDocs 1 + [doc] rustc (book) + [doc] rustc 1 -> Cargo 2 + [doc] cargo (book) + [doc] rustc 1 -> Clippy 2 + [doc] clippy (book) + [doc] rustc 1 -> Miri 2 + [doc] embedded-book (book) + [doc] edition-guide (book) + [doc] style-guide (book) + [build] rustdoc 0 + [doc] rustc 0 -> Tidy 1 + [doc] rustc 0 -> Bootstrap 1 + [doc] rustc 1 -> releases 2 + [doc] rustc 0 -> RunMakeSupport 1 + [doc] rustc 0 -> BuildHelper 1 + [doc] rustc 0 -> Compiletest 1 + [build] rustc 0 -> RustInstaller 1 + " + ); +} + +#[test] +fn dist_extended() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("dist") + .args(&[ + "--set", + "build.extended=true", + "--set", + "rust.llvm-bitcode-linker=true", + "--set", + "rust.lld=true", + ]) + .render_steps(), @r" + [build] rustc 0 -> UnstableBookGen 1 + [build] rustc 0 -> Rustbook 1 + [doc] unstable-book (book) + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 0 -> LldWrapper 1 + [build] rustc 0 -> WasmComponentLd 1 + [build] rustc 0 -> LlvmBitcodeLinker 1 + [build] rustc 1 -> std 1 + [doc] book (book) + [doc] book/first-edition (book) + [doc] book/second-edition (book) + [doc] book/2018-edition (book) + [build] rustdoc 1 + [doc] rustc 1 -> standalone 2 + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [build] rustc 1 -> rustc 2 + [build] rustc 1 -> LldWrapper 2 + [build] rustc 1 -> WasmComponentLd 2 + [build] rustc 1 -> LlvmBitcodeLinker 2 + [build] rustc 1 -> error-index 2 + [doc] rustc 1 -> error-index 2 + [doc] nomicon (book) + [doc] rustc 1 -> reference (book) 2 + [doc] rustdoc (book) + [doc] rust-by-example (book) + [build] rustc 0 -> LintDocs 1 + [doc] rustc (book) + [doc] cargo (book) + [doc] clippy (book) + [doc] embedded-book (book) + [doc] edition-guide (book) + [doc] style-guide (book) + [doc] rustc 1 -> releases 2 + [build] rustc 0 -> RustInstaller 1 + [dist] docs + [doc] rustc 1 -> std 1 crates=[] + [dist] rustc 1 -> json-docs 2 + [dist] mingw + [build] rustdoc 2 + [build] rustc 1 -> rust-analyzer-proc-macro-srv 2 + [build] rustc 0 -> GenerateCopyright 1 + [dist] rustc + [dist] rustc 1 -> std 1 + [dist] rustc 1 -> rustc-dev 2 + [dist] rustc 1 -> analysis 2 + [dist] src <> + [build] rustc 1 -> cargo 2 + [dist] rustc 1 -> cargo 2 + [build] rustc 1 -> rust-analyzer 2 + [dist] rustc 1 -> rust-analyzer 2 + [build] rustc 1 -> rustfmt 2 + [build] rustc 1 -> cargo-fmt 2 + [dist] rustc 1 -> rustfmt 2 + [build] rustc 1 -> clippy-driver 2 + [build] rustc 1 -> cargo-clippy 2 + [dist] rustc 1 -> clippy 2 + [build] rustc 1 -> miri 2 + [build] rustc 1 -> cargo-miri 2 + [dist] rustc 1 -> miri 2 + [doc] rustc 2 -> std 2 crates=[] + [dist] rustc 2 -> json-docs 3 + [dist] rustc 1 -> extended 2 + [dist] reproducible-artifacts + "); +} + +#[test] +fn dist_with_targets() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx + .config("dist") + .hosts(&[&host_target()]) + .targets(&[&host_target(), TEST_TRIPLE_1]) + .render_steps(), @r" + [build] rustc 0 -> UnstableBookGen 1 + [build] rustc 0 -> Rustbook 1 + [doc] unstable-book (book) + [doc] unstable-book (book) + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [doc] book (book) + [doc] book/first-edition (book) + [doc] book/second-edition (book) + [doc] book/2018-edition (book) + [build] rustdoc 1 + [build] rustc 1 -> std 1 + [doc] book (book) + [doc] book/first-edition (book) + [doc] book/second-edition (book) + [doc] book/2018-edition (book) + [doc] rustc 1 -> standalone 2 + [doc] rustc 1 -> standalone 2 + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [build] rustc 1 -> rustc 2 + [build] rustc 1 -> error-index 2 + [doc] rustc 1 -> error-index 2 + [doc] nomicon (book) + [doc] nomicon (book) + [doc] rustc 1 -> reference (book) 2 + [doc] rustc 1 -> reference (book) 2 + [doc] rustdoc (book) + [doc] rustdoc (book) + [doc] rust-by-example (book) + [doc] rust-by-example (book) + [build] rustc 0 -> LintDocs 1 + [doc] rustc (book) + [doc] cargo (book) + [doc] cargo (book) + [doc] clippy (book) + [doc] clippy (book) + [doc] embedded-book (book) + [doc] embedded-book (book) + [doc] edition-guide (book) + [doc] edition-guide (book) + [doc] style-guide (book) + [doc] style-guide (book) + [doc] rustc 1 -> releases 2 + [doc] rustc 1 -> releases 2 + [build] rustc 0 -> RustInstaller 1 + [dist] docs + [dist] docs + [doc] rustc 1 -> std 1 crates=[] + [dist] rustc 1 -> json-docs 2 + [doc] rustc 1 -> std 1 crates=[] + [dist] rustc 1 -> json-docs 2 + [dist] mingw + [dist] mingw + [build] rustdoc 2 + [build] rustc 0 -> GenerateCopyright 1 + [dist] rustc + [dist] rustc 1 -> std 1 + [dist] rustc 1 -> std 1 + [dist] rustc 1 -> rustc-dev 2 + [dist] src <> + [dist] reproducible-artifacts + " + ); +} + +#[test] +fn dist_with_hosts() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx + .config("dist") + .hosts(&[&host_target(), TEST_TRIPLE_1]) + .targets(&[&host_target()]) + .render_steps(), @r" + [build] rustc 0 -> UnstableBookGen 1 + [build] rustc 0 -> Rustbook 1 + [doc] unstable-book (book) + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [doc] book (book) + [doc] book/first-edition (book) + [doc] book/second-edition (book) + [doc] book/2018-edition (book) + [build] rustdoc 1 + [doc] rustc 1 -> standalone 2 + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [build] rustc 1 -> rustc 2 + [build] rustc 1 -> error-index 2 + [doc] rustc 1 -> error-index 2 + [build] llvm + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + [build] rustc 1 -> error-index 2 + [doc] rustc 1 -> error-index 2 + [doc] nomicon (book) + [doc] rustc 1 -> reference (book) 2 + [doc] rustdoc (book) + [doc] rust-by-example (book) + [build] rustc 0 -> LintDocs 1 + [doc] rustc (book) + [doc] rustc (book) + [doc] cargo (book) + [doc] clippy (book) + [doc] embedded-book (book) + [doc] edition-guide (book) + [doc] style-guide (book) + [doc] rustc 1 -> releases 2 + [build] rustc 0 -> RustInstaller 1 + [dist] docs + [doc] rustc 1 -> std 1 crates=[] + [dist] rustc 1 -> json-docs 2 + [dist] mingw + [build] rustdoc 2 + [build] rustc 0 -> GenerateCopyright 1 + [dist] rustc + [build] rustdoc 2 + [dist] rustc + [dist] rustc 1 -> std 1 + [dist] rustc 1 -> rustc-dev 2 + [dist] rustc 1 -> rustc-dev 2 + [dist] src <> + [dist] reproducible-artifacts + [dist] reproducible-artifacts + " + ); +} + +#[test] +fn dist_with_targets_and_hosts() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx + .config("dist") + .hosts(&[&host_target(), TEST_TRIPLE_1]) + .targets(&[&host_target(), TEST_TRIPLE_1]) + .render_steps(), @r" + [build] rustc 0 -> UnstableBookGen 1 + [build] rustc 0 -> Rustbook 1 + [doc] unstable-book (book) + [doc] unstable-book (book) + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [doc] book (book) + [doc] book/first-edition (book) + [doc] book/second-edition (book) + [doc] book/2018-edition (book) + [build] rustdoc 1 + [build] rustc 1 -> std 1 + [doc] book (book) + [doc] book/first-edition (book) + [doc] book/second-edition (book) + [doc] book/2018-edition (book) + [doc] rustc 1 -> standalone 2 + [doc] rustc 1 -> standalone 2 + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [build] rustc 1 -> rustc 2 + [build] rustc 1 -> error-index 2 + [doc] rustc 1 -> error-index 2 + [build] llvm + [build] rustc 1 -> rustc 2 + [build] rustc 1 -> error-index 2 + [doc] rustc 1 -> error-index 2 + [doc] nomicon (book) + [doc] nomicon (book) + [doc] rustc 1 -> reference (book) 2 + [doc] rustc 1 -> reference (book) 2 + [doc] rustdoc (book) + [doc] rustdoc (book) + [doc] rust-by-example (book) + [doc] rust-by-example (book) + [build] rustc 0 -> LintDocs 1 + [doc] rustc (book) + [doc] rustc (book) + [doc] cargo (book) + [doc] cargo (book) + [doc] clippy (book) + [doc] clippy (book) + [doc] embedded-book (book) + [doc] embedded-book (book) + [doc] edition-guide (book) + [doc] edition-guide (book) + [doc] style-guide (book) + [doc] style-guide (book) + [doc] rustc 1 -> releases 2 + [doc] rustc 1 -> releases 2 + [build] rustc 0 -> RustInstaller 1 + [dist] docs + [dist] docs + [doc] rustc 1 -> std 1 crates=[] + [dist] rustc 1 -> json-docs 2 + [doc] rustc 1 -> std 1 crates=[] + [dist] rustc 1 -> json-docs 2 + [dist] mingw + [dist] mingw + [build] rustdoc 2 + [build] rustc 0 -> GenerateCopyright 1 + [dist] rustc + [build] rustdoc 2 + [dist] rustc + [dist] rustc 1 -> std 1 + [dist] rustc 1 -> std 1 + [dist] rustc 1 -> rustc-dev 2 + [dist] rustc 1 -> rustc-dev 2 + [dist] src <> + [dist] reproducible-artifacts + [dist] reproducible-artifacts + " + ); +} + +#[test] +fn dist_with_empty_host() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx + .config("dist") + .hosts(&[]) + .targets(&[TEST_TRIPLE_1]) + .render_steps(), @r" + [build] rustc 0 -> UnstableBookGen 1 + [build] rustc 0 -> Rustbook 1 + [doc] unstable-book (book) + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [doc] book (book) + [doc] book/first-edition (book) + [doc] book/second-edition (book) + [doc] book/2018-edition (book) + [build] rustdoc 1 + [build] rustc 1 -> std 1 + [doc] rustc 1 -> standalone 2 + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [doc] nomicon (book) + [doc] rustc 1 -> reference (book) 2 + [doc] rustdoc (book) + [doc] rust-by-example (book) + [doc] cargo (book) + [doc] clippy (book) + [doc] embedded-book (book) + [doc] edition-guide (book) + [doc] style-guide (book) + [doc] rustc 1 -> releases 2 + [build] rustc 0 -> RustInstaller 1 + [dist] docs + [doc] rustc 1 -> std 1 crates=[] + [dist] rustc 1 -> json-docs 2 + [dist] mingw + [dist] rustc 1 -> std 1 + "); +} + +#[test] +fn dist_all_cross_extended() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx + .config("dist") + .hosts(&[TEST_TRIPLE_1]) + .targets(&[TEST_TRIPLE_1]) + .args(&["--set", "rust.channel=nightly", "--set", "build.extended=true"]) + .render_steps(), @r" + [build] rustc 0 -> UnstableBookGen 1 + [build] rustc 0 -> Rustbook 1 + [doc] unstable-book (book) + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 0 -> WasmComponentLd 1 + [build] rustc 1 -> std 1 + [doc] book (book) + [doc] book/first-edition (book) + [doc] book/second-edition (book) + [doc] book/2018-edition (book) + [build] rustdoc 1 + [build] rustc 1 -> std 1 + [doc] rustc 1 -> standalone 2 + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [build] llvm + [build] rustc 1 -> rustc 2 + [build] rustc 1 -> WasmComponentLd 2 + [build] rustc 1 -> error-index 2 + [doc] rustc 1 -> error-index 2 + [doc] nomicon (book) + [doc] rustc 1 -> reference (book) 2 + [doc] rustdoc (book) + [doc] rust-by-example (book) + [build] rustc 0 -> LintDocs 1 + [doc] rustc (book) + [doc] cargo (book) + [doc] clippy (book) + [doc] embedded-book (book) + [doc] edition-guide (book) + [doc] style-guide (book) + [doc] rustc 1 -> releases 2 + [build] rustc 0 -> RustInstaller 1 + [dist] docs + [doc] rustc 1 -> std 1 crates=[] + [dist] rustc 1 -> json-docs 2 + [dist] mingw + [build] rustdoc 2 + [build] rustc 1 -> rust-analyzer-proc-macro-srv 2 + [build] rustc 0 -> GenerateCopyright 1 + [dist] rustc + [dist] rustc 1 -> std 1 + [dist] rustc 1 -> rustc-dev 2 + [dist] rustc 1 -> analysis 2 + [dist] src <> + [build] rustc 1 -> cargo 2 + [dist] rustc 1 -> cargo 2 + [build] rustc 1 -> rust-analyzer 2 + [dist] rustc 1 -> rust-analyzer 2 + [build] rustc 1 -> rustfmt 2 + [build] rustc 1 -> cargo-fmt 2 + [dist] rustc 1 -> rustfmt 2 + [build] rustc 1 -> clippy-driver 2 + [build] rustc 1 -> cargo-clippy 2 + [dist] rustc 1 -> clippy 2 + [build] rustc 1 -> miri 2 + [build] rustc 1 -> cargo-miri 2 + [dist] rustc 1 -> miri 2 + [build] rustc 1 -> LlvmBitcodeLinker 2 + [doc] rustc 2 -> std 2 crates=[] + [dist] rustc 2 -> json-docs 3 + [dist] rustc 1 -> extended 2 + [dist] reproducible-artifacts + "); +} + +/// Simulates e.g. the powerpc64 builder, which is fully cross-compiled from x64, but it does +/// not build docs. Crucially, it shouldn't build host stage 2 rustc. +/// +/// This is a regression test for +/// and . +#[test] +fn dist_all_cross_extended_no_docs() { + let ctx = TestCtx::new(); + let steps = ctx + .config("dist") + .hosts(&[TEST_TRIPLE_1]) + .targets(&[TEST_TRIPLE_1]) + .args(&[ + "--set", + "rust.channel=nightly", + "--set", + "build.extended=true", + "--set", + "build.docs=false", + ]) + .get_steps(); + + // Make sure that we don't build stage2 host rustc + steps.assert_no_match(|m| { + m.name == "rustc" + && m.built_by.map(|b| b.stage) == Some(1) + && *m.target.triple == host_target() + }); + + insta::assert_snapshot!( + steps.render(), @r" + [dist] mingw + [build] llvm + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 0 -> WasmComponentLd 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + [build] rustc 1 -> WasmComponentLd 2 + [build] rustdoc 2 + [build] rustc 1 -> rust-analyzer-proc-macro-srv 2 + [build] rustc 0 -> GenerateCopyright 1 + [build] rustc 0 -> RustInstaller 1 + [dist] rustc + [dist] rustc 1 -> std 1 + [dist] rustc 1 -> rustc-dev 2 + [dist] rustc 1 -> analysis 2 + [dist] src <> + [build] rustc 1 -> cargo 2 + [dist] rustc 1 -> cargo 2 + [build] rustc 1 -> rust-analyzer 2 + [dist] rustc 1 -> rust-analyzer 2 + [build] rustc 1 -> rustfmt 2 + [build] rustc 1 -> cargo-fmt 2 + [dist] rustc 1 -> rustfmt 2 + [build] rustc 1 -> clippy-driver 2 + [build] rustc 1 -> cargo-clippy 2 + [dist] rustc 1 -> clippy 2 + [build] rustc 1 -> miri 2 + [build] rustc 1 -> cargo-miri 2 + [dist] rustc 1 -> miri 2 + [build] rustc 1 -> LlvmBitcodeLinker 2 + [dist] rustc 1 -> extended 2 + [dist] reproducible-artifacts + "); +} + +/// Enable dist cranelift tarball by default with `x dist` if cranelift is enabled in +/// `rust.codegen-backends`. +#[test] +fn dist_cranelift_by_default() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx + .config("dist") + .args(&["--set", "rust.codegen-backends=['llvm', 'cranelift']"]) + .render_steps(), @r" + [build] rustc 0 -> UnstableBookGen 1 + [build] rustc 0 -> Rustbook 1 + [doc] unstable-book (book) + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 0 -> rustc_codegen_cranelift 1 + [build] rustc 1 -> std 1 + [doc] book (book) + [doc] book/first-edition (book) + [doc] book/second-edition (book) + [doc] book/2018-edition (book) + [build] rustdoc 1 + [doc] rustc 1 -> standalone 2 + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [build] rustc 1 -> rustc 2 + [build] rustc 1 -> rustc_codegen_cranelift 2 + [build] rustc 1 -> error-index 2 + [doc] rustc 1 -> error-index 2 + [doc] nomicon (book) + [doc] rustc 1 -> reference (book) 2 + [doc] rustdoc (book) + [doc] rust-by-example (book) + [build] rustc 0 -> LintDocs 1 + [doc] rustc (book) + [doc] cargo (book) + [doc] clippy (book) + [doc] embedded-book (book) + [doc] edition-guide (book) + [doc] style-guide (book) + [doc] rustc 1 -> releases 2 + [build] rustc 0 -> RustInstaller 1 + [dist] docs + [doc] rustc 1 -> std 1 crates=[] + [dist] rustc 1 -> json-docs 2 + [dist] mingw + [build] rustdoc 2 + [build] rustc 0 -> GenerateCopyright 1 + [dist] rustc + [dist] rustc 1 -> rustc_codegen_cranelift 2 + [dist] rustc 1 -> std 1 + [dist] rustc 1 -> rustc-dev 2 + [dist] src <> + [dist] reproducible-artifacts + "); +} + +#[test] +fn dist_bootstrap() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx + .config("dist") + .path("bootstrap") + .render_steps(), @r" + [build] rustc 0 -> RustInstaller 1 + [dist] bootstrap + "); +} + +#[test] +fn dist_library_stage_0_local_rebuild() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("dist") + .path("rust-std") + .stage(0) + .targets(&[TEST_TRIPLE_1]) + .args(&["--set", "build.local-rebuild=true"]) + .render_steps(), @r" + [build] rustc 0 -> std 0 + [build] rustc 0 -> RustInstaller 1 + [dist] rustc 0 -> std 0 + "); +} + +#[test] +fn dist_rustc_docs() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx + .config("dist") + .path("rustc-docs") + .render_steps(), @r" + [build] rustc 0 -> UnstableBookGen 1 + [build] rustc 0 -> Rustbook 1 + [doc] unstable-book (book) + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [doc] book (book) + [doc] book/first-edition (book) + [doc] book/second-edition (book) + [doc] book/2018-edition (book) + [build] rustdoc 1 + [doc] rustc 1 -> standalone 2 + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [build] rustc 1 -> rustc 2 + [build] rustc 1 -> error-index 2 + [doc] rustc 1 -> error-index 2 + [doc] nomicon (book) + [doc] rustc 1 -> reference (book) 2 + [doc] rustdoc (book) + [doc] rust-by-example (book) + [build] rustc 0 -> LintDocs 1 + [doc] rustc (book) + [doc] cargo (book) + [doc] clippy (book) + [doc] embedded-book (book) + [doc] edition-guide (book) + [doc] style-guide (book) + [doc] rustc 1 -> releases 2 + [build] rustc 0 -> RustInstaller 1 + "); +} + +#[test] +fn check_compiler_no_explicit_stage() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("check") + .path("compiler") + .render_steps(), @"[check] rustc 0 -> rustc 1 (75 crates)"); +} + +#[test] +fn check_rustc_no_explicit_stage() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("check") + .path("rustc") + .render_steps(), @"[check] rustc 0 -> rustc 1 (1 crates)"); +} + +#[test] +#[should_panic] +fn check_compiler_stage_0() { + let ctx = TestCtx::new(); + ctx.config("check").path("compiler").stage(0).run(); +} + +#[test] +fn check_compiler_stage_1() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("check") + .path("compiler") + .stage(1) + .render_steps(), @"[check] rustc 0 -> rustc 1 (75 crates)"); +} + +#[test] +fn check_compiler_stage_2() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("check") + .path("compiler") + .stage(2) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [check] rustc 1 -> rustc 2 (75 crates) + "); +} + +#[test] +fn check_cross_compile() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("check") + .targets(&[TEST_TRIPLE_1]) + .hosts(&[TEST_TRIPLE_1]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [check] rustc 1 -> std 1 + [check] rustc 1 -> rustc 2 (75 crates) + [check] rustc 1 -> rustc 2 + [check] rustc 1 -> Rustdoc 2 + [check] rustc 1 -> rustc_codegen_cranelift 2 + [check] rustc 1 -> rustc_codegen_gcc 2 + [check] rustc 1 -> Clippy 2 + [check] rustc 1 -> Miri 2 + [check] rustc 1 -> CargoMiri 2 + [check] rustc 1 -> Rustfmt 2 + [check] rustc 1 -> RustAnalyzer 2 + [check] rustc 1 -> TestFloatParse 2 + [check] rustc 1 -> std 1 + "); +} + +#[test] +fn check_library_no_explicit_stage() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("check") + .path("library") + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [check] rustc 1 -> std 1 + "); +} + +#[test] +#[should_panic] +fn check_library_stage_0() { + let ctx = TestCtx::new(); + ctx.config("check").path("library").stage(0).run(); +} + +#[test] +fn check_library_stage_1() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("check") + .path("library") + .stage(1) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [check] rustc 1 -> std 1 + "); +} + +#[test] +fn check_library_stage_2() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("check") + .path("library") + .stage(2) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + [check] rustc 2 -> std 2 + "); +} + +#[test] +fn check_library_cross_compile() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("check") + .paths(&["core", "alloc", "std"]) + .targets(&[TEST_TRIPLE_1, TEST_TRIPLE_2]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [check] rustc 1 -> std 1 + [check] rustc 1 -> std 1 + "); +} + +/// Make sure that we don't check library when download-rustc is disabled +/// when `--skip-std-check-if-no-download-rustc` was passed. +#[test] +fn check_library_skip_without_download_rustc() { + let ctx = TestCtx::new(); + let args = ["--set", "rust.download-rustc=false", "--skip-std-check-if-no-download-rustc"]; + insta::assert_snapshot!( + ctx.config("check") + .paths(&["library"]) + .args(&args) + .render_steps(), @""); + + insta::assert_snapshot!( + ctx.config("check") + .paths(&["library", "compiler"]) + .args(&args) + .render_steps(), @"[check] rustc 0 -> rustc 1 (75 crates)"); +} + +#[test] +fn check_miri_no_explicit_stage() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("check") + .path("miri") + .render_steps(), @r" + [check] rustc 0 -> rustc 1 + [check] rustc 0 -> Miri 1 + "); +} + +#[test] +#[should_panic] +fn check_miri_stage_0() { + let ctx = TestCtx::new(); + ctx.config("check").path("miri").stage(0).run(); +} + +#[test] +fn check_miri_stage_1() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("check") + .path("miri") + .stage(1) + .render_steps(), @r" + [check] rustc 0 -> rustc 1 + [check] rustc 0 -> Miri 1 + "); +} + +#[test] +fn check_miri_stage_2() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("check") + .path("miri") + .stage(2) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [check] rustc 1 -> rustc 2 + [check] rustc 1 -> Miri 2 + "); +} + +#[test] +fn check_compiletest() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("check") + .path("compiletest") + .render_steps(), @"[check] rustc 0 -> Compiletest 1 "); +} + +#[test] +fn check_compiletest_stage1_libtest() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("check") + .path("compiletest") + .args(&["--set", "build.compiletest-use-stage0-libtest=false"]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [check] rustc 1 -> Compiletest 2 + "); +} + +#[test] +fn check_codegen() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("check") + .path("rustc_codegen_cranelift") + .render_steps(), @r" + [check] rustc 0 -> rustc 1 + [check] rustc 0 -> rustc_codegen_cranelift 1 + "); +} + +#[test] +fn check_rust_analyzer() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("check") + .path("rust-analyzer") + .render_steps(), @r" + [check] rustc 0 -> rustc 1 + [check] rustc 0 -> RustAnalyzer 1 + "); +} + +#[test] +fn check_bootstrap_tool() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("check") + .path("run-make-support") + .render_steps(), @"[check] rustc 0 -> RunMakeSupport 1 "); +} + +fn prepare_test_config(ctx: &TestCtx) -> ConfigBuilder { + ctx.config("test") + // Bootstrap only runs by default on CI, so we have to emulate that also locally. + .args(&["--ci", "true"]) + // These rustdoc tests requires nodejs to be present. + // We can't easily opt out of it, so if it is present on the local PC, the test + // would have different result on CI, where nodejs might be missing. + .args(&["--skip", "rustdoc-js-std"]) + .args(&["--skip", "rustdoc-js"]) + .args(&["--skip", "rustdoc-gui"]) +} + +#[test] +fn test_all_stage_1() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + prepare_test_config(&ctx) + .render_steps(), @r" + [build] rustc 0 -> Tidy 1 + [test] tidy <> + [build] rustdoc 0 + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 0 -> Compiletest 1 + [test] compiletest-ui 1 + [test] compiletest-crashes 1 + [build] rustc 0 -> CoverageDump 1 + [test] compiletest-coverage 1 + [test] compiletest-coverage 1 + [build] rustc 1 -> std 1 + [test] compiletest-mir-opt 1 + [test] compiletest-codegen-llvm 1 + [test] compiletest-codegen-units 1 + [test] compiletest-assembly-llvm 1 + [test] compiletest-incremental 1 + [test] compiletest-debuginfo 1 + [test] compiletest-ui-fulldeps 1 + [build] rustdoc 1 + [test] compiletest-rustdoc 1 + [test] compiletest-coverage-run-rustdoc 1 + [test] compiletest-pretty 1 + [build] rustc 1 -> std 1 + [build] rustc 0 -> std 0 + [test] rustc 0 -> CrateLibrustc 1 + [build] rustc 1 -> rustc 2 + [test] crate-bootstrap src/tools/coverage-dump + [test] crate-bootstrap src/tools/jsondoclint + [test] crate-bootstrap src/tools/replace-version-placeholder + [test] crate-bootstrap tidyselftest + [build] rustc 0 -> UnstableBookGen 1 + [build] rustc 0 -> Rustbook 1 + [doc] unstable-book (book) + [doc] book (book) + [doc] book/first-edition (book) + [doc] book/second-edition (book) + [doc] book/2018-edition (book) + [doc] rustc 0 -> standalone 1 + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [build] rustc 0 -> error-index 1 + [doc] rustc 0 -> error-index 1 + [doc] nomicon (book) + [doc] rustc 1 -> reference (book) 2 + [doc] rustdoc (book) + [doc] rust-by-example (book) + [build] rustc 0 -> LintDocs 1 + [doc] rustc (book) + [doc] cargo (book) + [doc] clippy (book) + [doc] embedded-book (book) + [doc] edition-guide (book) + [doc] style-guide (book) + [doc] rustc 0 -> releases 1 + [build] rustc 0 -> Linkchecker 1 + [test] link-check + [test] tier-check + [test] rustc 0 -> rust-analyzer 1 + [build] rustc 0 -> RustdocTheme 1 + [test] rustdoc-theme 1 + [test] compiletest-rustdoc-ui 1 + [build] rustc 0 -> JsonDocCk 1 + [build] rustc 0 -> JsonDocLint 1 + [test] compiletest-rustdoc-json 1 + [doc] rustc 0 -> rustc 1 + [build] rustc 0 -> HtmlChecker 1 + [test] html-check + [build] rustc 0 -> RunMakeSupport 1 + [test] compiletest-run-make 1 + [build] rustc 0 -> cargo 1 + [test] compiletest-run-make-cargo 1 + "); +} + +#[test] +fn test_compiletest_suites_stage1() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("test") + .args(&["ui", "ui-fulldeps", "run-make", "rustdoc", "rustdoc-gui", "incremental"]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 0 -> Compiletest 1 + [test] compiletest-ui 1 + [test] compiletest-ui-fulldeps 1 + [build] rustc 0 -> RunMakeSupport 1 + [build] rustdoc 1 + [test] compiletest-run-make 1 + [test] compiletest-rustdoc 1 + [build] rustc 0 -> RustdocGUITest 1 + [test] rustdoc-gui 1 + [test] compiletest-incremental 1 + [build] rustc 1 -> rustc 2 + "); +} + +#[test] +fn test_compiletest_suites_stage2() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("test") + .args(&["ui", "ui-fulldeps", "run-make", "rustdoc", "rustdoc-gui", "incremental"]) + .stage(2) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + [build] rustc 2 -> std 2 + [build] rustc 0 -> Compiletest 1 + [test] compiletest-ui 2 + [build] rustc 2 -> rustc 3 + [test] compiletest-ui-fulldeps 2 + [build] rustc 0 -> RunMakeSupport 1 + [build] rustdoc 2 + [test] compiletest-run-make 2 + [test] compiletest-rustdoc 2 + [build] rustc 0 -> RustdocGUITest 1 + [test] rustdoc-gui 2 + [test] compiletest-incremental 2 + [build] rustdoc 1 + "); +} + +#[test] +fn test_compiletest_suites_stage2_cross() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("test") + .hosts(&[TEST_TRIPLE_1]) + .targets(&[TEST_TRIPLE_1]) + .args(&["ui", "ui-fulldeps", "run-make", "rustdoc", "rustdoc-gui", "incremental"]) + .stage(2) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + [build] rustc 2 -> std 2 + [build] rustc 0 -> Compiletest 1 + [build] rustc 1 -> std 1 + [build] rustc 2 -> std 2 + [test] compiletest-ui 2 + [build] llvm + [build] rustc 2 -> rustc 3 + [test] compiletest-ui-fulldeps 2 + [build] rustc 0 -> RunMakeSupport 1 + [build] rustdoc 2 + [test] compiletest-run-make 2 + [test] compiletest-rustdoc 2 + [build] rustc 0 -> RustdocGUITest 1 + [test] rustdoc-gui 2 + [test] compiletest-incremental 2 + [build] rustc 1 -> rustc 2 + [build] rustdoc 1 + [build] rustc 2 -> std 2 + [build] rustdoc 2 + "); +} + +#[test] +fn test_all_stage_2() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + prepare_test_config(&ctx) + .stage(2) + .render_steps(), @r" + [build] rustc 0 -> Tidy 1 + [test] tidy <> + [build] rustdoc 0 + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + [build] rustc 2 -> std 2 + [build] rustc 0 -> Compiletest 1 + [test] compiletest-ui 2 + [test] compiletest-crashes 2 + [build] rustc 0 -> CoverageDump 1 + [test] compiletest-coverage 2 + [test] compiletest-coverage 2 + [build] rustc 2 -> std 2 + [test] compiletest-mir-opt 2 + [test] compiletest-codegen-llvm 2 + [test] compiletest-codegen-units 2 + [test] compiletest-assembly-llvm 2 + [test] compiletest-incremental 2 + [test] compiletest-debuginfo 2 + [build] rustc 2 -> rustc 3 + [test] compiletest-ui-fulldeps 2 + [build] rustdoc 2 + [test] compiletest-rustdoc 2 + [test] compiletest-coverage-run-rustdoc 2 + [test] compiletest-pretty 2 + [build] rustc 2 -> std 2 + [build] rustc 1 -> std 1 + [build] rustdoc 1 + [test] rustc 1 -> CrateLibrustc 2 + [test] crate-bootstrap src/tools/coverage-dump + [test] crate-bootstrap src/tools/jsondoclint + [test] crate-bootstrap src/tools/replace-version-placeholder + [test] crate-bootstrap tidyselftest + [build] rustc 0 -> UnstableBookGen 1 + [build] rustc 0 -> Rustbook 1 + [doc] unstable-book (book) + [doc] book (book) + [doc] book/first-edition (book) + [doc] book/second-edition (book) + [doc] book/2018-edition (book) + [doc] rustc 1 -> standalone 2 + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [build] rustc 1 -> error-index 2 + [doc] rustc 1 -> error-index 2 + [doc] nomicon (book) + [doc] rustc 1 -> reference (book) 2 + [doc] rustdoc (book) + [doc] rust-by-example (book) + [build] rustc 0 -> LintDocs 1 + [doc] rustc (book) + [doc] cargo (book) + [doc] clippy (book) + [doc] embedded-book (book) + [doc] edition-guide (book) + [doc] style-guide (book) + [doc] rustc 1 -> releases 2 + [build] rustc 0 -> Linkchecker 1 + [test] link-check + [test] tier-check + [test] rustc 1 -> rust-analyzer 2 + [doc] rustc (book) + [test] rustc 1 -> lint-docs 2 + [build] rustc 0 -> RustdocTheme 1 + [test] rustdoc-theme 2 + [test] compiletest-rustdoc-ui 2 + [build] rustc 0 -> JsonDocCk 1 + [build] rustc 0 -> JsonDocLint 1 + [test] compiletest-rustdoc-json 2 + [doc] rustc 1 -> rustc 2 + [build] rustc 0 -> HtmlChecker 1 + [test] html-check + [build] rustc 0 -> RunMakeSupport 1 + [test] compiletest-run-make 2 + [build] rustc 1 -> cargo 2 + [test] compiletest-run-make-cargo 2 + "); +} + +#[test] +fn test_compiler_stage_1() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("test") + .path("compiler") + .stage(1) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 0 -> std 0 + [build] rustdoc 0 + [test] rustc 0 -> CrateLibrustc 1 + "); +} + +#[test] +fn test_compiler_stage_2() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("test") + .path("compiler") + .stage(2) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + [build] rustc 1 -> std 1 + [build] rustdoc 1 + [test] rustc 1 -> CrateLibrustc 2 + "); +} + +#[test] +fn test_exclude() { + let ctx = TestCtx::new(); + let steps = ctx.config("test").args(&["--skip", "src/tools/tidy"]).get_steps(); + + let host = TargetSelection::from_user(&host_target()); + steps.assert_contains(StepMetadata::test("compiletest-rustdoc-ui", host).stage(1)); + steps.assert_not_contains(test::Tidy); +} + +#[test] +fn test_exclude_kind() { + let ctx = TestCtx::new(); + let host = TargetSelection::from_user(&host_target()); + + let get_steps = |args: &[&str]| ctx.config("test").args(args).get_steps(); + + let rustc_metadata = + || StepMetadata::test("CrateLibrustc", host).built_by(Compiler::new(0, host)); + // Ensure our test is valid, and `test::Rustc` would be run without the exclude. + get_steps(&[]).assert_contains(rustc_metadata()); + + let steps = get_steps(&["--skip", "compiler/rustc_data_structures"]); + + // Ensure tests for rustc are not skipped. + steps.assert_contains(rustc_metadata()); + steps.assert_contains_fuzzy(StepMetadata::build("rustc", host)); +} + +#[test] +fn test_cargo_stage_1() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("test") + .path("cargo") + .render_steps(), @r" + [build] rustc 0 -> cargo 1 + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustdoc 1 + [build] rustdoc 0 + [test] rustc 0 -> cargo 1 + "); +} + +#[test] +fn test_cargo_stage_2() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("test") + .path("cargo") + .stage(2) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> cargo 2 + [build] rustc 1 -> rustc 2 + [build] rustc 2 -> std 2 + [build] rustdoc 2 + [build] rustdoc 1 + [test] rustc 1 -> cargo 2 + "); +} + +#[test] +fn test_cargotest() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("test") + .path("cargotest") + .render_steps(), @r" + [build] rustc 0 -> cargo 1 + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 0 -> CargoTest 1 + [build] rustdoc 1 + [test] cargotest 1 + "); +} + +#[test] +fn test_tier_check() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("test") + .path("tier-check") + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [test] tier-check + "); +} + +// Differential snapshots for `./x test run-make` run `./x test run-make-cargo`: only +// `run-make-cargo` should build an in-tree cargo, running `./x test run-make` should not. +#[test] +fn test_run_make_no_cargo() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("test") + .path("run-make") + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 0 -> RunMakeSupport 1 + [build] rustc 1 -> std 1 + [build] rustc 0 -> Compiletest 1 + [build] rustdoc 1 + [test] compiletest-run-make 1 + "); +} + +#[test] +fn test_run_make_cargo_builds_cargo() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("test") + .path("run-make-cargo") + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 0 -> RunMakeSupport 1 + [build] rustc 1 -> std 1 + [build] rustc 0 -> Compiletest 1 + [build] rustc 0 -> cargo 1 + [build] rustdoc 1 + [test] compiletest-run-make-cargo 1 + "); +} + +#[test] +fn doc_all() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("doc") + .render_steps(), @r" + [build] rustc 0 -> UnstableBookGen 1 + [build] rustc 0 -> Rustbook 1 + [doc] unstable-book (book) + [doc] book (book) + [doc] book/first-edition (book) + [doc] book/second-edition (book) + [doc] book/2018-edition (book) + [build] rustdoc 0 + [doc] rustc 0 -> standalone 1 + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustdoc 1 + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [build] rustc 0 -> error-index 1 + [doc] rustc 0 -> error-index 1 + [doc] nomicon (book) + [build] rustc 1 -> std 1 + [doc] rustc 1 -> reference (book) 2 + [doc] rustdoc (book) + [doc] rust-by-example (book) + [build] rustc 0 -> LintDocs 1 + [doc] rustc (book) + [doc] cargo (book) + [doc] clippy (book) + [doc] embedded-book (book) + [doc] edition-guide (book) + [doc] style-guide (book) + [doc] rustc 0 -> releases 1 + "); +} + +#[test] +fn doc_library() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("doc") + .path("library") + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustdoc 1 + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + "); +} + +#[test] +fn doc_cargo_stage_1() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("doc") + .path("cargo") + .render_steps(), @r" + [build] rustdoc 0 + [doc] rustc 0 -> Cargo 1 + "); +} +#[test] +fn doc_cargo_stage_2() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("doc") + .path("cargo") + .stage(2) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustdoc 1 + [doc] rustc 1 -> Cargo 2 + "); +} + +#[test] +fn doc_core() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("doc") + .path("core") + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustdoc 1 + [doc] rustc 1 -> std 1 crates=[core] + "); +} + +#[test] +fn doc_core_no_std_target() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("doc") + .path("core") + .override_target_no_std(&host_target()) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustdoc 1 + [doc] rustc 1 -> std 1 crates=[core] + "); +} + +#[test] +fn doc_library_no_std_target() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("doc") + .path("library") + .override_target_no_std(&host_target()) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustdoc 1 + [doc] rustc 1 -> std 1 crates=[alloc,core] + "); +} + +#[test] +fn doc_library_no_std_target_cross_compile() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("doc") + .path("library") + .targets(&[TEST_TRIPLE_1]) + .override_target_no_std(TEST_TRIPLE_1) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustdoc 1 + [doc] rustc 1 -> std 1 crates=[alloc,core] + "); +} + +#[test] +#[should_panic] +fn doc_compiler_stage_0() { + let ctx = TestCtx::new(); + ctx.config("doc").path("compiler").stage(0).run(); +} + +#[test] +fn doc_compiler_stage_1() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("doc") + .path("compiler") + .stage(1) + .render_steps(), @r" + [build] rustdoc 0 + [build] llvm + [doc] rustc 0 -> rustc 1 + "); +} + +#[test] +fn doc_compiler_stage_2() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("doc") + .path("compiler") + .stage(2) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustdoc 1 + [doc] rustc 1 -> rustc 2 + "); +} + +#[test] +#[should_panic] +fn doc_compiletest_stage_0() { + let ctx = TestCtx::new(); + ctx.config("doc").path("src/tools/compiletest").stage(0).run(); +} + +#[test] +fn doc_compiletest_stage_1() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("doc") + .path("src/tools/compiletest") + .stage(1) + .render_steps(), @r" + [build] rustdoc 0 + [doc] rustc 0 -> Compiletest 1 + "); +} + +#[test] +fn doc_compiletest_stage_2() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("doc") + .path("src/tools/compiletest") + .stage(2) + .render_steps(), @r" + [build] rustdoc 0 + [doc] rustc 0 -> Compiletest 1 + "); +} + +// Reference should be auto-bumped to stage 2. +#[test] +fn doc_reference() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("doc") + .path("reference") + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 0 -> Rustbook 1 + [doc] rustc 1 -> reference (book) 2 + "); +} + +#[test] +fn clippy_ci() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("clippy") + .path("ci") + .stage(2) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 0 -> clippy-driver 1 + [build] rustc 0 -> cargo-clippy 1 + [clippy] rustc 1 -> bootstrap 2 + [clippy] rustc 1 -> std 1 + [clippy] rustc 1 -> rustc 2 + [check] rustc 1 -> rustc 2 + [clippy] rustc 1 -> rustc_codegen_gcc 2 + "); +} + +#[test] +fn clippy_compiler_stage1() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("clippy") + .path("compiler") + .render_steps(), @r" + [build] llvm + [clippy] rustc 0 -> rustc 1 + "); +} + +#[test] +fn clippy_compiler_stage2() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("clippy") + .path("compiler") + .stage(2) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 0 -> clippy-driver 1 + [build] rustc 0 -> cargo-clippy 1 + [clippy] rustc 1 -> rustc 2 + "); +} + +#[test] +fn clippy_std_stage1() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("clippy") + .path("std") + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 0 -> clippy-driver 1 + [build] rustc 0 -> cargo-clippy 1 + [clippy] rustc 1 -> std 1 + "); +} + +#[test] +fn clippy_std_stage2() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("clippy") + .path("std") + .stage(2) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> rustc 2 + [build] rustc 1 -> clippy-driver 2 + [build] rustc 1 -> cargo-clippy 2 + [clippy] rustc 2 -> std 2 + "); +} + +#[test] +fn clippy_miri_stage1() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("clippy") + .path("miri") + .stage(1) + .render_steps(), @r" + [build] llvm + [check] rustc 0 -> rustc 1 + [clippy] rustc 0 -> miri 1 + "); +} + +#[test] +fn clippy_miri_stage2() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("clippy") + .path("miri") + .stage(2) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [check] rustc 1 -> rustc 2 + [build] rustc 0 -> clippy-driver 1 + [build] rustc 0 -> cargo-clippy 1 + [clippy] rustc 1 -> miri 2 + "); +} + +#[test] +fn clippy_bootstrap() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("clippy") + .path("bootstrap") + .render_steps(), @"[clippy] rustc 0 -> bootstrap 1 "); +} + +#[test] +fn install_extended() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("install") + .args(&[ + // Using backslashes fails with `--set` + "--set", &format!("install.prefix={}", ctx.dir().display()).replace("\\", "/"), + "--set", &format!("install.sysconfdir={}", ctx.dir().display()).replace("\\", "/"), + "--set", "build.extended=true" + ]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 0 -> WasmComponentLd 1 + [build] rustc 0 -> UnstableBookGen 1 + [build] rustc 0 -> Rustbook 1 + [doc] unstable-book (book) + [build] rustc 1 -> std 1 + [doc] book (book) + [doc] book/first-edition (book) + [doc] book/second-edition (book) + [doc] book/2018-edition (book) + [build] rustdoc 1 + [doc] rustc 1 -> standalone 2 + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [build] rustc 1 -> rustc 2 + [build] rustc 1 -> WasmComponentLd 2 + [build] rustc 1 -> error-index 2 + [doc] rustc 1 -> error-index 2 + [doc] nomicon (book) + [doc] rustc 1 -> reference (book) 2 + [doc] rustdoc (book) + [doc] rust-by-example (book) + [build] rustc 0 -> LintDocs 1 + [doc] rustc (book) + [doc] cargo (book) + [doc] clippy (book) + [doc] embedded-book (book) + [doc] edition-guide (book) + [doc] style-guide (book) + [doc] rustc 1 -> releases 2 + [build] rustc 0 -> RustInstaller 1 + [dist] docs + [dist] rustc 1 -> std 1 + [build] rustdoc 2 + [build] rustc 1 -> rust-analyzer-proc-macro-srv 2 + [build] rustc 0 -> GenerateCopyright 1 + [dist] rustc + [build] rustc 1 -> cargo 2 + [dist] rustc 1 -> cargo 2 + [build] rustc 1 -> rust-analyzer 2 + [dist] rustc 1 -> rust-analyzer 2 + [build] rustc 1 -> rustfmt 2 + [build] rustc 1 -> cargo-fmt 2 + [dist] rustc 1 -> rustfmt 2 + [build] rustc 1 -> clippy-driver 2 + [build] rustc 1 -> cargo-clippy 2 + [dist] rustc 1 -> clippy 2 + [build] rustc 1 -> miri 2 + [build] rustc 1 -> cargo-miri 2 + [dist] rustc 1 -> miri 2 + [dist] src <> + "); +} + +// Check that `x run miri --target FOO` actually builds miri for the host. +#[test] +fn run_miri() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("run") + .path("miri") + .stage(1) + .targets(&[TEST_TRIPLE_1]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 0 -> miri 1 + [build] rustc 0 -> cargo-miri 1 + [run] rustc 0 -> miri 1 + "); +}