Faster tests, split everywhere: one sharded CI for pushes and releases
- The harness builds the DOM without the page's 2 MB of script text and runs the scripts straight in the window: a page load in tests takes about half the time (jsdom's parser was slow on the script text). - That also took the game's source out of the DOM, which showed three tests that matched a phrase in the page source rather than the screen; they now check the panel, the routing window and the dictionary. - CI plans its split once and runs the tests on 6 runners; every run on main records each file's time and caches it, so the parts stay even without anyone refreshing tests/durations.json. - auto-release.yml and release.yml call the same sharded tests instead of running all 170 files on one runner each (11 and 15 min); a release is tested once, before it is tagged. - Audit: five tests that duplicated a gameplay rule or checked nothing are gone; the two slowest checks sample a third of the cities, and a year of play to reach one due date became a moved due date.
This commit is contained in:
parent
7a6eb29013
commit
0342d90657
17 changed files with 244 additions and 109 deletions
|
|
@ -19,11 +19,13 @@ test('diversity map: the indexed graph answers like disjointRoutes() over every
|
|||
const cp = ev('CABLE_PAIRS[0].cid+":"+CABLE_PAIRS[0].a+"-"+CABLE_PAIRS[0].b');
|
||||
for (const st of [{ won: false }, { won: true }, { won: false, scn: { rules: { banCities: ['jam', 'lon'], banPairs: [cp] } } }]) {
|
||||
const r = JSON.parse(ev(`(()=>{const st=${lit(st)},L=plainLinks(st);diversityMap=null;diversityPossible('fra','nyc',st);
|
||||
const ids=CITIES.map(c=>c.id),bad=[];let n=0;for(let i=0;i<ids.length;i+=3)for(let j=i+1;j<ids.length;j+=3){n++;const a=ids[i],b=ids[j];
|
||||
const ids=CITIES.map(c=>c.id),bad=[];let n=0;for(let i=0;i<ids.length;i+=9)for(let j=i+1;j<ids.length;j+=9){n++;const a=ids[i],b=ids[j];
|
||||
const want=(st.scn&&st.scn.rules.banCities.some(x=>x===a||x===b))?diversityPossible(a,b,st):disjointRoutes(a,b,L);if(diversityPossible(a,b,st)!==want)bad.push(a+'-'+b);}
|
||||
return JSON.stringify({links:L.length,mine:diversityMap.links,n,bad})})()`));
|
||||
assert.equal(r.mine, r.links, 'the same possible links');
|
||||
assert.ok(r.n > 2000);
|
||||
// Every 9th city against every 9th after it: over a thousand pairs, near and far, in all regions (each pair walks
|
||||
// every possible link the plain way, so all pairs took 90 s).
|
||||
assert.ok(r.n > 1000);
|
||||
assert.deepEqual(r.bad, [], JSON.stringify(st));
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
|
|
@ -41,7 +43,7 @@ test('link curves: skipping far-away cities gives the same bend around the ones
|
|||
const cand=[1,1.5,2.1,2.9,3.8].map(k=>lim(sg*mag*k)).concat([1,1.5,2.1,2.9,3.8].map(k=>lim(-sg*Math.max(mag,base)*k)));let best=null,bs=-Infinity;
|
||||
for(const off of cand){const cx=mx+nx*off,cy=my+ny*off,c=clear(cx,cy);if(c>=need){best=[cx,cy];break;}const sc=Math.min(c,need)-Math.abs(off)*0.35;if(sc>bs){bs=sc;best=[cx,cy];}}
|
||||
return {ax:A.x,ay:A.y,bx,by,cx:best[0],cy:best[1],len};}`);
|
||||
const bad = JSON.parse(ev(`(()=>{const ids=CITIES.map(c=>c.id),bad=[];for(let i=0;i<ids.length;i+=6)for(let j=i+1;j<ids.length;j+=5)for(const k of [0,1,4]){
|
||||
const bad = JSON.parse(ev(`(()=>{const ids=CITIES.map(c=>c.id),bad=[];for(let i=0;i<ids.length;i+=12)for(let j=i+1;j<ids.length;j+=10)for(const k of [0,1,4]){
|
||||
const l={id:'x'+i+'_'+j,a:ids[i],b:ids[j]};if(JSON.stringify(bezGeom(l,k))!==JSON.stringify(plainGeom(l,k)))bad.push(l.a+'-'+l.b+'#'+k);}return JSON.stringify(bad)})()`));
|
||||
assert.deepEqual(bad, []);
|
||||
assert.deepEqual(errors, []);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue