about summary refs log tree commit diff
path: root/library/test/src/bench.rs
AgeCommit message (Collapse)AuthorLines
2022-09-16Do not panic when a test function returns Result::Err.Bradford Hovinen-10/+11
Rust's test library allows test functions to return a Result, so that the test is deemed to have failed if the function returns a Result::Err variant. Currently, this works by having Result implement the Termination trait and asserting in assert_test_result that Termination::report() indicates successful completion. This turns a Result::Err into a panic, which is caught and unwound in the test library. This approach is problematic in certain environments where one wishes to save on both binary size and compute resources when running tests by: * Compiling all code with --panic=abort to avoid having to generate unwinding tables, and * Running most tests in-process to avoid the overhead of spawning new processes. This change removes the intermediate panic step and passes a Result::Err directly through to the test runner. To do this, it modifies assert_test_result to return a Result<(), String> where the Err variant holds what was previously the panic message. It changes the types in the TestFn enum to return Result<(), String>. This tries to minimise the changes to benchmark tests, so it calls unwrap() on the Result returned by assert_test_result, effectively keeping the same behaviour as before.
2021-04-25move core::hint::black_box under its own feature gateRalf Jung-2/+9
2021-03-24libtest: Index tests by a unique TestIdAnders Kaseorg-4/+13
This more robustly avoids problems with duplicate TestDesc. See #81852 and #82274. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2020-11-10Merge set_panic and set_print into set_output_capture.Mara Bos-9/+5
There were no use cases for setting them separately. Merging them simplifies some things.
2020-11-10Remove io::LocalOutput and use Arc<Mutex<dyn>> for local streams.Mara Bos-6/+2
2020-10-01Fix some clippy issuesJoshua Nelson-1/+1
Found while working on https://github.com/rust-lang/rust/pull/77351; these are just the ones that could be fixed automatically.
2020-09-21Rollup merge of #76959 - est31:write, r=oli-obkRalf Jung-10/+10
Replace write_fmt with write! Latter is simpler
2020-09-20Replace write_fmt with write!est31-10/+10
Latter is simpler
2020-09-20Use as_nanos in bench.rs and base.rsest31-5/+1
2020-07-27mv std libs to library/mark-0/+238