test: fan out the gates and build shared binaries once
Every Nim test file and every Node test file is already isolated (own temp state dir, free ports, own server/nginx), so run them FFF_TEST_JOBS at a time (default half the cores, capped at 8) instead of one at a time. The real server (clean, leakfault, dispfault) and the leak checker are built once per source+flags and shared across the parallel files; nimcaches are worktree-local so two checkouts cannot race on them. The 22 independent fault cases are sharded across processes. The wall-clock gate files (persistence, tiles; e2e map/fog/fogbench/ perf) still run alone first so their budgets are not measured under the suite's own load. No test or assertion changes.
This commit is contained in:
+13
-9
@@ -34,7 +34,7 @@
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { spawnSync } from 'node:child_process'
|
||||
import { createPlayer, namePlayer, openWs, sleep, projectRoot, isWindow, anchorOf } from './lib.mjs'
|
||||
import { cachedNimBuild, createPlayer, namePlayer, openWs, sleep, projectRoot, isWindow, anchorOf } from './lib.mjs'
|
||||
import { signIn } from './withserver.mjs'
|
||||
|
||||
const QUIET_MS = 60
|
||||
@@ -43,18 +43,22 @@ const QUIET_MS = 60
|
||||
const FAR_WALL_X = 1400
|
||||
const nimblePkgs = () => path.join(process.env.NIMBLE_DIR ?? path.join(projectRoot, '.devbox', 'nimble'), 'pkgs2')
|
||||
|
||||
// The checker is compiled once per process (it imports server/geometry.nim through --path in nim.cfg).
|
||||
// The checker is compiled once per process (it imports server/geometry.nim through --path in nim.cfg),
|
||||
// and once per source+flags across the concurrently-running files (cachedNimBuild). Its nimcache is
|
||||
// worktree-local (run/nimcache/leakcheck) so two checkouts cannot share object files.
|
||||
let checkerBin = null
|
||||
export function buildChecker() {
|
||||
if (checkerBin) return checkerBin
|
||||
const out = path.join(projectRoot, 'run', 'test', 'leakcheck')
|
||||
fs.mkdirSync(path.dirname(out), { recursive: true })
|
||||
const r = spawnSync('nim', ['c', '--hints:off', '-d:release', `--nimblePath:${nimblePkgs()}`,
|
||||
`-o:${out}`, path.join('tools', 'leakcheck.nim')],
|
||||
{ cwd: projectRoot, encoding: 'utf8' })
|
||||
if (r.status !== 0) throw new Error(`nim c tools/leakcheck.nim failed:\n${r.stdout}\n${r.stderr}`)
|
||||
checkerBin = out
|
||||
return out
|
||||
checkerBin = cachedNimBuild({
|
||||
out,
|
||||
roots: [path.join('tools', 'leakcheck.nim'), 'server', 'nim.cfg'],
|
||||
extra: `-d:release\n${nimblePkgs()}\n`,
|
||||
nimArgs: tmp => ['c', '--hints:off', '-d:release', `--nimblePath:${nimblePkgs()}`,
|
||||
`--nimcache:${path.join(projectRoot, 'run', 'nimcache', 'leakcheck')}`,
|
||||
`-o:${tmp}`, path.join('tools', 'leakcheck.nim')],
|
||||
})
|
||||
return checkerBin
|
||||
}
|
||||
|
||||
export function runChecker(transcript, subject) {
|
||||
|
||||
Reference in New Issue
Block a user