Skip to content

Commit

Permalink
Unrolled build for rust-lang#130131
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#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
```
  • Loading branch information
rust-timer authored Sep 9, 2024
2 parents d7522d8 + acccb39 commit 88e90f6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/bootstrap/src/utils/render_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ struct Renderer<'a> {
builder: &'a Builder<'a>,
tests_count: Option<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,
}

Expand All @@ -100,6 +103,7 @@ impl<'a> Renderer<'a> {
builder,
tests_count: None,
executed_tests: 0,
up_to_date_tests: 0,
terse_tests_in_line: 0,
}
}
Expand Down Expand Up @@ -127,6 +131,12 @@ impl<'a> Renderer<'a> {
}
}
}

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
Expand All @@ -149,6 +159,11 @@ impl<'a> Renderer<'a> {
fn render_test_outcome(&mut self, outcome: Outcome<'_>, test: &TestOutcome) {
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")]
self.builder.metrics.record_test(
&test.name,
Expand Down
8 changes: 6 additions & 2 deletions src/tools/compiletest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -808,8 +808,12 @@ fn make_test(
&config, cache, test_name, &test_path, src_file, revision, poisoned,
);
// Ignore tests that already run and are up to date with respect to inputs.
if !config.force_rerun {
desc.ignore |= is_up_to_date(&config, testpaths, &early_props, revision, inputs);
if !config.force_rerun
&& 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 {
desc,
Expand Down

0 comments on commit 88e90f6

Please sign in to comment.