Skip to content

Commit c50de21

Browse files
authored
Rollup merge of #130131 - Zalathar:up-to-date, r=Kobzol
Print a helpful message if any tests were skipped for being up-to-date When running tests without the `--force-rerun` flag, compiletest will automatically skip any tests that (in its judgement) don't need to be run again since the last time they were run. This is normally very useful, but can occasionally be confusing, especially in edge-cases where up-to-date checking is not completely accurate (or the test is flaky). This PR makes bootstrap count the number of tests that were ignored for being up-to-date (via a hard-coded check on the ignore reason), and prints a helpful message when that number is nonzero. --- Sample output: ```text test result: ok. 4 passed; 0 failed; 17578 ignored; 0 measured; 0 filtered out; finished in 463.79ms help: ignored 17295 up-to-date tests; use `--force-rerun` to prevent this Build completed successfully in 0:00:07 ```
2 parents d2f98de + acccb39 commit c50de21

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/bootstrap/src/utils/render_tests.rs

+15
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ struct Renderer<'a> {
8888
builder: &'a Builder<'a>,
8989
tests_count: Option<usize>,
9090
executed_tests: usize,
91+
/// Number of tests that were skipped due to already being up-to-date
92+
/// (i.e. no relevant changes occurred since they last ran).
93+
up_to_date_tests: usize,
9194
terse_tests_in_line: usize,
9295
}
9396

@@ -100,6 +103,7 @@ impl<'a> Renderer<'a> {
100103
builder,
101104
tests_count: None,
102105
executed_tests: 0,
106+
up_to_date_tests: 0,
103107
terse_tests_in_line: 0,
104108
}
105109
}
@@ -127,6 +131,12 @@ impl<'a> Renderer<'a> {
127131
}
128132
}
129133
}
134+
135+
if self.up_to_date_tests > 0 {
136+
let n = self.up_to_date_tests;
137+
let s = if n > 1 { "s" } else { "" };
138+
println!("help: ignored {n} up-to-date test{s}; use `--force-rerun` to prevent this\n");
139+
}
130140
}
131141

132142
/// Renders the stdout characters one by one
@@ -149,6 +159,11 @@ impl<'a> Renderer<'a> {
149159
fn render_test_outcome(&mut self, outcome: Outcome<'_>, test: &TestOutcome) {
150160
self.executed_tests += 1;
151161

162+
// Keep this in sync with the "up-to-date" ignore message inserted by compiletest.
163+
if let Outcome::Ignored { reason: Some("up-to-date") } = outcome {
164+
self.up_to_date_tests += 1;
165+
}
166+
152167
#[cfg(feature = "build-metrics")]
153168
self.builder.metrics.record_test(
154169
&test.name,

src/tools/compiletest/src/lib.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -808,8 +808,12 @@ fn make_test(
808808
&config, cache, test_name, &test_path, src_file, revision, poisoned,
809809
);
810810
// Ignore tests that already run and are up to date with respect to inputs.
811-
if !config.force_rerun {
812-
desc.ignore |= is_up_to_date(&config, testpaths, &early_props, revision, inputs);
811+
if !config.force_rerun
812+
&& is_up_to_date(&config, testpaths, &early_props, revision, inputs)
813+
{
814+
desc.ignore = true;
815+
// Keep this in sync with the "up-to-date" message detected by bootstrap.
816+
desc.ignore_message = Some("up-to-date");
813817
}
814818
test::TestDescAndFn {
815819
desc,

0 commit comments

Comments
 (0)