@@ -86,20 +86,31 @@ describe("check gate", () => {
8686 } ) ;
8787
8888 test ( "CI test shards cover exactly the suite's paths" , ( ) => {
89+ // Time-balanced --shard slices each run the full union (bun partitions
90+ // files across the slices, balanced by --timings), so coverage holds
91+ // when the matrix has all four slices and the shard command template
92+ // carries the suite's paths plus the interpolated --shard flag.
8993 // Sharding must never silently drop (or double-run) part of the suite:
90- // expanding the matrix shards' filters to test files has to equal the
91- // unsharded `test` script's paths expanded the same way. Subdirectory
92- // shards (src-a/b/c) can never equal the literal ./src string, so this
93- // compares sorted file sets; a file covered twice fails the equality
94- // through the duplicate entry.
95- const shardFilters = [ ...ci . matchAll ( / ^ \s + p a t h s : ( .+ ) $ / gm) ] . flatMap (
96- ( match ) => match [ 1 ] ?. trim ( ) . split ( / \s + / ) ?? [ ] ,
97- ) ;
94+ // expanding the template's filters to test files has to equal the
95+ // unsharded `test` script's paths expanded the same way.
96+ for ( const shard of [ "1/4" , "2/4" , "3/4" , "4/4" ] ) {
97+ expect ( ci ) . toContain ( `"${ shard } "` ) ;
98+ }
99+ const runArgs = [
100+ ...ci . matchAll ( / ^ \s * r u n : b u n r u n c h e c k : p r o j e c t s - d i r - g u a r d ( .+ ) $ / gm) ,
101+ ]
102+ . map ( ( match ) => match [ 1 ] ?? "" )
103+ . find ( ( args ) => args . includes ( "--shard=${{ matrix.shard }}" ) ) ;
104+ expect ( runArgs ) . toBeDefined ( ) ;
105+ const shardFilters = ( runArgs ?? "" )
106+ . split ( / \s + / )
107+ . filter ( ( part ) => part . startsWith ( "./" ) ) ;
98108 const suiteFilters = TEST_SUITE . split ( " " ) . filter ( ( part ) =>
99109 part . startsWith ( "./" ) ,
100110 ) ;
101111 expect ( expandToTestFiles ( shardFilters ) ) . toEqual (
102112 expandToTestFiles ( suiteFilters ) ,
103113 ) ;
114+ expect ( runArgs ) . toContain ( "--timings=./scripts/ci-timings.json" ) ;
104115 } ) ;
105116} ) ;
0 commit comments