Skip to content

Commit 8fcc009

Browse files
committed
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.
1 parent 7141379 commit 8fcc009

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

library/test/src/console.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,11 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Resu
323323
// Prevent the usage of `Instant` in some cases:
324324
// - It's currently not supported for wasm targets.
325325
// - We disable it for miri because it's not available when isolation is enabled.
326-
let is_instant_supported =
327-
!cfg!(target_family = "wasm") && !cfg!(target_os = "zkvm") && !cfg!(miri);
326+
let is_instant_unsupported = (cfg!(target_family = "wasm") && !cfg!(target_os = "wasi"))
327+
|| cfg!(target_os = "zkvm")
328+
|| cfg!(miri);
328329

329-
let start_time = is_instant_supported.then(Instant::now);
330+
let start_time = (!is_instant_unsupported).then(Instant::now);
330331
run_tests(opts, tests, |x| on_test_event(&x, &mut st, &mut *out))?;
331332
st.exec_time = start_time.map(|t| TestSuiteExecTime(t.elapsed()));
332333

0 commit comments

Comments
 (0)