mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-10 22:13:27 +00:00
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.
This commit is contained in:
parent
7141379559
commit
8fcc009f7d
@ -323,10 +323,11 @@ 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_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()));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user