Skip to content

Commit 9dc0bb5

Browse files
committed
chore(gates): harden the test-only fixture subpath pin
- The R11 accept/deny test now pins TEST_ONLY_FIXTURE_SUBPATHS against an independent expectation before iterating it, so deleting an entry from the checker's set can no longer take its production-denial coverage with it. - The non-production consumer predicate recognizes package-local test trees (packages/*/test/), not just the root test/ directory: a package harness importing a fixture subpath is a test consumer, matching how R13's file vocabulary treats harness trees. Pin extends the accept list accordingly.
1 parent adb2748 commit 9dc0bb5

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎scripts/layering/package-boundaries.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,19 @@ test('the test-only fixture subpaths accept test consumers and deny production o
337337
externalDependencies: new Map(),
338338
};
339339
const rootDeps = new Set(consumer.workspaceDependencies);
340+
// Pin the set independently: iterating the checker's own set would let deleting an entry
341+
// silently delete its accept/deny coverage with it.
342+
assert.deepEqual([...TEST_ONLY_FIXTURE_SUBPATHS].sort(), [
343+
'@agent-device/device-selection/inventory-gateways-fixtures',
344+
'@agent-device/replay-port/replay-script-source-fixtures',
345+
]);
340346
for (const specifier of TEST_ONLY_FIXTURE_SUBPATHS) {
341347
const sites = (file: string) => specifierSites(file, `import { f } from '${specifier}';`);
342348
for (const file of [
343349
'src/daemon/__tests__/consumer.test.ts',
344350
'test/integration/consumer.ts',
345351
'packages/daemon-side/src/__tests__/consumer.test.ts',
352+
'packages/daemon-side/test/harness.ts',
346353
]) {
347354
assert.deepEqual(checkRootSites(sites(file), ALL, rootDeps, true), [], file);
348355
assert.deepEqual(checkPackageInternalSites(consumer, sites(file), ALL, true), [], file);

‎scripts/layering/package-boundaries.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,10 @@ export const TEST_ONLY_FIXTURE_SUBPATHS: ReadonlySet<string> = new Set([
184184
/** Consumer side of `TEST_ONLY_FIXTURE_SUBPATHS`, mirroring R13's non-production predicate. */
185185
function importsTestOnlyFixtureFromProduction(file: string, specifier: string): boolean {
186186
if (!TEST_ONLY_FIXTURE_SUBPATHS.has(specifier)) return false;
187+
// Root `test/`, package-local `packages/*/test/`, *.test.ts, and __tests__ trees are all
188+
// test consumers; anything else is production.
187189
const isTestConsumer =
188-
file.startsWith('test/') || file.endsWith('.test.ts') || file.includes('/__tests__/');
190+
/(?:^|\/)test\//.test(file) || file.endsWith('.test.ts') || file.includes('/__tests__/');
189191
return !isTestConsumer;
190192
}
191193

0 commit comments

Comments
 (0)