Skip to content

Commit 95aeb46

Browse files
committed
Auto merge of #148424 - Zalathar:tests, r=Kobzol
bootstrap: Add snapshot tests for path-to-step handling This PR adds a suite of snapshot tests for how bootstrap translates command-line “paths” (which are not necessarily actual paths) into a set of top-level steps to execute. Unlike the existing suite of snapshot tests (for transitive step logging), I decided to use `.snap` files over inline snapshots, because I find that inline snapshots quickly make test files impossible to navigate. Instead, I set up a macro that makes it relatively easy to add or modify test cases. Using `.snap` files also means that the tests can be blessed by setting `INSTA_UPDATE=always`, without necessarily needing the `cargo insta` tool installed, though the tool can still be used instead if desired. These snapshot tests capture _current_ behavior, to prevent unintended changes or regressions. If the current behavior is wrong or undersirable, then any fix will necessarily have to re-bless the affected tests! r? Kobzol
2 parents 0b329f8 + 2412e15 commit 95aeb46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1766
-0
lines changed

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3413,6 +3413,13 @@ impl Step for Bootstrap {
34133413
.env("INSTA_WORKSPACE_ROOT", &builder.src)
34143414
.env("RUSTC_BOOTSTRAP", "1");
34153415

3416+
if builder.config.cmd.bless() {
3417+
// Tell `insta` to automatically bless any failing `.snap` files.
3418+
// Unlike compiletest blessing, the tests might still report failure.
3419+
// Does not bless inline snapshots.
3420+
cargo.env("INSTA_UPDATE", "always");
3421+
}
3422+
34163423
run_cargo_test(cargo, &[], &[], None, host, builder);
34173424
}
34183425

src/bootstrap/src/core/builder/cli_paths.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ use std::path::PathBuf;
77

88
use crate::core::builder::{Builder, Kind, PathSet, ShouldRun, StepDescription};
99

