From 8fcc009f7d3d0dbe7fcee8e4df890e78c346378c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 6 Mar 2024 12:40:03 -0800 Subject: [PATCH] libtest: Print timing information on WASI This commit updates the libtest conditionals to use `std::time::Instant` on WASI targets where it's implemented. Previously all wasm targets wouldn't use this type. --- library/test/src/console.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/test/src/console.rs b/library/test/src/console.rs index 09aa3bfb6aa..8096e498263 100644 --- a/library/test/src/console.rs +++ b/library/test/src/console.rs @@ -323,10 +323,11 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec) -> 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_supported = - !cfg!(target_family = "wasm") && !cfg!(target_os = "zkvm") && !cfg!(miri); + let is_instant_unsupported = (cfg!(target_family = "wasm") && !cfg!(target_os = "wasi")) + || cfg!(target_os = "zkvm") + || cfg!(miri); - let start_time = is_instant_supported.then(Instant::now); + let start_time = (!is_instant_unsupported).then(Instant::now); run_tests(opts, tests, |x| on_test_event(&x, &mut st, &mut *out))?; st.exec_time = start_time.map(|t| TestSuiteExecTime(t.elapsed()));