From bd7aaa6f589f50f813b8da112181501798775706 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Sun, 9 Aug 2026 01:22:20 -0700 Subject: [PATCH] =?UTF-8?q?fix(test):=20shard-mechanics=20tests=20disable?= =?UTF-8?q?=20mem-adaptation=20=E2=80=94=20CI's=207GB=20runner=20collapsed?= =?UTF-8?q?=20explicit=202=20shards=20to=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The runner deliberately adapts even explicit --shards to available memory (GBRAIN_TEST_NO_MEM_ADAPT=1 is the escape hatch); on GitHub's ~7GB runners that collapsed the tests' 2-shard sandbox runs to 1 shard, breaking every 'shard 1/2:' expectation while passing locally. The tests pin shard MECHANICS with tiny synthetic files, so they now set the escape hatch; the one test that checks the mem banner overrides it back on. Co-Authored-By: Claude Fable 5 --- test/scripts/run-unit-parallel.test.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/scripts/run-unit-parallel.test.ts b/test/scripts/run-unit-parallel.test.ts index 0f269aff0..9c7f32455 100644 --- a/test/scripts/run-unit-parallel.test.ts +++ b/test/scripts/run-unit-parallel.test.ts @@ -72,7 +72,10 @@ function runWrapper(extraArgs: string[] = []): { code: number; stdout: string; s const result = spawnSync( 'bash', [join(TMPROOT, 'scripts', 'run-unit-parallel.sh'), '--shards', '2', ...extraArgs], - { cwd: TMPROOT, encoding: 'utf-8', env: { ...process.env } }, + // Shard-mechanics tests pin explicit --shards behavior with tiny + // synthetic files; disable mem-adaptation so a RAM-limited runner (CI's + // ~7GB) can't collapse 2 shards -> 1 and break the shard 1/2 expectations. + { cwd: TMPROOT, encoding: 'utf-8', env: { ...process.env, GBRAIN_TEST_NO_MEM_ADAPT: '1' } }, ); return { code: result.status ?? -1, @@ -209,6 +212,8 @@ describe('passing', () => { HOME: process.env.HOME ?? FROOT, TMPDIR: process.env.TMPDIR ?? '/tmp', GBRAIN_TEST_SHARD_TIMEOUT: '300', + // Same rationale as runWrapper: explicit-shard mechanics under test. + GBRAIN_TEST_NO_MEM_ADAPT: '1', }; }); @@ -304,7 +309,7 @@ describe('oom-once', () => { const result = spawnSync( 'bash', [join(OROOT, 'scripts', 'run-unit-parallel.sh'), '--shards', '2'], - { cwd: OROOT, encoding: 'utf-8', env: { ...process.env, ...env } }, + { cwd: OROOT, encoding: 'utf-8', env: { ...process.env, GBRAIN_TEST_NO_MEM_ADAPT: '1', ...env } }, ); return { code: result.status ?? -1, stdout: result.stdout || '', stderr: result.stderr || '' }; } @@ -323,7 +328,10 @@ describe('oom-once', () => { }, 120_000); it('memory-aware sizing is advertised in the banner (mem-ok or mem-adapted)', () => { - const r = runOom(); + // The one test that needs adaptation ON — override the harness-wide + // NO_MEM_ADAPT base (which keeps the shard-mechanics tests deterministic + // on RAM-limited CI runners). + const r = runOom({ GBRAIN_TEST_NO_MEM_ADAPT: '0' }); expect(r.stderr).toMatch(/mem-(ok|adapted)/); }, 120_000);