Skip to content

Commit 1e38462

Browse files
Rollup merge of rust-lang#159131 - Zalathar:skip-coverage, r=jieyouxu
bootstrap: Allow path-based skipping of the coverage test suite - Alternative to rust-lang#159079 --- When bootstrap runs a step by default, without explicit paths, it will normally act as though the user had explicitly requested all of the paths and aliases that the step registered through `ShouldRun`. For the coverage test suite, that gives the wrong outcome. Running a command like `./x test --skip=tests` or `./x test --skip=coverage` should skip the coverage tests, but instead the coverage tests would run anyway, due to the `coverage-map` and `coverage-run` aliases being treated as implied command-line arguments. This PR fixes that problem by adding a special flag to `ShouldRun`. When creating pathsets for a step that is being run by default, if the step has set the `default_to_suites_only` flag, all non-suite pathsets are discarded. That gives the desired behaviour for skipping coverage tests, without affecting other steps, since other steps don't set the flag. The end result is that `./x test --skip=tests` should now skip the coverage tests, as intended. This lets us remove some `--skip` arguments from CI scripts, which were only required by the previous incorrect behaviour. --- The `default_to_suites_only` flag is a bit of a hack, but to me it seems like the cleanest way to resolve this problem without having to completely overhaul how CLI paths work, which is a much bigger task. And I think being able to remove the weird extra `--skip` arguments from CI scripts makes this a net positive. r? jieyouxu
2 parents e76514e + a4d03c4 commit 1e38462

12 files changed

Lines changed: 677 additions & 27 deletions

File tree

src/bootstrap/mk/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ prepare:
106106
SKIP_COMPILER := --skip=compiler
107107
SKIP_SRC := --skip=src
108108
TEST_SET1 := $(SKIP_COMPILER) $(SKIP_SRC)
109-
TEST_SET2 := --skip=tests --skip=coverage-map --skip=coverage-run --skip=library --skip=tidyselftest
109+
TEST_SET2 := --skip=tests --skip=library --skip=tidyselftest
110110

111111
## MSVC native builders
112112

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,6 +1975,12 @@ impl Step for Coverage {
19751975
for mode in Self::ALL_MODES {
19761976
run = run.alias(mode.as_str());
19771977
}
1978+
1979+
// Allow `./x test --skip=tests` to properly skip the coverage tests,
1980+
// by not treating the `coverage-map` and `coverage-run` aliases as
1981+
// implied command-line arguments.
1982+
run = run.default_to_suites_only();
1983+
19781984
run
19791985
}
19801986

@@ -2016,13 +2022,6 @@ impl Step for Coverage {
20162022
!run.builder.config.skip.iter().any(|skip| skip == Path::new(mode.as_str()))
20172023
});
20182024

