From a6735e44ca28207d0f2c87c1f47769fed82b56fe Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 9 Sep 2024 14:11:43 +1000 Subject: [PATCH 1/2] Add an explicit ignore message for "up-to-date" tests 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 patch adds an explicit reason to those skipped tests, which is visible when running with `rust.verbose-tests = true` in `config.toml`. --- src/tools/compiletest/src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index 5402e69bc664e..3294a3bd080b3 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -808,8 +808,11 @@ 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; + desc.ignore_message = Some("up-to-date"); } test::TestDescAndFn { desc, From acccb39bff3c589b286c2dfe0d2f2afc8d1a3775 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 9 Sep 2024 14:30:02 +1000 Subject: [PATCH 2/2] Print a helpful message if any tests were skipped for being up-to-date --- src/bootstrap/src/utils/render_tests.rs | 15 +++++++++++++++ src/tools/compiletest/src/lib.rs | 1 + 2 files changed, 16 insertions(+) diff --git a/src/bootstrap/src/utils/render_tests.rs b/src/bootstrap/src/utils/render_tests.rs index b8aebc2854906..eb2c8254dc0f4 100644 --- a/src/bootstrap/src/utils/render_tests.rs +++ b/src/bootstrap/src/utils/render_tests.rs @@ -88,6 +88,9 @@ struct Renderer<'a> { builder: &'a Builder<'a>, tests_count: Option, 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, } @@ -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, } } @@ -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 @@ -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, diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index 3294a3bd080b3..33687a3dad35b 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -812,6 +812,7 @@ fn make_test( && 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 {