|
1 | 1 | import assert from "node:assert/strict"; |
| 2 | +import { spawnSync } from "node:child_process"; |
2 | 3 | import fs from "node:fs"; |
| 4 | +import os from "node:os"; |
| 5 | +import path from "node:path"; |
3 | 6 | import test from "node:test"; |
4 | 7 |
|
5 | 8 | const workflow = fs.readFileSync(".github/workflows/repair-cluster-worker.yml", "utf8"); |
@@ -37,6 +40,39 @@ test("repair target containment preflight runs the enforced worker only for fix |
37 | 40 | assert.doesNotMatch(preflight, /mount_probe|mount_errno|assert not \(mount_probe/); |
38 | 41 | }); |
39 | 42 |
|
| 43 | +test("repair target containment worker loads from the isolated work directory", () => { |
| 44 | + const work = fs.mkdtempSync(path.join(os.tmpdir(), "clawsweeper-containment-entry-")); |
| 45 | + const workerPath = path.resolve("dist/repair/contained-command-worker.js"); |
| 46 | + |
| 47 | + try { |
| 48 | + const worker = spawnSync(process.execPath, [workerPath], { |
| 49 | + cwd: work, |
| 50 | + env: { ...process.env, NODE_TEST_CONTEXT: "child-v8" }, |
| 51 | + input: JSON.stringify({ |
| 52 | + args: ["-e", 'process.stdout.write("loaded")'], |
| 53 | + command: process.execPath, |
| 54 | + cwd: work, |
| 55 | + isolateNetwork: true, |
| 56 | + maxBuffer: 1024, |
| 57 | + writableRoots: [work], |
| 58 | + windowsVerbatimArguments: false, |
| 59 | + }), |
| 60 | + encoding: "utf8", |
| 61 | + }); |
| 62 | + |
| 63 | + assert.equal(worker.status, 0, worker.stderr); |
| 64 | + assert.deepEqual(JSON.parse(worker.stdout), { |
| 65 | + backgroundProcesses: 0, |
| 66 | + signal: null, |
| 67 | + status: 0, |
| 68 | + stderr: "", |
| 69 | + stdout: "loaded", |
| 70 | + }); |
| 71 | + } finally { |
| 72 | + fs.rmSync(work, { recursive: true, force: true }); |
| 73 | + } |
| 74 | +}); |
| 75 | + |
40 | 76 | test("closure-only apply does not depend on target containment or target tool setup", () => { |
41 | 77 | const preflightIndex = workflow.indexOf("- name: Verify Linux validation containment"); |
42 | 78 | const publishStatusIndex = workflow.indexOf( |
|
0 commit comments