Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print a helpful message if any tests were skipped for being up-to-date #130131

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading