rust/library
Bradford Hovinen e19a98cff7 Do not panic when a test function returns Result::Err.
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.
2022-09-16 14:36:00 +00:00
..
alloc Alternate approach; just modify Drain 2022-09-10 17:52:34 -04:00
backtrace@07872f28cd Update backtrace 2022-09-02 16:09:58 -04:00
core Rollup merge of #101802 - chriss0612:const_fn_trait_ref_impls, r=fee1-dead 2022-09-16 11:17:02 +05:30
panic_abort Update comment about personalities in panic_abort 2022-08-23 16:12:58 +08:00
panic_unwind Auto merge of #92845 - Amanieu:std_personality, r=Mark-Simulacrum 2022-08-28 04:16:29 +00:00
portable-simd separate the receiver from arguments in HIR under /clippy 2022-09-05 22:25:57 +09:00
proc_macro Rollup merge of #100767 - kadiwa4:escape_ascii, r=jackh726 2022-09-12 15:21:30 +05:30
profiler_builtins Fully stabilize NLL 2022-06-03 17:16:41 -04:00
rtstartup Remove custom frame info registration on i686-pc-windows-gnu 2022-08-23 16:12:58 +08:00
rustc-std-workspace-alloc Switch all libraries to the 2021 edition 2021-12-23 19:03:47 +08:00
rustc-std-workspace-core Switch all libraries to the 2021 edition 2021-12-23 19:03:47 +08:00
rustc-std-workspace-std Switch all libraries to the 2021 edition 2021-12-23 19:03:47 +08:00
std Rollup merge of #101559 - andrewpollack:add-backtrace-off-fuchsia, r=tmandry 2022-09-15 08:00:12 +02:00
stdarch@42df7394d3 Update stdarch submodule 2022-08-23 16:24:59 +02:00
test Do not panic when a test function returns Result::Err. 2022-09-16 14:36:00 +00:00
unwind unwind: don't build dependency when building for Miri 2022-08-15 12:54:12 -04:00