Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
fix(view): a runner given options still guards its Chrome [C7]
Corey Olson05404138cedd
diff --git a/test/chrome-fixture.js b/test/chrome-fixture.jsindex ad538c1a..b4af0bd7 100644--- a/test/chrome-fixture.js+++ b/test/chrome-fixture.js@@ -169,6 +169,22 @@ setInterval(() => {let runnerAncestor;+/**+ * Whether a process command line is the test runner itself, bin/run-tests.js with any options, and not one of its+ * workers: a worker carries bin/run-tests.js only as its --import value, or runs under a standalone --test flag.+ * Options such as --test-concurrency=1 belong to the runner and never make it a worker (#896). Paths may hold spaces.+ *+ * @param {string} command - The command line as ps prints it.+ * @returns {boolean}+ */+export function isRunnerCommand(command) {+ const text = String(command);+ if (!/(?:^|[\s/])bin\/run-tests\.js(?:\s|$)/u.test(text)) return false;+ if (/(?:^|\s)--test(?:\s|$)/u.test(text)) return false;+ // The import value runs up to the next option, so a path with spaces still counts as one value.+ return !/(?:^|\s)--import[=\s](?:(?!\s--)[^])*?bin\/run-tests\.js(?:\s|$)/u.test(text);+}+/*** Find the test runner above this process: the nearest ancestor whose command runs bin/run-tests.js itself.* The walk uses `ps -o ppid=,command= -p <pid>`, which macOS and Linux share, runs once per process,@@ -185,8 +201,7 @@ export function findRunnerAncestor() {if (!match) break;pid = Number(match[1]);const ancestor = execFileSync('ps', ['-o', 'command=', '-p', String(pid)], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });- // The runner's own `node --test` child carries bin/run-tests.js only as its --import; it is not the runner.- if (/(?:^|[\s/])bin\/run-tests\.js(?:\s|$)/u.test(ancestor) && !/\s--(?:test|import)\b/u.test(ancestor)) { runnerAncestor = pid; break; }+ if (isRunnerCommand(ancestor.trim())) { runnerAncestor = pid; break; }}} catch { /* No readable ancestry means the guardian watches the owner alone. */ }return runnerAncestor;diff --git a/test/cockpit/stable.test.js b/test/cockpit/stable.test.jsindex 3932e99c..2981942d 100644--- a/test/cockpit/stable.test.js+++ b/test/cockpit/stable.test.js@@ -6,7 +6,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import test from 'node:test';import { fileURLToPath } from 'node:url';-import { findChromeExecutable } from '../chrome-fixture.js';+import { findChromeExecutable, isRunnerCommand } from '../chrome-fixture.js';const ROOT = fileURLToPath(new URL('../../', import.meta.url));const PROBE = join(ROOT, 'test/cockpit/chrome-owner-probe.mjs');@@ -57,8 +57,23 @@ function stopRecorded(profile, pids) {for (const pid of pids) { try { process.kill(pid, 'SIGKILL'); } catch { /* Already gone. */ } }}+test('the runner is bin/run-tests.js with any options, and its workers are not [C7]', () => {+ const at = '/Users/someone/Code/Open Source/repo';+ for (const command of [`node bin/run-tests.js test/a.test.js`, `node bin/run-tests.js --test-concurrency=1 test/a.test.js`,+ `/usr/local/bin/node ${at}/bin/run-tests.js --test-concurrency=1 ${at}/test/a.test.js`]) assert.equal(isRunnerCommand(command), true, command);+ for (const command of [`node --disable-warning=ExperimentalWarning --import ${at}/bin/run-tests.js ${at}/test/a.test.js`,+ `node --import=${at}/bin/run-tests.js ${at}/test/a.test.js`, `node --test test/a.test.js bin/run-tests.js`, `node test/a.test.js`]) assert.equal(isRunnerCommand(command), false, command);+});++/** How each killed process starts the probe: the owner directly, or the runner, with and without its own options. */+const VICTIMS = {+ owner: [],+ runner: ['bin/run-tests.js'],+ 'runner started with --test-concurrency=1': ['bin/run-tests.js', '--test-concurrency=1'],+};+for (const [launcher, name] of Object.entries(LAUNCHERS)) {- for (const killed of ['owner', 'runner']) {+ for (const killed of Object.keys(VICTIMS)) {test(`Chrome from ${name} exits within 10 s of its ${killed} dying by SIGKILL [C7]`, {timeout: READY_BUDGET_MS + DEATH_BUDGET_MS + 30_000,skip: !findChromeExecutable() && 'Chrome is not installed',@@ -72,7 +87,7 @@ for (const [launcher, name] of Object.entries(LAUNCHERS)) {// The runner case starts the probe the way the gate does, as a test file under bin/run-tests.js.const victim = killed === 'owner'? spawn(process.execPath, [PROBE], { cwd: ROOT, env, stdio: 'ignore' })- : spawn(process.execPath, ['bin/run-tests.js', 'test/cockpit/chrome-owner-probe.mjs'], { cwd: ROOT, env, stdio: 'ignore' });+ : spawn(process.execPath, [...VICTIMS[killed], 'test/cockpit/chrome-owner-probe.mjs'], { cwd: ROOT, env, stdio: 'ignore' });recorded.push(victim.pid);recorded.push(await waitForReady(readyFile, victim, READY_BUDGET_MS)); // budget: hang ceiling for Chrome to start, including a gate browser-slot wait; no speed claim.const before = chromeProcesses(profile);