Add an 'on_failure' attribute to gpui tests

This lets us perform a finalization step when a randomized test fails.
This commit is contained in:
Max Brunsfeld 2023-04-03 18:16:08 -07:00
parent 5ecc9606af
commit 7b0a6c0dfa
2 changed files with 20 additions and 0 deletions

View file

@ -45,6 +45,7 @@ pub fn run_test(
Arc<executor::Deterministic>,
u64,
)),
on_fail_fn: Option<fn()>,
fn_name: String,
) {
// let _profiler = dhat::Profiler::new_heap();
@ -177,6 +178,7 @@ pub fn run_test(
if is_randomized {
eprintln!("failing seed: {}", atomic_seed.load(SeqCst));
}
on_fail_fn.map(|f| f());
panic::resume_unwind(error);
}
}