mirror of https://codeberg.org/topola/topola.git
test: Use rstest to parametrizedly split tests into plain and with_undo_redo_replay
This commit is contained in:
parent
a390c67e4f
commit
59115b20d1
|
|
@ -73,6 +73,7 @@ features = ["rstar"]
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
proptest = "1.6"
|
proptest = "1.6"
|
||||||
|
rstest = "0.26.1"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
|
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,15 @@ pub fn create_invoker_and_assert(
|
||||||
invoker
|
invoker
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn replay_and_assert(invoker: &mut Invoker<SpecctraMesadata>, filename: &str) {
|
pub fn replay_and_assert(invoker: &mut Invoker<SpecctraMesadata>, filename: &str, variant: &str) {
|
||||||
let file = File::open(filename).unwrap();
|
let file = File::open(filename).unwrap();
|
||||||
let history: History = serde_json::from_reader(file).unwrap();
|
let history: History = serde_json::from_reader(file).unwrap();
|
||||||
|
|
||||||
invoker.replay(history);
|
invoker.replay(history);
|
||||||
|
|
||||||
|
if variant == "with_undo_redo_replay" {
|
||||||
assert_undo_redo_replay(invoker, filename);
|
assert_undo_redo_replay(invoker, filename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn assert_undo_redo_replay(invoker: &mut Invoker<SpecctraMesadata>, filename: &str) {
|
pub fn assert_undo_redo_replay(invoker: &mut Invoker<SpecctraMesadata>, filename: &str) {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
use rstest::rstest;
|
||||||
use topola::{
|
use topola::{
|
||||||
autorouter::{
|
autorouter::{
|
||||||
execution::Command,
|
execution::Command,
|
||||||
|
|
@ -14,22 +15,27 @@ use topola::{
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
#[test]
|
#[rstest]
|
||||||
fn test_tht_de9_to_tht_de9_in_order() {
|
#[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 =
|
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);
|
||||||
common::replay_and_assert(
|
common::replay_and_assert(
|
||||||
&mut invoker,
|
&mut invoker,
|
||||||
"tests/single_layer/tht_de9_to_tht_de9/autoroute_all_in_an_order.cmd",
|
"tests/single_layer/tht_de9_to_tht_de9/autoroute_all_in_an_order.cmd",
|
||||||
|
variant,
|
||||||
);
|
);
|
||||||
|
|
||||||
let (mut autorouter, ..) = invoker.dissolve();
|
let (mut autorouter, ..) = invoker.dissolve();
|
||||||
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
|
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[rstest]
|
||||||
fn test_tht_de9_to_tht_de9() {
|
#[case::plain("")]
|
||||||
|
#[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);
|
||||||
|
|
@ -37,20 +43,24 @@ fn test_tht_de9_to_tht_de9() {
|
||||||
common::replay_and_assert(
|
common::replay_and_assert(
|
||||||
&mut invoker,
|
&mut invoker,
|
||||||
"tests/single_layer/tht_de9_to_tht_de9/autoroute_all.cmd",
|
"tests/single_layer/tht_de9_to_tht_de9/autoroute_all.cmd",
|
||||||
|
variant,
|
||||||
);
|
);
|
||||||
|
|
||||||
let (mut autorouter, ..) = invoker.dissolve();
|
let (mut autorouter, ..) = invoker.dissolve();
|
||||||
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
|
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[rstest]
|
||||||
fn test_0603_breakout() {
|
#[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");
|
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);
|
||||||
common::replay_and_assert(
|
common::replay_and_assert(
|
||||||
&mut invoker,
|
&mut invoker,
|
||||||
"tests/single_layer/0603_breakout/autoroute_all.cmd",
|
"tests/single_layer/0603_breakout/autoroute_all.cmd",
|
||||||
|
variant,
|
||||||
);
|
);
|
||||||
|
|
||||||
let (mut autorouter, ..) = invoker.dissolve();
|
let (mut autorouter, ..) = invoker.dissolve();
|
||||||
|
|
@ -59,8 +69,10 @@ fn test_0603_breakout() {
|
||||||
//common::assert_number_of_conncomps(&mut autorouter, 2);
|
//common::assert_number_of_conncomps(&mut autorouter, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[rstest]
|
||||||
fn test_tht_diode_bridge_rectifier() {
|
#[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(
|
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",
|
||||||
);
|
);
|
||||||
|
|
@ -69,6 +81,7 @@ fn test_tht_diode_bridge_rectifier() {
|
||||||
common::replay_and_assert(
|
common::replay_and_assert(
|
||||||
&mut invoker,
|
&mut invoker,
|
||||||
"tests/single_layer/tht_diode_bridge_rectifier/autoroute_all.cmd",
|
"tests/single_layer/tht_diode_bridge_rectifier/autoroute_all.cmd",
|
||||||
|
variant,
|
||||||
);
|
);
|
||||||
|
|
||||||
let (mut autorouter, ..) = invoker.dissolve();
|
let (mut autorouter, ..) = invoker.dissolve();
|
||||||
|
|
@ -95,8 +108,10 @@ fn test_tht_diode_bridge_rectifier() {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[rstest]
|
||||||
fn test_4x_3rd_order_smd_lc_filters() {
|
#[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(
|
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",
|
||||||
);
|
);
|
||||||
|
|
@ -105,6 +120,7 @@ fn test_4x_3rd_order_smd_lc_filters() {
|
||||||
common::replay_and_assert(
|
common::replay_and_assert(
|
||||||
&mut invoker,
|
&mut invoker,
|
||||||
"tests/single_layer/4x_3rd_order_smd_lc_filters/autoroute_signals.cmd",
|
"tests/single_layer/4x_3rd_order_smd_lc_filters/autoroute_signals.cmd",
|
||||||
|
variant,
|
||||||
);
|
);
|
||||||
|
|
||||||
let (mut autorouter, ..) = invoker.dissolve();
|
let (mut autorouter, ..) = invoker.dissolve();
|
||||||
|
|
@ -116,8 +132,10 @@ fn test_4x_3rd_order_smd_lc_filters() {
|
||||||
// FIXME: This test fails indeterministically.
|
// FIXME: This test fails indeterministically.
|
||||||
// NOTE: Disabled until determinism is fixed.
|
// NOTE: Disabled until determinism is fixed.
|
||||||
//#[test]
|
//#[test]
|
||||||
#[allow(unused)]
|
/*#[allow(unused)]
|
||||||
fn test_tht_3pin_xlr_to_tht_3pin_xlr() {
|
#[case("")]
|
||||||
|
#[case("with_undo_redo_replay")]
|
||||||
|
fn test_tht_3pin_xlr_to_tht_3pin_xlr(#[case] variant: &str) {
|
||||||
let mut autorouter = common::load_design(
|
let mut autorouter = common::load_design(
|
||||||
"tests/single_layer/tht_3pin_xlr_to_tht_3pin_xlr/tht_3pin_xlr_to_tht_3pin_xlr.dsn",
|
"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(
|
common::replay_and_assert(
|
||||||
&mut invoker,
|
&mut invoker,
|
||||||
"tests/single_layer/tht_3pin_xlr_to_tht_3pin_xlr/autoroute_all.cmd",
|
"tests/single_layer/tht_3pin_xlr_to_tht_3pin_xlr/autoroute_all.cmd",
|
||||||
|
"undo_redo_replay",
|
||||||
);
|
);
|
||||||
|
|
||||||
let (mut autorouter, ..) = invoker.dissolve();
|
let (mut autorouter, ..) = invoker.dissolve();
|
||||||
|
|
||||||
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
|
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
|
||||||
}
|
}*/
|
||||||
|
|
||||||
#[test]
|
#[rstest]
|
||||||
fn test_vga_dac_breakout() {
|
#[case::plain("")]
|
||||||
|
#[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);
|
||||||
|
|
@ -142,6 +163,7 @@ fn test_vga_dac_breakout() {
|
||||||
common::replay_and_assert(
|
common::replay_and_assert(
|
||||||
&mut invoker,
|
&mut invoker,
|
||||||
"tests/single_layer/vga_dac_breakout/autoroute_all.cmd",
|
"tests/single_layer/vga_dac_breakout/autoroute_all.cmd",
|
||||||
|
variant,
|
||||||
);
|
);
|
||||||
|
|
||||||
let (mut autorouter, ..) = invoker.dissolve();
|
let (mut autorouter, ..) = invoker.dissolve();
|
||||||
|
|
@ -149,8 +171,10 @@ fn test_vga_dac_breakout() {
|
||||||
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
|
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[rstest]
|
||||||
fn test_smd_non_rectangular_buck_converter() {
|
#[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 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);
|
||||||
|
|
||||||
|
|
@ -159,6 +183,7 @@ fn test_smd_non_rectangular_buck_converter() {
|
||||||
common::replay_and_assert(
|
common::replay_and_assert(
|
||||||
&mut invoker,
|
&mut invoker,
|
||||||
"tests/single_layer/smd_non_rectangular_buck_converter/route_all.cmd",
|
"tests/single_layer/smd_non_rectangular_buck_converter/route_all.cmd",
|
||||||
|
variant,
|
||||||
);
|
);
|
||||||
|
|
||||||
let (mut autorouter, ..) = invoker.dissolve();
|
let (mut autorouter, ..) = invoker.dissolve();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue