test: Use `rstest_reuse` crate to reuse test cases

This commit is contained in:
Mikolaj Wielgus 2025-09-17 12:25:42 +02:00
parent 59115b20d1
commit 979493efe4
2 changed files with 19 additions and 25 deletions

View File

@ -74,6 +74,7 @@ features = ["rstar"]
serde_json.workspace = true serde_json.workspace = true
proptest = "1.6" proptest = "1.6"
rstest = "0.26.1" rstest = "0.26.1"
rstest_reuse = "0.7.0"
[package.metadata.docs.rs] [package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

View File

@ -3,6 +3,7 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
use rstest::rstest; use rstest::rstest;
use rstest_reuse::{self, *};
use topola::{ use topola::{
autorouter::{ autorouter::{
execution::Command, execution::Command,
@ -15,10 +16,14 @@ use topola::{
mod common; mod common;
#[template]
#[rstest] #[rstest]
#[case::plain("")] #[case::plain("")]
#[case::with_undo_redo_replay("with_undo_redo_replay")] #[case::with_undo_redo_replay("with_undo_redo_replay")]
fn test_tht_de9_to_tht_de9_in_order(#[case] variant: &str) { fn test_master(#[case] variant: &str) {}
#[apply(test_master)]
fn test_tht_de9_to_tht_de9_in_order(variant: &str) {
let autorouter = let autorouter =
common::load_design("tests/single_layer/tht_de9_to_tht_de9/tht_de9_to_tht_de9.dsn"); 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); let mut invoker = common::create_invoker_and_assert(autorouter);
@ -32,10 +37,8 @@ fn test_tht_de9_to_tht_de9_in_order(#[case] variant: &str) {
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu"); common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
} }
#[rstest] #[apply(test_master)]
#[case::plain("")] fn test_tht_de9_to_tht_de9(variant: &str) {
#[case::with_undo_redo_replay("with_undo_redo_replay")]
fn test_tht_de9_to_tht_de9(#[case] variant: &str) {
let autorouter = let autorouter =
common::load_design("tests/single_layer/tht_de9_to_tht_de9/tht_de9_to_tht_de9.dsn"); 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); let mut invoker = common::create_invoker_and_assert(autorouter);
@ -50,10 +53,8 @@ fn test_tht_de9_to_tht_de9(#[case] variant: &str) {
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu"); common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
} }
#[rstest] #[apply(test_master)]
#[case::plain("")] fn test_0603_breakout(variant: &str) {
#[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"); 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); common::assert_navnode_count(&mut autorouter, "R1-2", "J1-2", 22);
let mut invoker = common::create_invoker_and_assert(autorouter); let mut invoker = common::create_invoker_and_assert(autorouter);
@ -69,10 +70,8 @@ fn test_0603_breakout(#[case] variant: &str) {
//common::assert_number_of_conncomps(&mut autorouter, 2); //common::assert_number_of_conncomps(&mut autorouter, 2);
} }
#[rstest] #[apply(test_master)]
#[case::plain("")] fn test_tht_diode_bridge_rectifier(variant: &str) {
#[case::with_undo_redo_replay("with_undo_redo_replay")]
fn test_tht_diode_bridge_rectifier(#[case] variant: &str) {
let mut autorouter = common::load_design( let mut autorouter = common::load_design(
"tests/single_layer/tht_diode_bridge_rectifier/tht_diode_bridge_rectifier.dsn", "tests/single_layer/tht_diode_bridge_rectifier/tht_diode_bridge_rectifier.dsn",
); );
@ -108,10 +107,8 @@ fn test_tht_diode_bridge_rectifier(#[case] variant: &str) {
)); ));
} }
#[rstest] #[apply(test_master)]
#[case::plain("")] fn test_4x_3rd_order_smd_lc_filters(variant: &str) {
#[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( let mut autorouter = common::load_design(
"tests/single_layer/4x_3rd_order_smd_lc_filters/4x_3rd_order_smd_lc_filters.dsn", "tests/single_layer/4x_3rd_order_smd_lc_filters/4x_3rd_order_smd_lc_filters.dsn",
); );
@ -152,10 +149,8 @@ fn test_tht_3pin_xlr_to_tht_3pin_xlr(#[case] variant: &str) {
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu"); common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
}*/ }*/
#[rstest] #[apply(test_master)]
#[case::plain("")] fn test_vga_dac_breakout(variant: &str) {
#[case::with_undo_redo_replay("with_undo_redo_replay")]
fn test_vga_dac_breakout(#[case] variant: &str) {
let mut autorouter = let mut autorouter =
common::load_design("tests/single_layer/vga_dac_breakout/vga_dac_breakout.dsn"); common::load_design("tests/single_layer/vga_dac_breakout/vga_dac_breakout.dsn");
common::assert_navnode_count(&mut autorouter, "J1-2", "R4-1", 272); common::assert_navnode_count(&mut autorouter, "J1-2", "R4-1", 272);
@ -171,10 +166,8 @@ fn test_vga_dac_breakout(#[case] variant: &str) {
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu"); common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
} }
#[rstest] #[apply(test_master)]
#[case::plain("")] fn test_smd_non_rectangular_buck_converter(variant: &str) {
#[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 path = "tests/single_layer/smd_non_rectangular_buck_converter/smd_non_rectangular_buck_converter.dsn";
let autorouter = common::load_design(&path); let autorouter = common::load_design(&path);