@@ -16,6 +16,7 @@ import {
1616 folderSpecs ,
1717 isInteractionSpec ,
1818 legCount ,
19+ legsFitMessage ,
1920 planLegs ,
2021 recordLog ,
2122 selectProofs ,
@@ -37,6 +38,37 @@ const durations = JSON.parse(
3738) ;
3839const step = ( job , name ) => job . steps . find ( each => each . name === name ) ;
3940
41+ describe ( 'legsFitMessage' , ( ) => {
42+ const limits = { setupSeconds : 90 , maxSeconds : 600 , maxLegs : 3 } ;
43+ const costs = { 'a.spec.ts' : 500 , 'b.spec.ts' : 500 , 'c.spec.ts' : 480 } ;
44+
45+ it ( 'fits when the proofs need the last leg the matrix has' , ( ) => {
46+ expect (
47+ legsFitMessage ( { seconds : 1480 , files : Object . keys ( costs ) , costs, ...limits } ) ,
48+ ) . toBeNull ( ) ;
49+ } ) ;
50+
51+ it ( 'names the heaviest specs when the proofs need more legs than the matrix has' , ( ) => {
52+ const more = { ...costs , 'd.spec.ts' : 400 } ;
53+ const message = legsFitMessage ( {
54+ seconds : 1880 ,
55+ files : Object . keys ( more ) ,
56+ costs : more ,
57+ ...limits ,
58+ } ) ;
59+ expect ( message ) . toContain ( 'need 4 legs' ) ;
60+ expect ( message ) . toContain ( 'the matrix has 3' ) ;
61+ expect ( message ) . toContain ( 'a.spec.ts (500 s), b.spec.ts (500 s), c.spec.ts (480 s)' ) ;
62+ } ) ;
63+
64+ it ( 'names the spec when one spec alone outlasts a leg' , ( ) => {
65+ const one = { 'huge.spec.ts' : 700 } ;
66+ expect (
67+ legsFitMessage ( { seconds : 700 , files : [ 'huge.spec.ts' ] , costs : one , ...limits } ) ,
68+ ) . toContain ( 'huge.spec.ts (700 s)' ) ;
69+ } ) ;
70+ } ) ;
71+
4072describe ( 'planLegs' , ( ) => {
4173 const times = { a : 120 , b : 100 , c : 80 , d : 50 , e : 40 , f : 30 , g : 20 , h : 10 } ;
4274 const files = Object . keys ( times ) ;
@@ -290,7 +322,7 @@ describe('the interaction proof legs in ci.yml', () => {
290322 {
291323 id : 'pr-interaction-webkit' ,
292324 project : 'webkit' ,
293- legs : [ 1 , 2 , 3 , 4 , 5 ] ,
325+ legs : [ 1 , 2 , 3 , 4 , 5 , 6 ] ,
294326 run : 'Run WebKit interaction proofs' ,
295327 plan : "Plan this leg's WebKit interaction proofs" ,
296328 evidence : 'interaction-evidence-webkit-${{ matrix.leg }}' ,
@@ -872,34 +904,28 @@ describe('the interaction proof legs in ci.yml', () => {
872904 testsOf,
873905 perTest,
874906 } ) ;
875- // The matrix still has room: the count stays under its legs.
876- const needed = Math . ceil (
877- seconds / ( limits . maxSeconds - limits . setupSeconds ) ,
878- ) ;
907+ // The planner fits the matrix: no more legs than it has, and no leg
908+ // over ten minutes (plus one spec's slack). It fails naming the
909+ // heaviest specs, not by a margin under the matrix.
879910 expect (
880- needed ,
881- `${ label } : ${ Math . round ( seconds ) } s of proofs` ,
882- ) . toBeLessThan ( lane . legs . length ) ;
883- const legsNow = legCount ( { seconds, ...limits } ) ;
884- const planned = planLegs (
885- specs . filter (
886- file =>
887- filters . length === 0 ||
888- filters . some ( each => file . includes ( each ) ) ||
889- changed . includes ( file ) ,
890- ) ,
891- Object . fromEntries (
892- specs . map ( file => [
893- file ,
894- times [ file ] ?? fallback [ file ] ?? testsOf ( file ) * perTest ,
895- ] ) ,
896- ) ,
897- legsNow ,
898- ) ;
899- for ( const leg of planned )
900- expect ( leg . seconds + limits . setupSeconds , label ) . toBeLessThanOrEqual (
901- limits . maxSeconds + 60 ,
902- ) ;
911+ legsFitMessage ( {
912+ seconds,
913+ files : specs . filter (
914+ file =>
915+ filters . length === 0 ||
916+ filters . some ( each => file . includes ( each ) ) ||
917+ changed . includes ( file ) ,
918+ ) ,
919+ costs : Object . fromEntries (
920+ specs . map ( file => [
921+ file ,
922+ times [ file ] ?? fallback [ file ] ?? testsOf ( file ) * perTest ,
923+ ] ) ,
924+ ) ,
925+ ...limits ,
926+ } ) ,
927+ label ,
928+ ) . toBeNull ( ) ;
903929 }
904930 }
905931 } ) ;
0 commit comments