fix(ci): keep fast bucket stable for commonjs tests

This commit is contained in:
Tam Nhu Tran
2026-04-22 16:00:39 -04:00
parent 5af639ddf7
commit 6d4dcc1174
2 changed files with 15 additions and 0 deletions
+11
View File
@@ -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,
@@ -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);
});