test: Test tht_de9_to_tht_de9 with permuted autorouting as well

This commit is contained in:
Mikolaj Wielgus 2025-07-19 16:11:08 +02:00
parent 09c98f2d17
commit 2b95832cf7
3 changed files with 127 additions and 6 deletions

View File

@ -12,7 +12,7 @@ use topola::{
Autorouter,
},
board::{edit::BoardEdit, AccessMesadata, Board},
drawing::graph::GetMaybeNet,
drawing::graph::{GetMaybeNet, PrimitiveIndex},
geometry::{shape::MeasureLength, GenericNode, GetLayer},
graph::{GetPetgraphIndex, MakeRef},
router::{navmesh::Navmesh, RouterOptions},
@ -77,10 +77,7 @@ pub fn replay_and_assert(invoker: &mut Invoker<SpecctraMesadata>, filename: &str
let file = File::open(filename).unwrap();
let history: History = serde_json::from_reader(file).unwrap();
for _ in 0..history.done().len() {
invoker.undo().unwrap();
}
undo_all_and_assert(invoker);
invoker.replay(history);
assert_eq!(
@ -89,6 +86,31 @@ pub fn replay_and_assert(invoker: &mut Invoker<SpecctraMesadata>, filename: &str
);
}
pub fn undo_all_and_assert(invoker: &mut Invoker<SpecctraMesadata>) {
for _ in 0..invoker.history().done().len() {
invoker.undo().unwrap();
}
assert!(matches!(
invoker.undo(),
Err(InvokerError::History(HistoryError::NoPreviousCommand))
));
assert_no_loose_nodes(invoker.autorouter());
}
pub fn assert_no_loose_nodes(autorouter: &Autorouter<impl AccessMesadata>) {
for node in autorouter.board().layout().drawing().primitive_nodes() {
match node {
PrimitiveIndex::LooseDot(..)
| PrimitiveIndex::LoneLooseSeg(..)
| PrimitiveIndex::SeqLooseSeg(..)
| PrimitiveIndex::LooseBend(..) => assert!(false),
_ => (),
}
}
}
pub fn assert_navnode_count(
autorouter: &mut Autorouter<SpecctraMesadata>,
origin_pin: &str,

View File

@ -24,9 +24,16 @@ fn test_tht_de9_to_tht_de9() {
"tests/single_layer/tht_de9_to_tht_de9/autoroute_all_in_an_order.cmd",
);
let (mut autorouter, ..) = invoker.dissolve();
let (mut autorouter, history, ..) = invoker.dissolve();
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
invoker = Invoker::new_with_history(autorouter, history);
common::undo_all_and_assert(&mut invoker);
common::replay_and_assert(
&mut invoker,
"tests/single_layer/tht_de9_to_tht_de9/autoroute_all.cmd",
);
}
#[test]

View File

@ -0,0 +1,92 @@
{
"done": [
{
"Autoroute": [
[
{
"pin": "J1-1",
"layer": "F.Cu"
},
{
"pin": "J1-2",
"layer": "F.Cu"
},
{
"pin": "J1-3",
"layer": "F.Cu"
},
{
"pin": "J1-4",
"layer": "F.Cu"
},
{
"pin": "J1-5",
"layer": "F.Cu"
},
{
"pin": "J1-6",
"layer": "F.Cu"
},
{
"pin": "J1-7",
"layer": "F.Cu"
},
{
"pin": "J1-8",
"layer": "F.Cu"
},
{
"pin": "J1-9",
"layer": "F.Cu"
},
{
"pin": "J2-1",
"layer": "F.Cu"
},
{
"pin": "J2-2",
"layer": "F.Cu"
},
{
"pin": "J2-3",
"layer": "F.Cu"
},
{
"pin": "J2-4",
"layer": "F.Cu"
},
{
"pin": "J2-5",
"layer": "F.Cu"
},
{
"pin": "J2-6",
"layer": "F.Cu"
},
{
"pin": "J2-7",
"layer": "F.Cu"
},
{
"pin": "J2-8",
"layer": "F.Cu"
},
{
"pin": "J2-9",
"layer": "F.Cu"
}
],
{
"presort_by": "RatlineIntersectionCountAndLength",
"permutate": true,
"router_options": {
"routed_band_width": 100.0,
"wrap_around_bands": true,
"squeeze_through_under_bends": true
}
}
]
}
],
"undone": []
}