From 573d0ba0d94f2f870432e05317557eba4fe2d5d9 Mon Sep 17 00:00:00 2001 From: Luca Mondada <72734770+lmondada@users.noreply.github.com> Date: Wed, 24 Jul 2024 16:30:15 +0100 Subject: [PATCH] test: Add coverage for Badger split circuit multi-threading (#505) Coverage checks for #495 showed a hole in coverage for the Badger optimiser, when using multi-threading with circuit splitting. This PR fixes this. --- tket2/src/optimiser/badger.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tket2/src/optimiser/badger.rs b/tket2/src/optimiser/badger.rs index 4359166f..75741928 100644 --- a/tket2/src/optimiser/badger.rs +++ b/tket2/src/optimiser/badger.rs @@ -656,6 +656,27 @@ mod tests { opt_rz.hugr_mut().update_validate(®ISTRY).unwrap(); } + #[rstest] + #[case::compiled(badger_opt_compiled())] + #[case::json(badger_opt_json())] + fn rz_rz_cancellation_split_parallel( + rz_rz: Circuit, + #[case] badger_opt: DefaultBadgerOptimiser, + ) { + let mut opt_rz = badger_opt.optimise( + &rz_rz, + BadgerOptions { + timeout: Some(0), + n_threads: 2.try_into().unwrap(), + queue_size: 4, + split_circuit: true, + ..Default::default() + }, + ); + opt_rz.hugr_mut().update_validate(®ISTRY).unwrap(); + assert_eq!(opt_rz.commands().count(), 2); + } + #[rstest] #[ignore = "Loading the ECC set is really slow (~5 seconds)"] fn non_composable_rewrites(