Skip to content

Commit dea914c

Browse files
committed
chore(gates): register check-test-tmpdir in the catalog and tooling lane
Wire check:test-tmpdir and check:test-tmpdir:test into check:tooling, register the test-tmpdir / test-tmpdir-model gates in CHECK_CATALOG + CheckId, and run both as repo-guards CI steps so the raw-os.tmpdir-in-tests invariant is enforced and the gate manifest stays complete.
1 parent a92ebed commit dea914c

9 files changed

Lines changed: 20 additions & 29 deletions

File tree

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ jobs:
138138
uses: ./.github/actions/run-gate
139139
with: { gate: tmpdir-leaks-model }
140140

141+
# Product test files must create scratch through mkdtempForTest, not os.tmpdir(), so it
142+
# lands under the run's redirected TMPDIR and is removed once per run.
143+
- name: Fail if a product test reads os.tmpdir() directly
144+
uses: ./.github/actions/run-gate
145+
with: { gate: test-tmpdir }
146+
147+
- name: Check the raw-os.tmpdir test-file gate model
148+
uses: ./.github/actions/run-gate
149+
with: { gate: test-tmpdir-model }
150+
141151
# The selector is fail-open and advisory (GitHub CI stays authoritative),
142152
# so the gate only guards the derivation model.
143153
- name: Check affected-selector model

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,14 @@
160160
"check:packaged-runner-swift": "node --experimental-strip-types scripts/check-packaged-runner-swift.ts",
161161
"check:tmpdir-leaks": "node --experimental-strip-types scripts/check-tmpdir-leaks.ts",
162162
"check:tmpdir-leaks:test": "node --experimental-strip-types scripts/node-test-tmpdir.ts --experimental-strip-types --test scripts/check-tmpdir-leaks-model.test.ts scripts/vitest-tmpdir-global-setup.test.ts scripts/node-test-tmpdir.test.ts scripts/swift-toolchain-tmpdir.test.ts",
163+
"check:test-tmpdir": "node --experimental-strip-types scripts/check-test-tmpdir.ts",
164+
"check:test-tmpdir:test": "node --experimental-strip-types scripts/node-test-tmpdir.ts --experimental-strip-types --test scripts/check-test-tmpdir-model.test.ts",
163165
"check:freerange": "fr",
164166
"check:quick": "pnpm lint && pnpm typecheck",
165167
"sync:mcp-metadata": "node scripts/sync-mcp-metadata.mjs",
166168
"check:mcp-metadata": "node scripts/sync-mcp-metadata.mjs --check",
167169
"version": "pnpm sync:mcp-metadata && git add server.json",
168-
"check:tooling": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm check:layering && pnpm depgraph:test && pnpm check:gate-manifest:test && pnpm check:gate-manifest && pnpm check:production-exports && pnpm check:tmpdir-leaks:test && pnpm check:xctest-selection && pnpm check:packaged-runner-swift && pnpm check:mcp-metadata && pnpm build && pnpm check:bundle-owner-files && pnpm check:package",
170+
"check:tooling": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm check:layering && pnpm depgraph:test && pnpm check:gate-manifest:test && pnpm check:gate-manifest && pnpm check:production-exports && pnpm check:tmpdir-leaks:test && pnpm check:test-tmpdir:test && pnpm check:test-tmpdir && pnpm check:xctest-selection && pnpm check:packaged-runner-swift && pnpm check:mcp-metadata && pnpm build && pnpm check:bundle-owner-files && pnpm check:package",
169171
"check:unit": "pnpm test:unit && pnpm check:tmpdir-leaks && pnpm test:smoke",
170172
"check": "pnpm check:tooling && pnpm check:fallow && pnpm check:unit",
171173
"prepack": "pnpm check:mcp-metadata && pnpm package:npm",
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import fs from 'node:fs';
21
import fsPromises from 'node:fs/promises';
32
import os from 'node:os';
43
import path from 'node:path';
@@ -7,8 +6,3 @@ import path from 'node:path';
76
export async function mkdtempForTest(prefix: string): Promise<string> {
87
return fsPromises.mkdtemp(path.join(os.tmpdir(), prefix));
98
}
10-
11-
// fallow-ignore-next-line code-duplication
12-
export function mkdtempForTestSync(prefix: string): string {
13-
return fs.mkdtempSync(path.join(os.tmpdir(), prefix));
14-
}
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import fs from 'node:fs';
2-
import fsPromises from 'node:fs/promises';
32
import os from 'node:os';
43
import path from 'node:path';
54

