test(red): prove every id of round 4.5a red at ab6b32c, with a judge that is tested to go red

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-10-24 19:23:59 +02:00
commit 5476a36782
Signed by: ktg
SSH key fingerprint: SHA256:JakMjO6FTBBzN0Bhfj9saOoEjaFxlSdYuZQQpM/lF9Q
5 changed files with 629 additions and 0 deletions

View file

@ -1437,3 +1437,49 @@ test('e2e script: it names each of the four CLIs it runs', () => {
assert.ok(text.includes(cli), `the e2e script does not run ${cli}`);
}
});
// --- red script: tests/fix-round-4-5a-red.sh --------------------------------
// The round's red proof (the brief's last criterion). Static pins only: the
// script runs itself as the step's Regression:. Its judge is tested to go red
// in tests/lib/red-judge.test.mjs. The 30 ids are the brief's (brief.md:134
// and the 4.5a rows), written here as a constant so the list in the script
// cannot shrink without this test noticing.
const RED_SCRIPT = 'tests/fix-round-4-5a-red.sh';
const RED_IDS = ['#52', '#47', '#48', '#46', '#2', '#26', '#33', '#1', '#30', '#28', 'R6', 'D67', '#15', '#12', '#66',
'#102', '#57', '#67', '#113', '#111', '#24', '#23', 'F9', 'F4a', 'F4b', 'F4c', 'WF', 'CL', 'ORD', 'DJ'];
test('red script: tests/fix-round-4-5a-red.sh exists, is ASCII only, passes /bin/bash -n and uses no bash 4 form', () => {
assert.ok(existsSync(join(ROOT, RED_SCRIPT)), `missing file ${RED_SCRIPT}`);
const buf = readFileSync(join(ROOT, RED_SCRIPT));
assert.equal(buf.findIndex((b) => b > 127), -1, 'the red script is not ASCII only');
const r = spawnSync('/bin/bash', ['-n', join(ROOT, RED_SCRIPT)], { encoding: 'utf8', env: childEnv() });
assert.equal(r.status, 0, r.stderr);
const text = buf.toString('utf8');
assert.match(text, /^set -u$/m, 'the red script does not set -u');
for (const bash4 of [/\bdeclare -A\b/, /\bmapfile\b/, /\breadarray\b/, /\|&/, /^\s*[A-Za-z_]+=\(/m, /\$\{[A-Za-z_]+,,\}/]) {
assert.doesNotMatch(text, bash4, `the red script uses ${bash4}, which bash 3.2 lacks or the round forbids`);
}
});
test('red script: an EXIT trap removes $TMP, and INT, TERM and HUP remove it too', () => {
const text = read(RED_SCRIPT);
assert.match(text, /^TMP="\$\(mktemp -d [^\n]*\)"/m, 'the red script does not make $TMP with mktemp -d');
assert.match(text, /^trap 'rm -rf "\$TMP"' EXIT$/m, 'no EXIT trap removes $TMP');
assert.match(text, /^trap '[^'\n]*rm -rf "\$TMP"[^'\n]*' INT TERM HUP$/m, 'no INT/TERM/HUP trap removes $TMP');
});
test('red script: BASE is the full ab6b32c sha', () => {
const text = read(RED_SCRIPT);
const lines = text.split('\n').filter((l) => /^BASE=/.test(l));
assert.deepEqual(lines, ['BASE=ab6b32c9304534b77c7ca2b36e7c993682c9efde'], 'BASE is not the one full ab6b32c sha');
});
test('red script: the id list is the round\'s 30 ids, in the brief\'s order', () => {
const text = read(RED_SCRIPT);
const lines = text.split('\n').filter((l) => /^IDS=/.test(l));
assert.equal(lines.length, 1, `expected one IDS= line; found ${lines.length}`);
const m = lines[0].match(/^IDS='([^']*)'$/);
assert.ok(m, `the IDS= line is not one single-quoted list: ${lines[0]}`);
assert.deepEqual(m[1].trim().split(/\s+/), RED_IDS);
});