@@ -57,37 +57,54 @@ def main() -> int:
5757 if not media_root .exists ():
5858 raise SystemExit (f"Missing materialized tree: { media_root } " )
5959
60- bunny_path = media_root / "assets/mesh/standalone/stl/Stanford_Bunny.stl"
61- yellowflower_path = media_root / "assets/mesh/bundles/obj/yellowflower.zip"
62- required_paths = (bunny_path , yellowflower_path )
63- for path in required_paths :
64- if not path .exists ():
65- raise SystemExit (f"Missing required file: { path } " )
66-
67- files = list (iter_files (media_root ))
60+ files = sorted (iter_files (media_root ))
6861 if not files :
6962 raise SystemExit (f"No files found under { media_root } " )
7063
7164 counts = {"symlink" : 0 , "hardlink" : 0 , "copy" : 0 }
7265 logical_size = 0
7366 estimated_extra_size = 0
67+ largest_files : list [dict [str , object ]] = []
68+ mismatches : list [str ] = []
69+ zip_file_count = 0
70+ invalid_zip_files : list [str ] = []
7471 for path in files :
7572 materialization , file_size , extra_size = classify_materialization (path )
73+ relative_path = path .relative_to (build_dir ).as_posix ()
7674 counts [materialization ] += 1
7775 logical_size += file_size
7876 estimated_extra_size += extra_size
79-
80- sample_modes : dict [str , str ] = {}
81- for path in required_paths :
82- materialization , _ , _ = classify_materialization (path )
83- sample_modes [str (path .relative_to (build_dir ))] = materialization
8477 if materialization != args .expected_mode :
85- raise SystemExit (
86- f"Expected `{ args .expected_mode } ` for { path .name } but found `{ materialization } `"
87- )
88-
89- if not zipfile .is_zipfile (yellowflower_path ):
90- raise SystemExit (f"Expected a zip payload at { yellowflower_path } " )
78+ mismatches .append (f"{ relative_path } ={ materialization } " )
79+ if path .suffix .lower () == ".zip" :
80+ zip_file_count += 1
81+ if not zipfile .is_zipfile (path ):
82+ invalid_zip_files .append (relative_path )
83+ largest_files .append (
84+ {
85+ "path" : relative_path ,
86+ "mode" : materialization ,
87+ "size_bytes" : file_size ,
88+ "size_human" : format_bytes (file_size ),
89+ }
90+ )
91+
92+ largest_files .sort (key = lambda entry : (- int (entry ["size_bytes" ]), str (entry ["path" ])))
93+ largest_files = largest_files [:5 ]
94+
95+ if mismatches :
96+ preview = ", " .join (mismatches [:5 ])
97+ raise SystemExit (
98+ f"Expected `{ args .expected_mode } ` for all { len (files )} files under { media_root } "
99+ f"but found { len (mismatches )} mismatches. First mismatches: { preview } "
100+ )
101+
102+ if invalid_zip_files :
103+ preview = ", " .join (invalid_zip_files [:5 ])
104+ raise SystemExit (
105+ f"Expected every materialized .zip payload to stay a valid zip file, "
106+ f"but found { len (invalid_zip_files )} invalid files. First invalid entries: { preview } "
107+ )
91108
92109 summary = {
93110 "build_dir" : str (build_dir ),
@@ -99,7 +116,8 @@ def main() -> int:
99116 "logical_size_human" : format_bytes (logical_size ),
100117 "estimated_extra_size_bytes" : estimated_extra_size ,
101118 "estimated_extra_size_human" : format_bytes (estimated_extra_size ),
102- "sample_modes" : sample_modes ,
119+ "zip_file_count" : zip_file_count ,
120+ "largest_files" : largest_files ,
103121 }
104122
105123 print (json .dumps (summary , indent = 2 , sort_keys = True ))
@@ -114,9 +132,14 @@ def main() -> int:
114132 f"- Counts: `symlink={ counts ['symlink' ]} ` `hardlink={ counts ['hardlink' ]} ` `copy={ counts ['copy' ]} `" ,
115133 f"- Logical size: `{ format_bytes (logical_size )} `" ,
116134 f"- Estimated extra size in build tree: `{ format_bytes (estimated_extra_size )} `" ,
117- f"- Stanford_Bunny.stl: `{ sample_modes [str (bunny_path .relative_to (build_dir ))]} `" ,
118- f"- yellowflower.zip: `{ sample_modes [str (yellowflower_path .relative_to (build_dir ))]} `" ,
135+ f"- Valid zip payloads: `{ zip_file_count } `" ,
119136 ]
137+ if largest_files :
138+ lines .extend (("" , "### Largest materialized files" ))
139+ for entry in largest_files :
140+ lines .append (
141+ f"- `{ entry ['path' ]} ` `{ entry ['mode' ]} ` `{ entry ['size_human' ]} `"
142+ )
120143 Path (step_summary ).write_text ("\n " .join (lines ) + "\n " , encoding = "utf-8" )
121144
122145 return 0
0 commit comments