@@ -10,12 +9,6 @@ import path from 'node:path';
109
* individual tests never need their own afterEach/afterAll for this.
1110
*/
1211
// fallow-ignore-next-line code-duplication
13-
export async function mkdtempForTest(prefix: string): Promise<string> {
14-
return fsPromises.mkdtemp(path.join(os.tmpdir(), prefix));
15-
}
16-
17-
/** Sync counterpart of {@link mkdtempForTest}, for setup code that can't await. */
18-
// fallow-ignore-next-line code-duplication
1912
export function mkdtempForTestSync(prefix: string): string {
2013
return fs.mkdtempSync(path.join(os.tmpdir(), prefix));
2114
}
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import fs from 'node:fs';
21
import fsPromises from 'node:fs/promises';
32
import os from 'node:os';
43
import path from 'node:path';
@@ -13,9 +12,3 @@ import path from 'node:path';
1312
export async function mkdtempForTest(prefix: string): Promise<string> {
1413
return fsPromises.mkdtemp(path.join(os.tmpdir(), prefix));
1514
}
16-
17-
/** Sync counterpart of {@link mkdtempForTest}, for setup code that can't await. */
18-
// fallow-ignore-next-line code-duplication
19-
export function mkdtempForTestSync(prefix: string): string {
20-
return fs.mkdtempSync(path.join(os.tmpdir(), prefix));
21-
}
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import fs from 'node:fs';
2-
import fsPromises from 'node:fs/promises';
32
import os from 'node:os';
43
import path from 'node:path';
54

@@ -10,12 +9,6 @@ import path from 'node:path';
109
* individual tests never need their own afterEach/afterAll for this.
1110
*/
1211
// fallow-ignore-next-line code-duplication
13-
export async function mkdtempForTest(prefix: string): Promise<string> {
14-
return fsPromises.mkdtemp(path.join(os.tmpdir(), prefix));
15-
}
16-
17-
/** Sync counterpart of {@link mkdtempForTest}, for setup code that can't await. */
18-
// fallow-ignore-next-line code-duplication
1912
export function mkdtempForTestSync(prefix: string): string {
2013
return fs.mkdtempSync(path.join(os.tmpdir(), prefix));
2114
}

scripts/check-affected/checks.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ export const CHECK_CATALOG: readonly CheckSpec[] = [
103103
gate('depgraph', 'Dependency graph report model', 'depgraph:test'),
104104
gate('tmpdir-leaks', 'Leaked test tmpdir detector', 'check:tmpdir-leaks'),
105105
gate('tmpdir-leaks-model', 'TMPDIR redirection model', 'check:tmpdir-leaks:test'),
106+
gate('test-tmpdir', 'Raw os.tmpdir() in product tests', 'check:test-tmpdir'),
107+
gate('test-tmpdir-model', 'Raw-os.tmpdir test-file gate model', 'check:test-tmpdir:test'),
106108
gate('coverage-model', 'Changed-line coverage model', 'check:coverage-changed:test'),
107109
gate('wire-compat-model', 'Wire-compat rules model', 'check:daemon-wire-compat:test'),
108110
gate('production-exports', 'Production-unused exports', 'check:production-exports'),

scripts/check-affected/model.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ export type CheckId =
6363
| 'depgraph'
6464
| 'tmpdir-leaks'
6565
| 'tmpdir-leaks-model'
66+
| 'test-tmpdir'
67+
| 'test-tmpdir-model'
6668
| 'coverage-model'
6769
| 'wire-compat-model'
6870
| 'production-exports'
@@ -129,6 +131,8 @@ export const ALL_CHECKS: readonly CheckId[] = [
129131
'depgraph',
130132
'tmpdir-leaks',
131133
'tmpdir-leaks-model',
134+
'test-tmpdir',
135+
'test-tmpdir-model',
132136
'coverage-model',
133137
'wire-compat-model',
134138
'production-exports',

scripts/check-test-tmpdir-model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function isTestFile(file: string): boolean {
5959
}
6060

6161
/** Every tracked test file under the scanned roots, repo-root-relative. */
62-
export function listTrackedTestFiles(repoRoot: string): string[] {
62+
function listTrackedTestFiles(repoRoot: string): string[] {
6363
const out = execFileSync('git', ['ls-files', '-z', '--', ...TEST_SOURCE_PATHSPECS], {
6464
cwd: repoRoot,
6565
encoding: 'utf8',

0 commit comments

Comments
 (0)