fix(#4020): bound the test run's temp footprint with a swept run-scoped root (#4207)

* test(#4020): the runner must bound and sweep a run-scoped temp root

* fix(#4020): bound the run's temp footprint with a swept run-scoped root

* test(#4020): isolate the env-mutating rows in child processes

* fix(#4020): gate root removal on ownership so nested runners spare the outer root

* test(#4020): pass the probe file via --files, the runner's explicit-file flag

* test(#4020): resolve the probe by basename, as --files matching requires

* test(#4020): assert root survival, not content survival, in the nested-row

* chore(#4020): changeset for the run-scoped temp root

* chore(#4020): backfill changeset pr number

* fix(#4020): the sweep spares ancestors of the runner's own selected files

* fix(#4020): TMPDIR precedence — an operator redirect beats inherited TEMP/TMP

* fix(#4020): only the root's owner sweeps — a nested runner spares live sibling fixtures

---------

Co-authored-by: sim <sim@local>
This commit is contained in:
Tom Boucher
2026-09-02 20:47:34 -04:00
committed by GitHub
parent 858bb89769
commit 7d6d788b51
6 changed files with 389 additions and 6 deletions

View File

@@ -16,6 +16,7 @@ process.env.GSD_TEST_MODE = '1';
// formatShowReport) now has unit coverage.
const { test } = require('node:test');
const { cleanup } = require('./helpers.cjs'); // #4020: fixture-tree removal
const assert = require('node:assert/strict');
const path = require('node:path');
const fs = require('node:fs');
@@ -66,8 +67,9 @@ test('parseFlags handles a missing `--` rest gracefully (no rest array)', () =>
// ─── findPlanningDir ──────────────────────────────────────────────────────────
test('findPlanningDir walks up to the nearest .planning and returns its path', () => {
test('findPlanningDir walks up to the nearest .planning and returns its path', (t) => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-slurm-'));
t.after(() => cleanup(root)); // #4020: no leaked fixture tree on the success path
const planning = path.join(root, '.planning');
fs.mkdirSync(planning);
const nested = path.join(root, 'a', 'b', 'c');
@@ -75,11 +77,12 @@ test('findPlanningDir walks up to the nearest .planning and returns its path', (
assert.strictEqual(findPlanningDir(nested), planning);
});
test('findPlanningDir fails closed (ExitError) when no .planning is reachable', () => {
test('findPlanningDir fails closed (ExitError) when no .planning is reachable', (t) => {
// A tmp dir with no .planning anywhere up to the walk bound (10 levels).
// Use a fresh tmp and create 11 nested dirs so the walk can't escape to a
// parent that happens to contain .planning (e.g. the repo root).
const deep = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-slurm-noplan-'));
t.after(() => cleanup(deep)); // #4020
let cur = deep;
for (let i = 0; i < 12; i++) {
cur = path.join(cur, `n${i}`);