@@ -140,8 +140,10 @@ def expected_from_artifacts(build_root: Path) -> dict[tuple[str, str, str, str],
140140    return  expected 
141141
142142
143- def  scan_executed_xml (xml_root : Path ) ->  dict [tuple [str , str , str , str ], int ]:
144-     """Return executed counts per (platform, target, type, sketch).""" 
143+ def  scan_executed_xml (xml_root : Path , valid_types : set [str ]) ->  dict [tuple [str , str , str , str ], int ]:
144+     """Return executed counts per (platform, target, type, sketch). 
145+     Type/sketch/target are inferred from .../<type>/<sketch>/<target>/<file>.xml 
146+     """ 
145147    counts : dict [tuple [str , str , str , str ], int ] =  {}
146148    if  not  xml_root .exists ():
147149        print (f"[DEBUG] Results root not found: { xml_root }  , file = sys .stderr )
@@ -156,18 +158,17 @@ def scan_executed_xml(xml_root: Path) -> dict[tuple[str, str, str, str], int]:
156158            platform  =  "wokwi" 
157159        elif  "test-results-qemu-"  in  rel :
158160            platform  =  "qemu" 
159-         # Expect tests/<type>/<sketch>/<target>/<sketch>.xml 
160-         # Find 'tests' segment 
161+         # Expect .../<type>/<sketch>/<target>/*.xml 
161162        parts  =  xml_path .parts 
162-         try : 
163-              t_idx   =   parts . index ( "tests" ) 
164-         except   ValueError :
165-             continue 
166-         if  t_idx  +   4  >=  len (parts ):
163+         t_idx   =   - 1 
164+         for   i ,  p   in   enumerate ( parts ): 
165+              if   p   in   valid_types :
166+                  t_idx   =   i 
167+         if  t_idx  ==   - 1   or   t_idx   +   3  >=  len (parts ):
167168            continue 
168-         test_type  =  parts [t_idx   +   1 ]
169-         sketch  =  parts [t_idx  +  2 ]
170-         target  =  parts [t_idx  +  3 ]
169+         test_type  =  parts [t_idx ]
170+         sketch  =  parts [t_idx  +  1 ]
171+         target  =  parts [t_idx  +  2 ]
171172        key  =  (platform , target , test_type , sketch )
172173        counts [key ] =  counts .get (key , 0 ) +  1 
173174    print (f"[DEBUG] Executed entries discovered: { len (counts )}  , file = sys .stderr )
@@ -227,7 +228,8 @@ def main():
227228    qemu_types  =  parse_array (os .environ .get ("QEMU_TYPES" , "[]" ))
228229
229230    expected  =  expected_from_artifacts (build_root )  # (platform, target, type, sketch) -> expected_count 
230-     executed  =  scan_executed_xml (results_root )      # (platform, target, type, sketch) -> count 
231+     executed_types  =  set (hw_types  +  wokwi_types  +  qemu_types )
232+     executed  =  scan_executed_xml (results_root , executed_types )      # (platform, target, type, sketch) -> count 
231233    print (f"[DEBUG] Expected entries computed: { len (expected )}  , file = sys .stderr )
232234
233235    # Filter expected by enabled platforms and target/type matrices 
0 commit comments