Skip to content

Commit d9441da

Browse files
piquark6046muse-spark-1.3-contributor via TokenGuard
andcommitted
fix(ci): stream upstream fixtures to lower worker memory
Load tests/fixtures/upstream.json through readFileSync instead of a static JSON import so the 30MB corpus is collected promptly, and release each rule group after registering its RuleTester cases. Keeps catalog and upstream assertions identical while cutting peak heap on memory-constrained macOS runners. Co-authored-by: muse-spark-1.3-contributor via TokenGuard <noreply-noemail@adguard.com>
1 parent f1d61f6 commit d9441da

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

‎tests/catalog.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ import { describe, expect, it } from 'vitest';
99
import { catalog, severity } from '../packages/rule-catalog/src/index';
1010
import { customCases } from './custom-cases';
1111
import { gapCases } from './gap-cases';
12-
import upstream from './fixtures/upstream.json' with { type: 'json' };
12+
13+
import type { Fixture } from './harness';
14+
15+
const upstream = JSON.parse(
16+
readFileSync(new URL('./fixtures/upstream.json', import.meta.url), 'utf8'),
17+
) as Fixture[];
1318

1419
const helpers = ['react/jsx-uses-react', 'react/jsx-uses-vars'];
1520

‎tests/upstream.test.ts‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
/**
22
* @file Attributed upstream behavior regressions executed by Oxlint's RuleTester.
33
*/
4+
import { readFileSync } from 'node:fs';
45
import { RuleTester } from 'oxlint/plugins-dev';
56
import { describe, it } from 'vitest';
67

7-
import fixtures from './fixtures/upstream.json' with { type: 'json' };
88
import { getRule, testCase } from './harness';
99

1010
import type { Fixture } from './harness';
1111

1212
RuleTester.describe = describe;
1313
RuleTester.it = it;
1414

15-
Object.values(Object.groupBy(fixtures as Fixture[], (fixture) => fixture.sourceRule)).forEach((group) => {
15+
const fixtures = JSON.parse(readFileSync(new URL('./fixtures/upstream.json', import.meta.url), 'utf8')) as Fixture[];
16+
17+
for (const group of Object.values(Object.groupBy(fixtures, (fixture) => fixture.sourceRule))) {
1618
const first = group?.[0];
1719
if (!first) {
18-
return;
20+
continue;
1921
}
22+
const valid = group.filter((fixture) => fixture.errors.length === 0).map(testCase);
23+
const invalid = group.filter((fixture) => fixture.errors.length > 0).map(testCase) as RuleTester.InvalidTestCase[];
2024
const tester = new RuleTester({ eslintCompat: true });
21-
tester.run(first.sourceRule, getRule(first), {
22-
valid: group.filter((fixture) => fixture.errors.length === 0).map(testCase),
23-
invalid: group.filter((fixture) => fixture.errors.length > 0).map(testCase) as RuleTester.InvalidTestCase[],
24-
});
25-
});
25+
tester.run(first.sourceRule, getRule(first), { valid, invalid });
26+
group.length = 0;
27+
}

0 commit comments

Comments
 (0)