tests: fix 0603 breakout test by passing a command file

This commit is contained in:
Mikolaj Wielgus 2024-05-25 00:33:58 +02:00
parent 2f8cccea07
commit a757576fe3
3 changed files with 42 additions and 11 deletions

View File

@ -206,8 +206,8 @@ impl eframe::App for App {
execute(async move { execute(async move {
if let Some(file_handle) = task.await { if let Some(file_handle) = task.await {
let path = file_handle.path(); let path = file_handle.path();
let mut file = File::open(path).unwrap();
let mut invoker = invoker_arc_mutex.lock().unwrap(); let mut invoker = invoker_arc_mutex.lock().unwrap();
let mut file = File::open(path).unwrap();
invoker.replay(serde_json::from_reader(file).unwrap()); invoker.replay(serde_json::from_reader(file).unwrap());
} }
}); });
@ -223,8 +223,8 @@ impl eframe::App for App {
execute(async move { execute(async move {
if let Some(file_handle) = task.await { if let Some(file_handle) = task.await {
let path = file_handle.path(); let path = file_handle.path();
let mut file = File::create(path).unwrap();
let mut invoker = invoker_arc_mutex.lock().unwrap(); let mut invoker = invoker_arc_mutex.lock().unwrap();
let mut file = File::create(path).unwrap();
serde_json::to_writer_pretty(file, invoker.history()); serde_json::to_writer_pretty(file, invoker.history());
} }
}); });

View File

@ -2,11 +2,17 @@ use petgraph::{
unionfind::UnionFind, unionfind::UnionFind,
visit::{EdgeRef, IntoEdgeReferences, NodeIndexable}, visit::{EdgeRef, IntoEdgeReferences, NodeIndexable},
}; };
use std::sync::{Arc, Mutex}; use std::{
fs::File,
sync::{Arc, Mutex},
};
use topola::{ use topola::{
autorouter::Autorouter, dsn::design::DsnDesign, graph::GetNodeIndex, autorouter::{invoker::Invoker, Autorouter},
router::EmptyRouterObserver, triangulation::GetVertexIndex, dsn::design::DsnDesign,
graph::GetNodeIndex,
router::EmptyRouterObserver,
triangulation::GetVertexIndex,
}; };
#[test] #[test]
@ -14,8 +20,9 @@ fn test() {
let design = DsnDesign::load_from_file("tests/data/0603_breakout/0603_breakout.dsn").unwrap(); let design = DsnDesign::load_from_file("tests/data/0603_breakout/0603_breakout.dsn").unwrap();
let layout_arc_mutex = Arc::new(Mutex::new(design.make_layout())); let layout_arc_mutex = Arc::new(Mutex::new(design.make_layout()));
let mut autorouter = Autorouter::new(layout_arc_mutex.clone()).unwrap(); let mut invoker = Invoker::new(Autorouter::new(layout_arc_mutex.clone()).unwrap());
autorouter.autoroute(&mut EmptyRouterObserver); let file = File::open("tests/data/0603_breakout/autoroute_all.cmd").unwrap();
invoker.replay(serde_json::from_reader(file).unwrap());
let layout = layout_arc_mutex.lock().unwrap(); let layout = layout_arc_mutex.lock().unwrap();
let mut unionfind = UnionFind::new(layout.drawing().geometry().graph().node_bound()); let mut unionfind = UnionFind::new(layout.drawing().geometry().graph().node_bound());
@ -25,7 +32,8 @@ fn test() {
} }
assert_eq!( assert_eq!(
autorouter invoker
.autorouter()
.ratsnest() .ratsnest()
.graph() .graph()
.edge_indices() .edge_indices()
@ -34,15 +42,17 @@ fn test() {
2 2
); );
for ratline in autorouter.ratsnest().graph().edge_references() { for ratline in invoker.autorouter().ratsnest().graph().edge_references() {
let from_index = autorouter let from_index = invoker
.autorouter()
.ratsnest() .ratsnest()
.graph() .graph()
.node_weight(ratline.source()) .node_weight(ratline.source())
.unwrap() .unwrap()
.vertex_index() .vertex_index()
.node_index(); .node_index();
let to_index = autorouter let to_index = invoker
.autorouter()
.ratsnest() .ratsnest()
.graph() .graph()
.node_weight(ratline.target()) .node_weight(ratline.target())

View File

@ -0,0 +1,21 @@
{
"done": [
{
"Autoroute": {
"pins": [
"R1-2",
"J1-2"
]
}
},
{
"Autoroute": {
"pins": [
"J1-1",
"R1-1"
]
}
}
],
"undone": []
}