@@ -67,10 +67,18 @@ fn workloads_run_and_print_their_pinned_lines() {
6767
6868/// The workloads README claims "committed data == the generator's output".
6969/// This test makes that a checked fact, not a manual claim: each gen.py is
70- /// copied to a temp dir, run there (it writes next to itself), and every file
71- /// it produced must byte-equal the committed one.
70+ /// copied to a temp dir, run there (it writes next to itself), and the set of
71+ /// generated data files must match the committed data set **both ways** — every
72+ /// generated file byte-equals its committed twin, and no committed data file is
73+ /// left that the generator no longer produces (a stale file would otherwise
74+ /// survive silently). Non-data companions are excluded by an allowlist.
7275#[ test]
7376fn committed_workload_data_equals_generator_output ( ) {
77+ // Files that live in a workload dir but are not generator output.
78+ let is_companion = |name : & std:: ffi:: OsStr | {
79+ let n = name. to_string_lossy ( ) ;
80+ n == "gen.py" || n == "README.md" || n. ends_with ( ".strata" )
81+ } ;
7482 let python = "python3" ;
7583 if Command :: new ( python) . arg ( "--version" ) . output ( ) . is_err ( ) {
7684 panic ! ( "python3 is required to verify the workload generators" ) ;
@@ -90,9 +98,12 @@ fn committed_workload_data_equals_generator_output() {
9098 "gen.py for `{dir}` failed:\n {}" ,
9199 String :: from_utf8_lossy( & out. stderr) ,
92100 ) ;
101+
102+ // Generated data files (the temp dir also holds the copied gen.py).
103+ let mut generated_names: Vec < String > = Vec :: new ( ) ;
93104 for entry in fs:: read_dir ( & tmp) . expect ( "read temp dir" ) {
94105 let name = entry. expect ( "entry" ) . file_name ( ) ;
95- if name == "gen.py" {
106+ if is_companion ( & name) {
96107 continue ;
97108 }
98109 let generated = fs:: read ( tmp. join ( & name) ) . expect ( "read generated" ) ;
@@ -104,6 +115,19 @@ fn committed_workload_data_equals_generator_output() {
104115 "committed {dir}/{name:?} differs from the generator's output — \
105116 regenerate or update gen.py",
106117 ) ;
118+ generated_names. push ( name. to_string_lossy ( ) . into_owned ( ) ) ;
119+ }
120+
121+ // The other direction: no committed data file the generator dropped.
122+ for entry in fs:: read_dir ( & src_dir) . expect ( "read workload dir" ) {
123+ let name = entry. expect ( "entry" ) . file_name ( ) ;
124+ if is_companion ( & name) {
125+ continue ;
126+ }
127+ assert ! (
128+ generated_names. contains( & name. to_string_lossy( ) . into_owned( ) ) ,
129+ "committed {dir}/{name:?} is not produced by gen.py — a stale data file" ,
130+ ) ;
107131 }
108132 let _ = fs:: remove_dir_all ( & tmp) ;
109133 }
0 commit comments