fix(test): stop hard-requiring the literal ok) case label in gbrain-refresh guards

The extractor grepped for 'ok)' but the case label grew to
ok|timeout|thin-client) (#1964, #2051), so the whole file errored on
import — the free suite's only red for months. The extractor now matches
any label starting with ok and its alternations; all 7 guard assertions
run again.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Garry Tan 2026-08-13 10:34:25 -07:00
parent 92a107db13
commit 8278322a70
No known key found for this signature in database
GPG Key ID: C1F69E85C74EFE1D
1 changed files with 9 additions and 4 deletions

View File

@ -9,13 +9,18 @@ import * as fs from 'fs';
const ROOT = path.resolve(import.meta.dir, '..');
const SRC = fs.readFileSync(path.join(ROOT, 'bin', 'gstack-config'), 'utf-8');
// Pull out just the gbrain-refresh `ok)` branch so assertions can't be
// satisfied by unrelated text elsewhere in the file.
// Pull out just the gbrain-refresh healthy-status branch so assertions can't
// be satisfied by unrelated text elsewhere in the file. The case label grew
// from `ok)` to `ok|timeout|thin-client)` (#1964, #2051) and may grow again,
// so match any label that STARTS with `ok` followed by alternations.
function okBranch(): string {
const start = SRC.indexOf('gbrain-refresh)');
const ok = SRC.indexOf('ok)', start);
if (start < 0) throw new Error('Could not locate gbrain-refresh case');
const labelMatch = /^\s*ok(?:\|[\w-]+)*\)/m.exec(SRC.slice(start));
if (!labelMatch) throw new Error('Could not locate gbrain-refresh ok) branch');
const ok = start + labelMatch.index;
const end = SRC.indexOf(';;', ok);
if (start < 0 || ok < 0 || end < 0) throw new Error('Could not locate gbrain-refresh ok) branch');
if (end < 0) throw new Error('Could not locate gbrain-refresh ok) branch terminator');
return SRC.slice(ok, end);
}