remove nested function from run_test

The inner function is not needed anymore as it's only called once after
the previous commit's refactoring.
This commit is contained in:
Pietro Albini 2023-05-26 14:56:59 +02:00
parent b1d60bc076
commit fa451fe6db
No known key found for this signature in database
GPG Key ID: CD76B35F7734769E

View File

@ -559,38 +559,36 @@ pub fn run_test(
return None;
}
struct TestRunOpts {
pub strategy: RunStrategy,
pub nocapture: bool,
pub time: Option<time::TestTimeOptions>,
match testfn.into_runnable() {
Runnable::Test(runnable_test) => {
if runnable_test.is_dynamic() {
match strategy {
RunStrategy::InProcess => (),
_ => panic!("Cannot run dynamic test fn out-of-process"),
};
}
fn run_test_inner(
id: TestId,
desc: TestDesc,
monitor_ch: Sender<CompletedTest>,
runnable_test: RunnableTest,
opts: TestRunOpts,
) -> Option<thread::JoinHandle<()>> {
let name = desc.name.clone();
let nocapture = opts.nocapture;
let time_options = opts.time_options;
let runtest = move || match opts.strategy {
let runtest = move || match strategy {
RunStrategy::InProcess => run_test_in_process(
id,
desc,
opts.nocapture,
opts.time.is_some(),
nocapture,
time_options.is_some(),
runnable_test,
monitor_ch,
opts.time,
time_options,
),
RunStrategy::SpawnPrimary => spawn_test_subprocess(
id,
desc,
opts.nocapture,
opts.time.is_some(),
nocapture,
time_options.is_some(),
monitor_ch,
opts.time,
time_options,
),
};
@ -617,20 +615,6 @@ pub fn run_test(
None
}
}
let test_run_opts =
TestRunOpts { strategy, nocapture: opts.nocapture, time: opts.time_options };
match testfn.into_runnable() {
Runnable::Test(runnable_test) => {
if runnable_test.is_dynamic() {
match strategy {
RunStrategy::InProcess => (),
_ => panic!("Cannot run dynamic test fn out-of-process"),
};
}
run_test_inner(id, desc, monitor_ch, runnable_test, test_run_opts)
}
Runnable::Bench(runnable_bench) => {
// Benchmarks aren't expected to panic, so we run them all in-process.
runnable_bench.run(id, &desc, &monitor_ch, opts.nocapture);