Rollup merge of #123548 - RalfJung:what-is-time, r=joboet

libtest: also measure time in Miri

A long time ago we disabled timekeeping of the default test harness in Miri, as otherwise it would fail to run without `-Zmiri-disable-isolation`. However, since then Miri gained a "fake clock" that lets it present some deterministic notion of time when isolation is enabled.

So we could now let libtest do timekeeping again when running in Miri. That's nice as it can help detect tests that run too long. However it can also be confusing as the results with isolation can be quite different than the real time.

``@rust-lang/miri`` what do you think?
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-04-15 16:56:14 +01:00 committed by GitHub
commit 2074631732
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 5 deletions

View File

@ -315,10 +315,8 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Resu
// Prevent the usage of `Instant` in some cases:
// - It's currently not supported for wasm targets.
// - We disable it for miri because it's not available when isolation is enabled.
let is_instant_unsupported = (cfg!(target_family = "wasm") && !cfg!(target_os = "wasi"))
|| cfg!(target_os = "zkvm")
|| cfg!(miri);
let is_instant_unsupported =
(cfg!(target_family = "wasm") && !cfg!(target_os = "wasi")) || cfg!(target_os = "zkvm");
let start_time = (!is_instant_unsupported).then(Instant::now);
run_tests(opts, tests, |x| on_test_event(&x, &mut st, &mut *out))?;

View File

@ -377,7 +377,7 @@ struct SuiteOutcome {
measured: usize,
filtered_out: usize,
/// The time it took to execute this test suite, or `None` if time measurement was not possible
/// (e.g. due to running inside Miri).
/// (e.g. due to running on wasm).
exec_time: Option<f64>,
}