10+
#[cfg(test)]
11+
mod tests;
12+
1013
pub(crate) const PATH_REMAP: &[(&str, &[&str])] = &[
1114
// bootstrap.toml uses `rust-analyzer-proc-macro-srv`, but the
1215
// actual path is `proc-macro-srv-cli`
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
source: src/bootstrap/src/core/builder/cli_paths/tests.rs
3+
expression: build
4+
---
5+
[Build] compile::Std
6+
targets: [aarch64-unknown-linux-gnu]
7+
- Set({build::library})
8+
- Set({build::library/alloc})
9+
- Set({build::library/compiler-builtins/compiler-builtins})
10+
- Set({build::library/core})
11+
- Set({build::library/panic_abort})
12+
- Set({build::library/panic_unwind})
13+
- Set({build::library/proc_macro})
14+
- Set({build::library/rustc-std-workspace-core})
15+
- Set({build::library/std})
16+
- Set({build::library/std_detect})
17+
- Set({build::library/sysroot})
18+
- Set({build::library/test})
19+
- Set({build::library/unwind})
20+
[Build] tool::Rustdoc
21+
targets: [x86_64-unknown-linux-gnu]
22+
- Set({build::src/librustdoc})
23+
- Set({build::src/tools/rustdoc})
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
source: src/bootstrap/src/core/builder/cli_paths/tests.rs
3+
expression: build compiler
4+
---
5+
[Build] compile::Rustc
6+
targets: [x86_64-unknown-linux-gnu]
7+
- Set({build::compiler/rustc_abi})
8+
- Set({build::compiler/rustc_arena})
9+
- Set({build::compiler/rustc_ast})
10+
- Set({build::compiler/rustc_ast_ir})
11+
- Set({build::compiler/rustc_ast_lowering})
12+
- Set({build::compiler/rustc_ast_passes})
13+
- Set({build::compiler/rustc_ast_pretty})
14+
- Set({build::compiler/rustc_attr_parsing})
15+
- Set({build::compiler/rustc_baked_icu_data})
16+
- Set({build::compiler/rustc_borrowck})
17+
- Set({build::compiler/rustc_builtin_macros})
18+
- Set({build::compiler/rustc_codegen_llvm})
19+
- Set({build::compiler/rustc_codegen_ssa})
20+
- Set({build::compiler/rustc_const_eval})
21+
- Set({build::compiler/rustc_data_structures})
22+
- Set({build::compiler/rustc_driver})
23+
- Set({build::compiler/rustc_driver_impl})
24+
- Set({build::compiler/rustc_error_codes})
25+
- Set({build::compiler/rustc_error_messages})
26+
- Set({build::compiler/rustc_errors})
27+
- Set({build::compiler/rustc_expand})
28+
- Set({build::compiler/rustc_feature})
29+
- Set({build::compiler/rustc_fluent_macro})
30+
- Set({build::compiler/rustc_fs_util})
31+
- Set({build::compiler/rustc_graphviz})
32+
- Set({build::compiler/rustc_hashes})
33+
- Set({build::compiler/rustc_hir})
34+
- Set({build::compiler/rustc_hir_analysis})
35+
- Set({build::compiler/rustc_hir_id})
36+
- Set({build::compiler/rustc_hir_pretty})
37+
- Set({build::compiler/rustc_hir_typeck})
38+
- Set({build::compiler/rustc_incremental})
39+
- Set({build::compiler/rustc_index})
40+
- Set({build::compiler/rustc_index_macros})
41+
- Set({build::compiler/rustc_infer})
42+
- Set({build::compiler/rustc_interface})
43+
- Set({build::compiler/rustc_lexer})
44+
- Set({build::compiler/rustc_lint})
45+
- Set({build::compiler/rustc_lint_defs})
46+
- Set({build::compiler/rustc_llvm})
47+
- Set({build::compiler/rustc_log})
48+
- Set({build::compiler/rustc_macros})
49+
- Set({build::compiler/rustc_metadata})
50+
- Set({build::compiler/rustc_middle})
51+
- Set({build::compiler/rustc_mir_build})
52+
- Set({build::compiler/rustc_mir_dataflow})
53+
- Set({build::compiler/rustc_mir_transform})
54+
- Set({build::compiler/rustc_monomorphize})
55+
- Set({build::compiler/rustc_next_trait_solver})
56+
- Set({build::compiler/rustc_parse})
57+
- Set({build::compiler/rustc_parse_format})
58+
- Set({build::compiler/rustc_passes})
59+
- Set({build::compiler/rustc_pattern_analysis})
60+
- Set({build::compiler/rustc_privacy})
61+
- Set({build::compiler/rustc_proc_macro})
62+
- Set({build::compiler/rustc_public})
63+
- Set({build::compiler/rustc_public_bridge})
64+
- Set({build::compiler/rustc_query_impl})
65+
- Set({build::compiler/rustc_query_system})
66+
- Set({build::compiler/rustc_resolve})
67+
- Set({build::compiler/rustc_sanitizers})
68+
- Set({build::compiler/rustc_serialize})
69+
- Set({build::compiler/rustc_session})
70+
- Set({build::compiler/rustc_span})
71+
- Set({build::compiler/rustc_symbol_mangling})
72+
- Set({build::compiler/rustc_target})
73+
- Set({build::compiler/rustc_thread_pool})
74+
- Set({build::compiler/rustc_trait_selection})
75+
- Set({build::compiler/rustc_traits})
76+
- Set({build::compiler/rustc_transmute})
77+
- Set({build::compiler/rustc_ty_utils})
78+
- Set({build::compiler/rustc_type_ir})
79+
- Set({build::compiler/rustc_type_ir_macros})
80+
- Set({build::compiler/rustc_windows_rc})
81+
[Build] compile::Assemble
82+
targets: [x86_64-unknown-linux-gnu]
83+
- Set({build::compiler})
84+
- Set({build::compiler/rustc})
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
source: src/bootstrap/src/core/builder/cli_paths/tests.rs
3+
expression: build compiletest
4+
---
5+
[Build] tool::Compiletest
6+
targets: [aarch64-unknown-linux-gnu]
7+
- Set({build::src/tools/compiletest})
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
source: src/bootstrap/src/core/builder/cli_paths/tests.rs
3+
expression: build library
4+
---
5+
[Build] compile::Std
6+
targets: [aarch64-unknown-linux-gnu]
7+
- Set({build::library})
8+
- Set({build::library/alloc})
9+
- Set({build::library/compiler-builtins/compiler-builtins})
10+
- Set({build::library/core})
11+
- Set({build::library/panic_abort})
12+
- Set({build::library/panic_unwind})
13+
- Set({build::library/proc_macro})
14+
- Set({build::library/rustc-std-workspace-core})
15+
- Set({build::library/std})
16+
- Set({build::library/std_detect})
17+
- Set({build::library/sysroot})
18+
- Set({build::library/test})
19+
- Set({build::library/unwind})
20+
[Build] compile::StartupObjects
21+
targets: [aarch64-unknown-linux-gnu]
22+
- Set({build::library/rtstartup})
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
source: src/bootstrap/src/core/builder/cli_paths/tests.rs
3+
expression: build llvm
4+
---
5+
[Build] llvm::Llvm
6+
targets: [x86_64-unknown-linux-gnu]
7+
- Set({build::src/llvm-project/llvm})
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
source: src/bootstrap/src/core/builder/cli_paths/tests.rs
3+
expression: build rustc
4+
---
5+
[Build] compile::Assemble
6+
targets: [x86_64-unknown-linux-gnu]
7+
- Set({build::compiler/rustc})
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
source: src/bootstrap/src/core/builder/cli_paths/tests.rs
3+
expression: build rustc_llvm
4+
---
5+
[Build] compile::Rustc
6+
targets: [x86_64-unknown-linux-gnu]
7+
- Set({build::compiler/rustc_llvm})
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
source: src/bootstrap/src/core/builder/cli_paths/tests.rs
3+
expression: build rustdoc
4+
---
5+
[Build] tool::Rustdoc
6+
targets: [x86_64-unknown-linux-gnu]
7+
- Set({build::src/tools/rustdoc})

0 commit comments

Comments
 (0)