diff --git a/Cargo.toml b/Cargo.toml index a91862f..5cfa34a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -73,6 +73,7 @@ features = ["rstar"] [dev-dependencies] serde_json.workspace = true proptest = "1.6" +rstest = "0.26.1" [package.metadata.docs.rs] cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] diff --git a/tests/common/mod.rs b/tests/common/mod.rs index c687061..ebcdab6 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -43,12 +43,15 @@ pub fn create_invoker_and_assert( invoker } -pub fn replay_and_assert(invoker: &mut Invoker, filename: &str) { +pub fn replay_and_assert(invoker: &mut Invoker, filename: &str, variant: &str) { let file = File::open(filename).unwrap(); let history: History = serde_json::from_reader(file).unwrap(); invoker.replay(history); - assert_undo_redo_replay(invoker, filename); + + if variant == "with_undo_redo_replay" { + assert_undo_redo_replay(invoker, filename); + } } pub fn assert_undo_redo_replay(invoker: &mut Invoker, filename: &str) { diff --git a/tests/single_layer.rs b/tests/single_layer.rs index 3b82e58..e809842 100644 --- a/tests/single_layer.rs +++ b/tests/single_layer.rs @@ -2,6 +2,7 @@ // // SPDX-License-Identifier: MIT +use rstest::rstest; use topola::{ autorouter::{ execution::Command, @@ -14,22 +15,27 @@ use topola::{ mod common; -#[test] -fn test_tht_de9_to_tht_de9_in_order() { +#[rstest] +#[case::plain("")] +#[case::with_undo_redo_replay("with_undo_redo_replay")] +fn test_tht_de9_to_tht_de9_in_order(#[case] variant: &str) { let autorouter = common::load_design("tests/single_layer/tht_de9_to_tht_de9/tht_de9_to_tht_de9.dsn"); let mut invoker = common::create_invoker_and_assert(autorouter); common::replay_and_assert( &mut invoker, "tests/single_layer/tht_de9_to_tht_de9/autoroute_all_in_an_order.cmd", + variant, ); let (mut autorouter, ..) = invoker.dissolve(); common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu"); } -#[test] -fn test_tht_de9_to_tht_de9() { +#[rstest] +#[case::plain("")] +#[case::with_undo_redo_replay("with_undo_redo_replay")] +fn test_tht_de9_to_tht_de9(#[case] variant: &str) { let autorouter = common::load_design("tests/single_layer/tht_de9_to_tht_de9/tht_de9_to_tht_de9.dsn"); let mut invoker = common::create_invoker_and_assert(autorouter); @@ -37,20 +43,24 @@ fn test_tht_de9_to_tht_de9() { common::replay_and_assert( &mut invoker, "tests/single_layer/tht_de9_to_tht_de9/autoroute_all.cmd", + variant, ); let (mut autorouter, ..) = invoker.dissolve(); common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu"); } -#[test] -fn test_0603_breakout() { +#[rstest] +#[case::plain("")] +#[case::with_undo_redo_replay("with_undo_redo_replay")] +fn test_0603_breakout(#[case] variant: &str) { let mut autorouter = common::load_design("tests/single_layer/0603_breakout/0603_breakout.dsn"); common::assert_navnode_count(&mut autorouter, "R1-2", "J1-2", 22); let mut invoker = common::create_invoker_and_assert(autorouter); common::replay_and_assert( &mut invoker, "tests/single_layer/0603_breakout/autoroute_all.cmd", + variant, ); let (mut autorouter, ..) = invoker.dissolve(); @@ -59,8 +69,10 @@ fn test_0603_breakout() { //common::assert_number_of_conncomps(&mut autorouter, 2); } -#[test] -fn test_tht_diode_bridge_rectifier() { +#[rstest] +#[case::plain("")] +#[case::with_undo_redo_replay("with_undo_redo_replay")] +fn test_tht_diode_bridge_rectifier(#[case] variant: &str) { let mut autorouter = common::load_design( "tests/single_layer/tht_diode_bridge_rectifier/tht_diode_bridge_rectifier.dsn", ); @@ -69,6 +81,7 @@ fn test_tht_diode_bridge_rectifier() { common::replay_and_assert( &mut invoker, "tests/single_layer/tht_diode_bridge_rectifier/autoroute_all.cmd", + variant, ); let (mut autorouter, ..) = invoker.dissolve(); @@ -95,8 +108,10 @@ fn test_tht_diode_bridge_rectifier() { )); } -#[test] -fn test_4x_3rd_order_smd_lc_filters() { +#[rstest] +#[case::plain("")] +#[case::with_undo_redo_replay("with_undo_redo_replay")] +fn test_4x_3rd_order_smd_lc_filters(#[case] variant: &str) { let mut autorouter = common::load_design( "tests/single_layer/4x_3rd_order_smd_lc_filters/4x_3rd_order_smd_lc_filters.dsn", ); @@ -105,6 +120,7 @@ fn test_4x_3rd_order_smd_lc_filters() { common::replay_and_assert( &mut invoker, "tests/single_layer/4x_3rd_order_smd_lc_filters/autoroute_signals.cmd", + variant, ); let (mut autorouter, ..) = invoker.dissolve(); @@ -116,8 +132,10 @@ fn test_4x_3rd_order_smd_lc_filters() { // FIXME: This test fails indeterministically. // NOTE: Disabled until determinism is fixed. //#[test] -#[allow(unused)] -fn test_tht_3pin_xlr_to_tht_3pin_xlr() { +/*#[allow(unused)] +#[case("")] +#[case("with_undo_redo_replay")] +fn test_tht_3pin_xlr_to_tht_3pin_xlr(#[case] variant: &str) { let mut autorouter = common::load_design( "tests/single_layer/tht_3pin_xlr_to_tht_3pin_xlr/tht_3pin_xlr_to_tht_3pin_xlr.dsn", ); @@ -126,15 +144,18 @@ fn test_tht_3pin_xlr_to_tht_3pin_xlr() { common::replay_and_assert( &mut invoker, "tests/single_layer/tht_3pin_xlr_to_tht_3pin_xlr/autoroute_all.cmd", + "undo_redo_replay", ); let (mut autorouter, ..) = invoker.dissolve(); common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu"); -} +}*/ -#[test] -fn test_vga_dac_breakout() { +#[rstest] +#[case::plain("")] +#[case::with_undo_redo_replay("with_undo_redo_replay")] +fn test_vga_dac_breakout(#[case] variant: &str) { let mut autorouter = common::load_design("tests/single_layer/vga_dac_breakout/vga_dac_breakout.dsn"); common::assert_navnode_count(&mut autorouter, "J1-2", "R4-1", 272); @@ -142,6 +163,7 @@ fn test_vga_dac_breakout() { common::replay_and_assert( &mut invoker, "tests/single_layer/vga_dac_breakout/autoroute_all.cmd", + variant, ); let (mut autorouter, ..) = invoker.dissolve(); @@ -149,8 +171,10 @@ fn test_vga_dac_breakout() { common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu"); } -#[test] -fn test_smd_non_rectangular_buck_converter() { +#[rstest] +#[case::plain("")] +#[case::with_undo_redo_replay("with_undo_redo_replay")] +fn test_smd_non_rectangular_buck_converter(#[case] variant: &str) { let path = "tests/single_layer/smd_non_rectangular_buck_converter/smd_non_rectangular_buck_converter.dsn"; let autorouter = common::load_design(&path); @@ -159,6 +183,7 @@ fn test_smd_non_rectangular_buck_converter() { common::replay_and_assert( &mut invoker, "tests/single_layer/smd_non_rectangular_buck_converter/route_all.cmd", + variant, ); let (mut autorouter, ..) = invoker.dissolve();