@@ -4,6 +4,8 @@ use crate::testlang::{TestInstructionSet, TestLang};
44use crate :: visualization:: Hierarchy ;
55use zhc_utils:: svec;
66
7+ const PREFIX : & ' static str = "/tmp/" ;
8+
79/// Build a small IR and annotate it with a flat hierarchy (all ops at root).
810#[ test]
911fn test_flat_hierarchy ( ) {
@@ -17,7 +19,7 @@ fn test_flat_hierarchy() {
1719 let root = Hierarchy :: new ( ) ;
1820 let op_annotations = ir. filled_opmap ( root) ;
1921
20- draw_ir_html ( & ir, op_annotations, " test1.html") ;
22+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test1.html") ) ;
2123}
2224
2325/// Build an IR where some ops are in a nested hierarchy level.
@@ -42,7 +44,7 @@ fn test_nested_hierarchy() {
4244 op_annotations. insert ( op2, group_a. clone ( ) ) ;
4345 op_annotations. insert ( op3, root. clone ( ) ) ;
4446
45- draw_ir_html ( & ir, op_annotations, " test2.html") ;
47+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test2.html") ) ;
4648}
4749
4850/// Test with two separate groups at the same level.
@@ -69,7 +71,7 @@ fn test_sibling_groups() {
6971 op_annotations. insert ( op2, group_a. clone ( ) ) ;
7072 op_annotations. insert ( op3, group_b. clone ( ) ) ;
7173 op_annotations. insert ( op4, root. clone ( ) ) ;
72- draw_ir_html ( & ir, op_annotations, " test3.html") ;
74+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test3.html") ) ;
7375}
7476
7577/// Test deeply nested hierarchy (2 levels deep).
@@ -95,7 +97,7 @@ fn test_deep_nesting() {
9597 op_annotations. insert ( op2, group_ab. clone ( ) ) ;
9698 op_annotations. insert ( op3, root. clone ( ) ) ;
9799
98- draw_ir_html ( & ir, op_annotations, " test4.html") ;
100+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test4.html") ) ;
99101}
100102
101103/// Operations along a group boundary (enter/exit same group multiple times).
@@ -119,7 +121,7 @@ fn test_operations_along_group() {
119121 op_annotations. insert ( op2, root. clone ( ) ) ;
120122 op_annotations. insert ( op3, group_a. clone ( ) ) ;
121123 op_annotations. insert ( op4, root. clone ( ) ) ;
122- draw_ir_html ( & ir, op_annotations, " test5.html") ;
124+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test5.html") ) ;
123125}
124126
125127/// Diamond with different path lengths (slack test).
@@ -149,7 +151,7 @@ fn test_diamond_different_slacks() {
149151 op_annotations. insert ( op4, root. clone ( ) ) ;
150152 op_annotations. insert ( op5, root. clone ( ) ) ;
151153 op_annotations. insert ( op6, root. clone ( ) ) ;
152- draw_ir_html ( & ir, op_annotations, " test6.html") ;
154+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test6.html") ) ;
153155}
154156
155157/// Branches with asymmetric slack in nested groups.
@@ -181,7 +183,7 @@ fn test_asymmetric_slack_nested() {
181183 op_annotations. insert ( op3, group_c. clone ( ) ) ;
182184 op_annotations. insert ( op4, root. clone ( ) ) ;
183185 op_annotations. insert ( op5, root. clone ( ) ) ;
184- draw_ir_html ( & ir, op_annotations, " test7.html") ;
186+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test7.html") ) ;
185187}
186188
187189/// Deep entry immediately, slow exit with ops at each level.
@@ -209,7 +211,7 @@ fn test_deep_entry_slow_exit() {
209211 op_annotations. insert ( op2, group_ab. clone ( ) ) ;
210212 op_annotations. insert ( op3, group_a. clone ( ) ) ;
211213 op_annotations. insert ( op4, root. clone ( ) ) ;
212- draw_ir_html ( & ir, op_annotations, " test8.html") ;
214+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test8.html") ) ;
213215}
214216
215217/// Slow entry with ops at each level, deep exit immediately.
@@ -237,7 +239,7 @@ fn test_slow_entry_deep_exit() {
237239 op_annotations. insert ( op2, group_ab. clone ( ) ) ;
238240 op_annotations. insert ( op3, group_abc. clone ( ) ) ;
239241 op_annotations. insert ( op4, root. clone ( ) ) ;
240- draw_ir_html ( & ir, op_annotations, " test9.html") ;
242+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test9.html") ) ;
241243}
242244
243245/// Immediate deep entry and exit (no intermediate ops).
@@ -259,7 +261,7 @@ fn test_immediate_deep_entry_exit() {
259261 op_annotations. insert ( op0, root. clone ( ) ) ;
260262 op_annotations. insert ( op1, group_abc. clone ( ) ) ;
261263 op_annotations. insert ( op2, root. clone ( ) ) ;
262- draw_ir_html ( & ir, op_annotations, " test10.html") ;
264+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test10.html") ) ;
263265}
264266
265267/// Multiple ops deep, immediate jump out and back in.
@@ -285,7 +287,7 @@ fn test_deep_oscillation() {
285287 op_annotations. insert ( op2, root. clone ( ) ) ;
286288 op_annotations. insert ( op3, group_abc. clone ( ) ) ;
287289 op_annotations. insert ( op4, group_abc. clone ( ) ) ;
288- draw_ir_html ( & ir, op_annotations, " test11.html") ;
290+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test11.html") ) ;
289291}
290292
291293/// Fan-out with different nesting depths per branch.
@@ -318,7 +320,7 @@ fn test_fanout_varied_depths() {
318320 op_annotations. insert ( op4, root. clone ( ) ) ;
319321 op_annotations. insert ( op5, root. clone ( ) ) ;
320322 op_annotations. insert ( op6, root. clone ( ) ) ;
321- draw_ir_html ( & ir, op_annotations, " test12.html") ;
323+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test12.html") ) ;
322324}
323325
324326/// Paths of lengths 1-6 converging, producing slacks 5 down to 0.
@@ -416,7 +418,7 @@ fn test_slack_gradient_0_to_5() {
416418 op_annotations. insert ( add4_id, root. clone ( ) ) ;
417419 op_annotations. insert ( add5_id, root. clone ( ) ) ;
418420 op_annotations. insert ( ret_id, root. clone ( ) ) ;
419- draw_ir_html ( & ir, op_annotations, " test13.html") ;
421+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test13.html") ) ;
420422}
421423
422424/// Multi-return op with outputs consumed at different depths.
@@ -447,7 +449,7 @@ fn test_multireturn_different_depths() {
447449 op_annotations. insert ( op4, group_c. clone ( ) ) ; // shallow
448450 op_annotations. insert ( op5, root. clone ( ) ) ;
449451 op_annotations. insert ( op6, root. clone ( ) ) ;
450- draw_ir_html ( & ir, op_annotations, " test14.html") ;
452+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test14.html") ) ;
451453}
452454
453455/// Multiple inputs entering same group from root.
@@ -473,7 +475,7 @@ fn test_multi_input_to_group() {
473475 op_annotations. insert ( op3, group_a. clone ( ) ) ;
474476 op_annotations. insert ( op4, group_a. clone ( ) ) ;
475477 op_annotations. insert ( op5, root. clone ( ) ) ;
476- draw_ir_html ( & ir, op_annotations, " test15.html") ;
478+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test15.html") ) ;
477479}
478480
479481/// Group produces multiple outputs consumed by different ops at root.
@@ -501,7 +503,7 @@ fn test_multi_output_from_group() {
501503 op_annotations. insert ( op4, root. clone ( ) ) ;
502504 op_annotations. insert ( op5, root. clone ( ) ) ;
503505 op_annotations. insert ( op6, root. clone ( ) ) ;
504- draw_ir_html ( & ir, op_annotations, " test16.html") ;
506+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test16.html") ) ;
505507}
506508
507509/// Multiple inputs and outputs crossing group boundary simultaneously.
@@ -531,7 +533,7 @@ fn test_multi_io_group() {
531533 op_annotations. insert ( op5, root. clone ( ) ) ;
532534 op_annotations. insert ( op6, root. clone ( ) ) ;
533535 op_annotations. insert ( op7, root. clone ( ) ) ;
534- draw_ir_html ( & ir, op_annotations, " test17.html") ;
536+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test17.html") ) ;
535537}
536538
537539/// Large diamond subgraph entirely within a group.
@@ -563,7 +565,7 @@ fn test_big_subgraph_diamond() {
563565 op_annotations. insert ( op5, group_a. clone ( ) ) ;
564566 op_annotations. insert ( op6, group_a. clone ( ) ) ;
565567 op_annotations. insert ( op7, root. clone ( ) ) ;
566- draw_ir_html ( & ir, op_annotations, " test18.html") ;
568+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test18.html") ) ;
567569}
568570
569571/// Chain of 8 ops inside nested group with single entry/exit.
@@ -597,7 +599,7 @@ fn test_long_chain_in_nested_group() {
597599 op_annotations. insert ( op7, group_ab. clone ( ) ) ;
598600 op_annotations. insert ( op8, group_ab. clone ( ) ) ;
599601 op_annotations. insert ( op9, root. clone ( ) ) ;
600- draw_ir_html ( & ir, op_annotations, " test19.html") ;
602+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test19.html") ) ;
601603}
602604
603605/// Cross-group edges: two groups each receive input and produce output to the other.
@@ -630,7 +632,7 @@ fn test_cross_group_multi_edge() {
630632 op_annotations. insert ( op5, group_a. clone ( ) ) ;
631633 op_annotations. insert ( op6, root. clone ( ) ) ;
632634 op_annotations. insert ( op7, root. clone ( ) ) ;
633- draw_ir_html ( & ir, op_annotations, " test20.html") ;
635+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test20.html") ) ;
634636}
635637
636638/// Nested groups with multiple inputs at different depths.
@@ -664,7 +666,7 @@ fn test_multi_input_nested_depths() {
664666 op_annotations. insert ( op5, group_ab. clone ( ) ) ;
665667 op_annotations. insert ( op6, group_ab. clone ( ) ) ;
666668 op_annotations. insert ( op7, root. clone ( ) ) ;
667- draw_ir_html ( & ir, op_annotations, " test21.html") ;
669+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test21.html") ) ;
668670}
669671
670672/// Group with internal fanout: one input, multiple parallel chains, multiple outputs.
@@ -700,7 +702,7 @@ fn test_group_internal_fanout() {
700702 op_annotations. insert ( op7, root. clone ( ) ) ;
701703 op_annotations. insert ( op8, root. clone ( ) ) ;
702704 op_annotations. insert ( op9, root. clone ( ) ) ;
703- draw_ir_html ( & ir, op_annotations, " test22.html") ;
705+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test22.html") ) ;
704706}
705707
706708/// Two groups each with internal diamond, connected in sequence.
@@ -738,7 +740,7 @@ fn test_sequential_diamonds_in_groups() {
738740 op_annotations. insert ( op7, group_b. clone ( ) ) ;
739741 op_annotations. insert ( op8, group_b. clone ( ) ) ;
740742 op_annotations. insert ( op9, root. clone ( ) ) ;
741- draw_ir_html ( & ir, op_annotations, " test23.html") ;
743+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test23.html") ) ;
742744}
743745
744746/// Five inputs feeding into a deep nested group, five outputs exiting to root.
@@ -779,7 +781,7 @@ fn test_wide_io_deep_group() {
779781 for id in [ c0, c1, c2, c3, r] {
780782 op_annotations. insert ( id, root. clone ( ) ) ;
781783 }
782- draw_ir_html ( & ir, op_annotations, " test24.html") ;
784+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test24.html") ) ;
783785}
784786
785787/// Two parallel paths with crossing edges if not reordered.
@@ -802,7 +804,7 @@ fn test_crossing_two_parallel() {
802804 for id in [ a, b, c, d, e, r] {
803805 op_annotations. insert ( id, root. clone ( ) ) ;
804806 }
805- draw_ir_html ( & ir, op_annotations, " test25.html") ;
807+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test25.html") ) ;
806808}
807809
808810/// Three inputs, three outputs, all cross-connected (K₃,₃ bipartite).
@@ -831,7 +833,7 @@ fn test_bipartite_k33() {
831833 for id in [ a, b, c, d, d2, e, e2, f, f2, g, h, r] {
832834 op_annotations. insert ( id, root. clone ( ) ) ;
833835 }
834- draw_ir_html ( & ir, op_annotations, " test26.html") ;
836+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test26.html") ) ;
835837}
836838
837839/// Fan-out to 4 children, connected to fan-in in reversed order.
@@ -861,7 +863,7 @@ fn test_fanout_reversed_fanin() {
861863 for id in [ inp, a, b, c, d, w, x, y, z, m1, m2, m3, r] {
862864 op_annotations. insert ( id, root. clone ( ) ) ;
863865 }
864- draw_ir_html ( & ir, op_annotations, " test27.html") ;
866+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test27.html") ) ;
865867}
866868
867869/// Ladder pattern: pairs connected with alternating cross-links.
@@ -890,7 +892,7 @@ fn test_ladder_alternating() {
890892 for id in [ a0, b0, a1, b1, a2, b2, a3, b3, m, r] {
891893 op_annotations. insert ( id, root. clone ( ) ) ;
892894 }
893- draw_ir_html ( & ir, op_annotations, " test28.html") ;
895+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test28.html") ) ;
894896}
895897
896898/// Permuted parallel chains: 4 chains inserted in shuffled order.
@@ -926,7 +928,7 @@ fn test_permuted_chains() {
926928 ] {
927929 op_annotations. insert ( id, root. clone ( ) ) ;
928930 }
929- draw_ir_html ( & ir, op_annotations, " test29.html") ;
931+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test29.html") ) ;
930932}
931933
932934/// Single source, multiple sinks at same depth with shared intermediate.
@@ -955,7 +957,7 @@ fn test_shared_intermediate_multi_sink() {
955957 for id in [ inp, mid, s0, s1, s2, t0, t1, t2, c1, c2, r] {
956958 op_annotations. insert ( id, root. clone ( ) ) ;
957959 }
958- draw_ir_html ( & ir, op_annotations, " test30.html") ;
960+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test30.html") ) ;
959961}
960962
961963/// Wide layer (8 nodes) with butterfly-pattern edges to next layer.
@@ -1014,7 +1016,7 @@ fn test_butterfly_wide() {
10141016 for id in [ c0, c1, c2, c3, d0, d1, e, r] {
10151017 op_annotations. insert ( id, root. clone ( ) ) ;
10161018 }
1017- draw_ir_html ( & ir, op_annotations, " test31.html") ;
1019+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test31.html") ) ;
10181020}
10191021
10201022/// Crossing within nested group — reordering must respect hierarchy.
@@ -1044,7 +1046,7 @@ fn test_crossing_in_group() {
10441046 }
10451047 op_annotations. insert ( m, root. clone ( ) ) ;
10461048 op_annotations. insert ( r, root. clone ( ) ) ;
1047- draw_ir_html ( & ir, op_annotations, " test32.html") ;
1049+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test32.html") ) ;
10481050}
10491051
10501052/// Cross-group edges that would cross if groups aren't reordered.
@@ -1074,7 +1076,7 @@ fn test_cross_group_reorder() {
10741076 op_annotations. insert ( b, group_b) ;
10751077 op_annotations. insert ( m, root. clone ( ) ) ;
10761078 op_annotations. insert ( r, root. clone ( ) ) ;
1077- draw_ir_html ( & ir, op_annotations, " test33.html") ;
1079+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test33.html") ) ;
10781080}
10791081
10801082/// Bug reproducer: GroupInput shares layer 1 with an IntInput inside the group.
@@ -1112,7 +1114,7 @@ fn test_mixed_first_layer_in_group() {
11121114 op_annotations. insert ( op_add1, group_a. clone ( ) ) ;
11131115 op_annotations. insert ( op_add2, group_a. clone ( ) ) ;
11141116 op_annotations. insert ( op_ret, root. clone ( ) ) ;
1115- draw_ir_html ( & ir, op_annotations, " test34.html") ;
1117+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test34.html") ) ;
11161118}
11171119
11181120/// Bug reproducer: GroupOutput shares last layer with a Return inside the group.
@@ -1151,5 +1153,5 @@ fn test_mixed_last_layer_in_group() {
11511153 op_annotations. insert ( op_inc2, group_a. clone ( ) ) ;
11521154 op_annotations. insert ( op_internal_ret, group_a. clone ( ) ) ;
11531155 op_annotations. insert ( op_ret, root. clone ( ) ) ;
1154- draw_ir_html ( & ir, op_annotations, " test35.html") ;
1156+ draw_ir_html ( & ir, op_annotations, & format ! ( "{PREFIX} test35.html") ) ;
11551157}
0 commit comments