mutation: parallel jobs in temp copies, per-mutation test files, FFF_MUTATION reduced iterations, trap cleanup, sleep inhibit

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-08 19:19:58 +01:00
co-authored by Claude Sonnet 5.5
parent dcb8efa422
commit 8d3b77add4
3 changed files with 69 additions and 35 deletions
+12 -7
View File
@@ -1,3 +1,4 @@
# FFF_MUTATION=1 (set only by tools/mutation.sh) cuts iteration counts ~10x via scaled(); plain `devbox run test` runs full counts.
import std/[unittest, json, os, math]
import geometry, refold, testutil
@@ -233,7 +234,10 @@ suite "corpus (prototype leak transcripts)":
var sc = loadScene()
let base = sc.walls
var n, doorsSeen = 0
var li = 0
for line in lines(currentSourcePath().parentDir / "fixtures" / "corpus.jsonl"):
inc li
if li mod (300 div scaled(300)) != 0: continue # quick mode: every 10th record
let j = parseJson(line)
var walls = base
for w in walls.mitems:
@@ -247,7 +251,7 @@ suite "corpus (prototype leak transcripts)":
check cellsTouched(poly, sc.cell) == cellsTouchedOld(poly, sc.cell)
check cellsTouched(rec, sc.cell) == cellsTouchedOld(rec, sc.cell)
inc n
check n >= 300 # corpus is not silently empty
check n >= scaled(300) # corpus is not silently empty
check doorsSeen > 0 # and exercises opened doors
# ---- differential: scanline vs prototype per-cell ---------------------------------------------------------------
@@ -255,7 +259,7 @@ suite "cellsTouched differential vs prototype":
test "random visibility polygons: identical cell lists":
var r = Rng(s: 0x9E3779B97F4A7C15'u64)
var total = 0
for iter in 0 ..< 300:
for iter in 0 ..< scaled(300):
let walls = randomWalls(r, 5 + iter mod 40, 1200)
let o: Vec = (r.uni(100, 1100), r.uni(100, 1100))
let cell = [32.0, 64.0, 25.0][iter mod 3]
@@ -263,10 +267,10 @@ suite "cellsTouched differential vs prototype":
let (a, b) = (cellsTouched(poly, cell), cellsTouchedOld(poly, cell))
check a == b
total += a.len
check total > 10000
check total > scaled(10000)
test "random simple polygons (star-shaped, concave): identical cell lists":
var r = Rng(s: 12345'u64)
for iter in 0 ..< 300:
for iter in 0 ..< scaled(300):
let c: Vec = (r.uni(100, 500), r.uni(100, 500))
let n = 3 + iter mod 20
var poly: seq[Vec]
@@ -277,7 +281,7 @@ suite "cellsTouched differential vs prototype":
check cellsTouched(poly, 32) == cellsTouchedOld(poly, 32)
test "grid-aligned integer polygons (edges on cell lines): identical cell lists":
var r = Rng(s: 777'u64)
for iter in 0 ..< 300:
for iter in 0 ..< scaled(300):
let x0 = float(int(r.uni(0, 10))) * 16
let y0 = float(int(r.uni(0, 10))) * 16
let poly = [(x0, y0), (x0 + float(1 + int(r.uni(0, 8))) * 16, y0),
@@ -359,12 +363,13 @@ suite "explored oracle (independent, tolerance 0.5 px)":
if w.door: w.open = true
var sure = 0
for walls in [sc.walls, opened]:
for p in sc.tokens:
for ti, p in sc.tokens:
if ti mod (300 div scaled(300)) != 0: continue # quick mode: every 10th token
let r = oracleOf((p.x + 7.3, p.y - 3.1), walls, sc.radius, sc.cell)
check r.miss == 0
check r.extra == 0
sure += r.sure
check sure > 100000 # the oracle really sampled
check sure > scaled(100000) # the oracle really sampled
test "random wall fields, cell 32 and 25":
var r = Rng(s: 4242'u64)
for iter in 0 ..< 6: