ci(scope): narrow #494 invariant — changed tests join windows lane, not full matrix
full_matrix fired on 15/15 sampled PRs because any tests/** change forced it, costing ~25 runner-minutes each. A changed test file now always joins the scoped windows lane (covering the #482 OS-specific failure class per-file) and still runs on ubuntu 22/24 via targeted_tests; the residual macOS / windows-node-22 cross-product is covered on every push to next. Also narrows WINDOWS_HINTS from 6 substrings (102/633 files, a ~10-minute scoped lane) to windows/win32/shell/path — the dropped hints (workflow, install, hook) are either platform-independent lint tests or already covered by fullMatrix rules. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -279,18 +279,36 @@ describe('ci-test-scope.cjs', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('ci-test-scope superset invariant (#494)', () => {
|
||||
// Facet A: any tests/** change → full_matrix === true
|
||||
test('A1: a specific changed test file forces full_matrix', () => {
|
||||
describe('ci-test-scope superset invariant (#494, narrowed)', () => {
|
||||
// Facet A (narrowed): a changed test file no longer triggers the full
|
||||
// parity matrix — instead it must ALWAYS run on the scoped windows lane,
|
||||
// so OS-specific breakage in the changed test (the #482 class) is still
|
||||
// exercised pre-merge. Ubuntu 22/24 coverage comes via targeted_tests.
|
||||
test('A1: a changed test file joins the windows scoped lane without full_matrix', () => {
|
||||
const result = scopeFor(['tests/bug-1974-context-exhaustion-record.test.cjs']);
|
||||
assert.strictEqual(result.full_matrix, true,
|
||||
`expected full_matrix=true for tests/** change, got: ${JSON.stringify(result)}`);
|
||||
assert.strictEqual(result.full_matrix, false,
|
||||
`expected full_matrix=false for a tests/**-only change, got: ${JSON.stringify(result)}`);
|
||||
assert.ok(result.targeted_tests.includes('tests/bug-1974-context-exhaustion-record.test.cjs'),
|
||||
`expected the changed test in targeted_tests, got: ${JSON.stringify(result.targeted_tests)}`);
|
||||
assert.ok(result.windows_tests.includes('tests/bug-1974-context-exhaustion-record.test.cjs'),
|
||||
`expected the changed test in windows_tests, got: ${JSON.stringify(result.windows_tests)}`);
|
||||
});
|
||||
|
||||
test('A2: any tests/** path forces full_matrix', () => {
|
||||
test('A2: a changed test file with no windows hint still joins the windows lane', () => {
|
||||
// commands.test.cjs matches none of the WINDOWS_HINTS substrings — the
|
||||
// unconditional changed-test → windows lane rule must include it anyway.
|
||||
const result = scopeFor(['tests/commands.test.cjs']);
|
||||
assert.strictEqual(result.full_matrix, false);
|
||||
assert.ok(result.windows_tests.includes('tests/commands.test.cjs'),
|
||||
`expected hint-less changed test in windows_tests, got: ${JSON.stringify(result.windows_tests)}`);
|
||||
});
|
||||
|
||||
test('A3: a deleted/nonexistent test path falls back to the unit token, no full_matrix', () => {
|
||||
const result = scopeFor(['tests/some-new.test.cjs']);
|
||||
assert.strictEqual(result.full_matrix, true,
|
||||
`expected full_matrix=true for tests/** change, got: ${JSON.stringify(result)}`);
|
||||
assert.strictEqual(result.full_matrix, false);
|
||||
// The nonexistent file is filtered by existingTests(); with nothing left,
|
||||
// the #408 fallback applies so the targeted lane still runs something.
|
||||
assert.deepStrictEqual(result.targeted_tests, ['unit']);
|
||||
});
|
||||
|
||||
// Facet B: commands/**, agents/** → code_changed AND docs-parity selected
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
const { test, describe } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
|
||||
const { CROSS_PLATFORM_TEST_REASON, runCrossPlatformTests } = require('../scripts/run-cross-platform-tests.cjs');
|
||||
|
||||
describe('run cross-platform tests module', () => {
|
||||
test('returns pass reason on zero exit', () => {
|
||||
const out = runCrossPlatformTests({}, {
|
||||
spawnSync: () => ({ status: 0, stdout: 'ok', stderr: '' }),
|
||||
});
|
||||
assert.strictEqual(out.ok, true);
|
||||
assert.strictEqual(out.reason, CROSS_PLATFORM_TEST_REASON.PASS);
|
||||
assert.ok(out.command.includes('--base next'));
|
||||
});
|
||||
|
||||
test('classifies infrastructure failure', () => {
|
||||
const out = runCrossPlatformTests({}, {
|
||||
spawnSync: () => ({ status: 2, stdout: '', stderr: 'infrastructure failure' }),
|
||||
});
|
||||
assert.strictEqual(out.ok, false);
|
||||
assert.strictEqual(out.reason, CROSS_PLATFORM_TEST_REASON.INFRA_FAILURE);
|
||||
});
|
||||
|
||||
test('classifies test failure from FAIL marker', () => {
|
||||
const out = runCrossPlatformTests({}, {
|
||||
spawnSync: () => ({ status: 1, stdout: 'linux FAIL 1/2 tests (1 failures)', stderr: '' }),
|
||||
});
|
||||
assert.strictEqual(out.ok, false);
|
||||
assert.strictEqual(out.reason, CROSS_PLATFORM_TEST_REASON.TEST_FAILURE);
|
||||
});
|
||||
|
||||
test('passes options through to command args', () => {
|
||||
let cmd = null;
|
||||
let args = null;
|
||||
runCrossPlatformTests({ base: 'main', head: 'abc123', source: '/tmp/x', targets: 'linux' }, {
|
||||
spawnSync: (c, a) => {
|
||||
cmd = c;
|
||||
args = a;
|
||||
return { status: 0, stdout: '', stderr: '' };
|
||||
},
|
||||
});
|
||||
|
||||
assert.strictEqual(cmd, 'gsd-test');
|
||||
assert.deepStrictEqual(args, ['--targets', 'linux', '--base', 'main', '--head', 'abc123', '--source', '/tmp/x']);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user