2019-
// FIXME(Zalathar): Make these commands skip all coverage tests, as expected:
2020-
// - `./x test --skip=tests`
2021-
// - `./x test --skip=tests/coverage`
2022-
// - `./x test --skip=coverage`
2023-
// Skip handling currently doesn't have a way to know that skipping the coverage
2024-
// suite should also skip the `coverage-map` and `coverage-run` aliases.
2025-
20262025
for mode in modes {
20272026
run.builder.ensure(Coverage { compiler, target, mode });
20282027
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ pub(crate) fn match_paths_to_steps_and_run(
138138
if paths.is_empty() || builder.config.include_default_paths {
139139
for StepExtra { desc, should_run } in &steps {
140140
if (desc.is_default_step_fn)(builder) {
141-
desc.maybe_run(builder, should_run.paths.iter().cloned().collect());
141+
let default_pathsets = should_run.default_pathsets();
142+
desc.maybe_run(builder, default_pathsets);
142143
}
143144
}
144145
}

src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ expression: test
1313
- Suite(test::tests/crashes)
1414
[Test] test::Coverage
1515
targets: [aarch64-unknown-linux-gnu]
16-
- Set({test::coverage-map})
17-
- Set({test::coverage-run})
1816
- Suite(test::tests/coverage)
1917
[Test] test::MirOpt
2018
targets: [aarch64-unknown-linux-gnu]

src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ expression: test --skip=coverage
1111
[Test] test::Crashes
1212
targets: [aarch64-unknown-linux-gnu]
1313
- Suite(test::tests/crashes)
14-
[Test] test::Coverage
15-
targets: [aarch64-unknown-linux-gnu]
16-
- Set({test::coverage-map})
17-
- Set({test::coverage-run})
1814
[Test] test::MirOpt
1915
targets: [aarch64-unknown-linux-gnu]
2016
- Suite(test::tests/mir-opt)
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
---
2+
source: src/bootstrap/src/core/builder/cli_paths/tests.rs
3+
expression: test --skip=coverage-map
4+
---
5+
[Test] test::Tidy
6+
targets: [x86_64-unknown-linux-gnu]
7+
- Set({test::src/tools/tidy})
8+
[Test] test::Ui
9+
targets: [aarch64-unknown-linux-gnu]
10+
- Suite(test::tests/ui)
11+
[Test] test::Crashes
12+
targets: [aarch64-unknown-linux-gnu]
13+
- Suite(test::tests/crashes)
14+
[Test] test::Coverage
15+
targets: [aarch64-unknown-linux-gnu]
16+
- Suite(test::tests/coverage)
17+
[Test] test::MirOpt
18+
targets: [aarch64-unknown-linux-gnu]
19+
- Suite(test::tests/mir-opt)
20+
[Test] test::CodegenLlvm
21+
targets: [aarch64-unknown-linux-gnu]
22+
- Suite(test::tests/codegen-llvm)
23+
[Test] test::CodegenUnits
24+
targets: [aarch64-unknown-linux-gnu]
25+
- Suite(test::tests/codegen-units)
26+
[Test] test::AssemblyLlvm
27+
targets: [aarch64-unknown-linux-gnu]
28+
- Suite(test::tests/assembly-llvm)
29+
[Test] test::Incremental
30+
targets: [aarch64-unknown-linux-gnu]
31+
- Suite(test::tests/incremental)
32+
[Test] test::Debuginfo
33+
targets: [aarch64-unknown-linux-gnu]
34+
- Suite(test::tests/debuginfo)
35+
[Test] test::UiFullDeps
36+
targets: [x86_64-unknown-linux-gnu]
37+
- Suite(test::tests/ui-fulldeps)
38+
[Test] test::RustdocHtml
39+
targets: [x86_64-unknown-linux-gnu]
40+
- Suite(test::tests/rustdoc-html)
41+
[Test] test::CoverageRunRustdoc
42+
targets: [x86_64-unknown-linux-gnu]
43+
- Suite(test::tests/coverage-run-rustdoc)
44+
[Test] test::Pretty
45+
targets: [x86_64-unknown-linux-gnu]
46+
- Suite(test::tests/pretty)
47+
[Test] test::CodegenCranelift
48+
targets: [x86_64-unknown-linux-gnu]
49+
- Set({test::compiler/rustc_codegen_cranelift})
50+
[Test] test::CodegenGCC
51+
targets: [x86_64-unknown-linux-gnu]
52+
- Set({test::compiler/rustc_codegen_gcc})
53+
[Test] test::Crate
54+
targets: [aarch64-unknown-linux-gnu]
55+
- Set({test::library/alloc})
56+
- Set({test::library/alloctests})
57+
- Set({test::library/compiler-builtins/compiler-builtins})
58+
- Set({test::library/core})
59+
- Set({test::library/coretests})
60+
- Set({test::library/panic_abort})
61+
- Set({test::library/panic_unwind})
62+
- Set({test::library/proc_macro})
63+
- Set({test::library/rustc-std-workspace-core})
64+
- Set({test::library/std})
65+
- Set({test::library/std_detect})
66+
- Set({test::library/sysroot})
67+
- Set({test::library/test})
68+
- Set({test::library/unwind})
69+
[Test] test::CrateLibrustc
70+
targets: [x86_64-unknown-linux-gnu]
71+
- Set({test::compiler})
72+
- Set({test::compiler/rustc})
73+
- Set({test::compiler/rustc_abi})
74+
- Set({test::compiler/rustc_arena})
75+
- Set({test::compiler/rustc_ast})
76+
- Set({test::compiler/rustc_ast_ir})
77+
- Set({test::compiler/rustc_ast_lowering})
78+
- Set({test::compiler/rustc_ast_passes})
79+
- Set({test::compiler/rustc_ast_pretty})
80+
- Set({test::compiler/rustc_attr_parsing})
81+
- Set({test::compiler/rustc_baked_icu_data})
82+
- Set({test::compiler/rustc_borrowck})
83+
- Set({test::compiler/rustc_builtin_macros})
84+
- Set({test::compiler/rustc_codegen_llvm})
85+
- Set({test::compiler/rustc_codegen_ssa})
86+
- Set({test::compiler/rustc_const_eval})
87+
- Set({test::compiler/rustc_data_structures})
88+
- Set({test::compiler/rustc_driver})
89+
- Set({test::compiler/rustc_driver_impl})
90+
- Set({test::compiler/rustc_error_codes})
91+
- Set({test::compiler/rustc_error_messages})
92+
- Set({test::compiler/rustc_errors})
93+
- Set({test::compiler/rustc_expand})
94+
- Set({test::compiler/rustc_feature})
95+
- Set({test::compiler/rustc_fs_util})
96+
- Set({test::compiler/rustc_graphviz})
97+
- Set({test::compiler/rustc_hashes})
98+
- Set({test::compiler/rustc_hir})
99+
- Set({test::compiler/rustc_hir_analysis})
100+
- Set({test::compiler/rustc_hir_id})
101+
- Set({test::compiler/rustc_hir_pretty})
102+
- Set({test::compiler/rustc_hir_typeck})
103+
- Set({test::compiler/rustc_incremental})
104+
- Set({test::compiler/rustc_index})
105+
- Set({test::compiler/rustc_index_macros})
106+
- Set({test::compiler/rustc_infer})
107+
- Set({test::compiler/rustc_interface})
108+
- Set({test::compiler/rustc_lexer})
109+
- Set({test::compiler/rustc_lint})
110+
- Set({test::compiler/rustc_lint_defs})
111+
- Set({test::compiler/rustc_llvm})
112+
- Set({test::compiler/rustc_log})
113+
- Set({test::compiler/rustc_macros})
114+
- Set({test::compiler/rustc_metadata})
115+
- Set({test::compiler/rustc_middle})
116+
- Set({test::compiler/rustc_mir_build})
117+
- Set({test::compiler/rustc_mir_dataflow})
118+
- Set({test::compiler/rustc_mir_transform})
119+
- Set({test::compiler/rustc_monomorphize})
120+
- Set({test::compiler/rustc_next_trait_solver})
121+
- Set({test::compiler/rustc_parse})
122+
- Set({test::compiler/rustc_parse_format})
123+
- Set({test::compiler/rustc_passes})
124+
- Set({test::compiler/rustc_pattern_analysis})
125+
- Set({test::compiler/rustc_privacy})
126+
- Set({test::compiler/rustc_proc_macro})
127+
- Set({test::compiler/rustc_public})
128+
- Set({test::compiler/rustc_public_bridge})
129+
- Set({test::compiler/rustc_query_impl})
130+
- Set({test::compiler/rustc_resolve})
131+
- Set({test::compiler/rustc_sanitizers})
132+
- Set({test::compiler/rustc_serialize})
133+
- Set({test::compiler/rustc_session})
134+
- Set({test::compiler/rustc_span})
135+
- Set({test::compiler/rustc_symbol_mangling})
136+
- Set({test::compiler/rustc_target})
137+
- Set({test::compiler/rustc_thread_pool})
138+
- Set({test::compiler/rustc_trait_selection})
139+
- Set({test::compiler/rustc_traits})
140+
- Set({test::compiler/rustc_transmute})
141+
- Set({test::compiler/rustc_ty_utils})
142+
- Set({test::compiler/rustc_type_ir})
143+
- Set({test::compiler/rustc_type_ir_macros})
144+
- Set({test::compiler/rustc_windows_rc})
145+
[Test] test::CrateRustdoc
146+
targets: [x86_64-unknown-linux-gnu]
147+
- Set({test::src/librustdoc, test::src/tools/rustdoc})
148+
[Test] test::CrateRustdocJsonTypes
149+
targets: [x86_64-unknown-linux-gnu]
150+
- Set({test::src/rustdoc-json-types})
151+
[Test] test::CrateBootstrap
152+
targets: [x86_64-unknown-linux-gnu]
153+
- Set({test::src/tools/coverage-dump})
154+
- Set({test::src/tools/jsondoclint})
155+
- Set({test::src/tools/replace-version-placeholder})
156+
- Set({test::tidyselftest})
157+
[Test] test::RemoteTestClientTests
158+
targets: [x86_64-unknown-linux-gnu]
159+
- Set({test::src/tools/remote-test-client})
160+
[Test] test::Linkcheck
161+
targets: [x86_64-unknown-linux-gnu]
162+
- Set({test::src/tools/linkchecker})
163+
[Test] test::TierCheck
164+
targets: [x86_64-unknown-linux-gnu]
165+
- Set({test::src/tools/tier-check})
166+
[Test] test::RustAnalyzer
167+
targets: [x86_64-unknown-linux-gnu]
168+
- Set({test::src/tools/rust-analyzer})
169+
[Test] test::ErrorIndex
170+
targets: [x86_64-unknown-linux-gnu]
171+
- Set({test::error-index})
172+
- Set({test::src/tools/error_index_generator})
173+
[Test] test::RustdocBook
174+
targets: [x86_64-unknown-linux-gnu]
175+
- Set({test::src/doc/rustdoc})
176+
[Test] test::UnstableBook
177+
targets: [x86_64-unknown-linux-gnu]
178+
- Set({test::src/doc/unstable-book})
179+
[Test] test::RustcBook
180+
targets: [x86_64-unknown-linux-gnu]
181+
- Set({test::src/doc/rustc})
182+
[Test] test::StdarchVerify
183+
targets: [x86_64-unknown-linux-gnu]
184+
- Set({test::library/stdarch/crates/stdarch-verify})
185+
[Test] test::RustdocJSStd
186+
targets: [x86_64-unknown-linux-gnu]
187+
- Suite(test::tests/rustdoc-js-std)
188+
[Test] test::RustdocJSNotStd
189+
targets: [x86_64-unknown-linux-gnu]
190+
- Suite(test::tests/rustdoc-js)
191+
[Test] test::RustdocTheme
192+
targets: [x86_64-unknown-linux-gnu]
193+
- Set({test::src/tools/rustdoc-themes})
194+
[Test] test::RustdocUi
195+
targets: [x86_64-unknown-linux-gnu]
196+
- Suite(test::tests/rustdoc-ui)
197+
[Test] test::RustdocJson
198+
targets: [x86_64-unknown-linux-gnu]
199+
- Suite(test::tests/rustdoc-json)
200+
[Test] test::HtmlCheck
201+
targets: [x86_64-unknown-linux-gnu]
202+
- Set({test::src/tools/html-checker})
203+
[Test] test::RustInstaller
204+
targets: [x86_64-unknown-linux-gnu]
205+
- Set({test::src/tools/rust-installer})
206+
[Test] test::TestFloatParse
207+
targets: [x86_64-unknown-linux-gnu]
208+
- Set({test::src/tools/test-float-parse})
209+
[Test] test::RunMake
210+
targets: [aarch64-unknown-linux-gnu]
211+
- Suite(test::tests/run-make)
212+
[Test] test::RunMakeCargo
213+
targets: [aarch64-unknown-linux-gnu]
214+
- Suite(test::tests/run-make-cargo)

0 commit comments

Comments
 (0)