rust/library/test/src
bors e5bb341f0e Auto merge of #111992 - ferrocene:pa-panic-abort-tests-bench, r=m-ou-se
Test benchmarks with `-Z panic-abort-tests`

During test execution, when a `#[bench]` benchmark is encountered it's executed once to check whether it works. Unfortunately that was not compatible with `-Z panic-abort-tests`: the feature works by spawning a subprocess for each test, which prevents the use of dynamic tests as we cannot pass closures to child processes, and before this PR the conversion from benchmark to test was done by turning benchmarks into dynamic tests whose closures execute the benchmark once.

The approach this PR took was to add two new kinds of `TestFn`s: `StaticBenchAsTestFn` and `DynBenchAsTestFn` (⚠️ **this is a breaking change** ⚠️). With that change, a `StaticBenchFn` can be converted into a `StaticBenchAsTestFn` without creating dynamic tests, and making it possible to test `#[bench]` functions with `-Z panic-abort-tests`. The subprocess test runner also had to be updated to perform the conversion from benchmark to test when appropriate.

Along with the bug fix, in the first commit I refactored how tests are executed: rather than executing the test function in multiple places across `libtest`, there is now a private `TestFn::into_runnable()` method, which returns either a `RunnableTest` or `RunnableBench`, on which you can call the `run()` method. This simplified the rest of the changes in the PR.

This PR is best reviewed commit-by-commit.
Fixes https://github.com/rust-lang/rust/issues/73509
2023-07-01 07:07:50 +00:00
..
formatters Rollup merge of #110651 - durin42:xunit-stdout, r=cuviper 2023-05-04 19:18:18 +02:00
helpers Add IsTerminal trait to determine if a descriptor or handle is a terminal 2022-10-15 00:35:38 +01:00
stats mv std libs to library/ 2020-07-27 19:51:13 -05:00
term Remove various double spaces in source comments. 2023-01-14 17:22:04 +01:00
bench.rs Do not panic when a test function returns Result::Err. 2022-09-16 14:36:00 +00:00
cli.rs libtest: Improve error when missing -Zunstable-options 2023-05-24 11:18:20 -05:00
console.rs add StaticBenchAsTestFn and DynBenchAsTestFn to convert benches to tests 2023-05-26 14:57:38 +02:00
event.rs Do fewer passes and generally be more efficient when filtering tests 2022-10-27 21:34:56 -04:00
lib.rs convert benches to tests in subprocess if we're not benchmarking 2023-05-26 14:59:10 +02:00
options.rs derive Default trait for compiletest::common::Config 2023-05-20 14:40:46 +03:00
stats.rs Fix naming format of IEEE 754 standard 2022-09-11 04:13:33 +02:00
term.rs WinConsole::new is not actually fallible 2022-10-21 12:18:33 +02:00
test_result.rs Fix a few clippy lints in libtest 2023-01-03 18:55:03 +00:00
tests.rs ignore core, alloc and test tests that require unwinding on panic=abort 2023-06-13 15:53:24 +02:00
time.rs Fix uninlined_format_args in libtest 2022-12-19 08:58:40 +01:00
types.rs add StaticBenchAsTestFn and DynBenchAsTestFn to convert benches to tests 2023-05-26 14:57:38 +02:00