From 6d4dcc1174f4c6382233e12cfa9a211ddde367db Mon Sep 17 00:00:00 2001 From: Tam Nhu Tran Date: Wed, 22 Apr 2026 16:00:39 -0400 Subject: [PATCH] fix(ci): keep fast bucket stable for commonjs tests --- scripts/run-test-bucket.js | 11 +++++++++++ tests/unit/scripts/run-test-bucket.test.js | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/scripts/run-test-bucket.js b/scripts/run-test-bucket.js index da2cdc68..4cd682d6 100644 --- a/scripts/run-test-bucket.js +++ b/scripts/run-test-bucket.js @@ -24,6 +24,12 @@ const slowTests = [ 'tests/unit/web-server/cursor-routes.test.ts', 'tests/unit/web-server/websearch-routes.test.ts', ]; +// CommonJS-heavy JS suites stay slow by default because many of them mutate +// module cache or process state. Opt them into `test:fast` only after they are +// proven stable in the mixed fast bucket. +const fastJsTests = new Set([ + 'tests/unit/flag-parsing-simple.test.js', +]); const filePattern = /(\.test\.(c|m)?[jt]s|\.spec\.(c|m)?[jt]s|-test\.(c|m)?[jt]s)$/; @@ -59,6 +65,10 @@ function shouldForceSlow(file) { return true; } + if (/\.(c|m)?js$/.test(file) && !fastJsTests.has(file)) { + return true; + } + return readsBuiltDist(file); } @@ -149,6 +159,7 @@ if (require.main === module) { module.exports = { slowTests, + fastJsTests, readsBuiltDist, shouldForceSlow, getDiscoveredTests, diff --git a/tests/unit/scripts/run-test-bucket.test.js b/tests/unit/scripts/run-test-bucket.test.js index b4a1213d..d9c79ef2 100644 --- a/tests/unit/scripts/run-test-bucket.test.js +++ b/tests/unit/scripts/run-test-bucket.test.js @@ -18,6 +18,10 @@ describe('run-test-bucket', () => { expect(bucket.shouldForceSlow('tests/unit/flag-parsing-simple.test.js')).toBe(false); }); + test('keeps non-allowlisted javascript tests in the slow bucket', () => { + expect(bucket.shouldForceSlow('tests/unit/commands/persist-command.test.js')).toBe(true); + }); + test('still forces dist-dependent tests into the slow bucket', () => { expect(bucket.shouldForceSlow('tests/unit/config-dir-override.test.js')).toBe(true); });