tests: support running benches via custom test runner
close tikv/tikv#12820
@@ -57,15 +57,15 @@ pub fn run_test_with_hook(cases: &[&TestDescAndFn], hook: impl TestHook + Send +
.iter()
.map(|case| {
let name = case.desc.name.as_slice().to_owned();
- let h = hook.clone();
+ let hook = hook.clone();
let f = match case.testfn {
TestFn::StaticTestFn(f) => TestFn::DynTestFn(Box::new(move || {
- let _watcher = CaseLifeWatcher::new(name, h);
+ let _watcher = CaseLifeWatcher::new(name.clone(), hook.clone());
f();
})),
- TestFn::StaticBenchFn(f) => TestFn::DynTestFn(Box::new(move || {
- let _watcher = CaseLifeWatcher::new(name, h);
- bench::run_once(move |b| f(b));
+ TestFn::StaticBenchFn(f) => TestFn::DynBenchFn(Box::new(move |b| {
+ let _watcher = CaseLifeWatcher::new(name.clone(), hook.clone());
+ f(b);
})),
ref f => panic!("unexpected testfn {:?}", f),
};
