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
```
This commit is contained in:
Matthias Krüger 2024-09-09 20:20:19 +02:00 committed by GitHub
commit 3658bfb6ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 2 deletions

View File

@ -88,6 +88,9 @@ struct Renderer<'a> {
builder: &'a Builder<'a>, builder: &'a Builder<'a>,
tests_count: Option<usize>, tests_count: Option<usize>,
executed_tests: usize, executed_tests: usize,
/// Number of tests that were skipped due to already being up-to-date
/// (i.e. no relevant changes occurred since they last ran).
up_to_date_tests: usize,
terse_tests_in_line: usize, terse_tests_in_line: usize,
} }
@ -100,6 +103,7 @@ fn new(stdout: ChildStdout, builder: &'a Builder<'a>) -> Self {
builder, builder,
tests_count: None, tests_count: None,
executed_tests: 0, executed_tests: 0,
up_to_date_tests: 0,
terse_tests_in_line: 0, terse_tests_in_line: 0,
} }
} }
@ -127,6 +131,12 @@ fn render_all(mut self) {
} }
} }
} }
if self.up_to_date_tests > 0 {
let n = self.up_to_date_tests;
let s = if n > 1 { "s" } else { "" };
println!("help: ignored {n} up-to-date test{s}; use `--force-rerun` to prevent this\n");
}
} }
/// Renders the stdout characters one by one /// Renders the stdout characters one by one
@ -149,6 +159,11 @@ fn stream_all(mut self) {
fn render_test_outcome(&mut self, outcome: Outcome<'_>, test: &TestOutcome) { fn render_test_outcome(&mut self, outcome: Outcome<'_>, test: &TestOutcome) {
self.executed_tests += 1; self.executed_tests += 1;
// Keep this in sync with the "up-to-date" ignore message inserted by compiletest.
if let Outcome::Ignored { reason: Some("up-to-date") } = outcome {
self.up_to_date_tests += 1;
}
#[cfg(feature = "build-metrics")] #[cfg(feature = "build-metrics")]
self.builder.metrics.record_test( self.builder.metrics.record_test(
&test.name, &test.name,

View File

@ -808,8 +808,12 @@ fn make_test(
&config, cache, test_name, &test_path, src_file, revision, poisoned, &config, cache, test_name, &test_path, src_file, revision, poisoned,
); );
// Ignore tests that already run and are up to date with respect to inputs. // Ignore tests that already run and are up to date with respect to inputs.
if !config.force_rerun { if !config.force_rerun
desc.ignore |= is_up_to_date(&config, testpaths, &early_props, revision, inputs); && is_up_to_date(&config, testpaths, &early_props, revision, inputs)
{
desc.ignore = true;
// Keep this in sync with the "up-to-date" message detected by bootstrap.
desc.ignore_message = Some("up-to-date");
} }
test::TestDescAndFn { test::TestDescAndFn {
desc, desc,