Skip to content

Commit c251ef4

Browse files
claude[bot]claude
andauthored
test(cli): route 14 e2e spawners through childEnv(), 18 -> 3 on the child-env ratchet (#11653)
The `check:cli-test-child-env` gate (#11341) baselined 18 bulk `process.env` copies reaching spawned children under `packages/cli/test/**`. This is the cheap-batch slice of that burn-down: 15 references across 14 files, each `{ ...process.env, X }` replaced with `childEnv({ X })`, the choke point from #11267 that strips the vitest worker family (`TEST`, `VITEST`, `VITEST_*`) before the overrides are applied. `scripts/cli-test-child-env.baseline.json` drops the 14 repaired keys in the same commit -- the ratchet fails on a stale ceiling too, so leaving 18 there would silently license 15 new leaks. Left in the ledger deliberately: the three `serve-*` files the card flags for the crypto/auth re-check (`$HOME/.objectstack/dev-crypto-key`, the `OS_SECRET_KEY` precedent), which need a second slice. The two `DELIBERATE` sites are untouched. Every one of the 14 files was run individually after the edit -- 147 tests, all green -- so no child in this slice turned out to depend on an inherited runner variable. Part of #11596 Claude-Session: https://claude.ai/code/session_019siH5jDmk5hrayvfyojUqR Co-authored-by: Claude <noreply@anthropic.com>
1 parent 09ae32e commit c251ef4

15 files changed

Lines changed: 30 additions & 30 deletions

packages/cli/test/cloud-login-json-ndjson.e2e.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import { mkdtempSync, rmSync, readFileSync, existsSync } from 'node:fs';
7070
import { tmpdir } from 'node:os';
7171
import { join, resolve } from 'node:path';
7272
import { fileURLToPath } from 'node:url';
73+
import { childEnv } from './helpers/serve-process.js';
7374

7475
const HERE = resolve(fileURLToPath(import.meta.url), '..');
7576
const CLI = resolve(HERE, '../bin/run-dev.js');
@@ -278,7 +279,7 @@ async function runCloudDeviceLogin(opts: {
278279
'script',
279280
// -q quiet, -e propagate the child's exit status, -c the command.
280281
['-qec', shell, '/dev/null'],
281-
{ env: { ...process.env, HOME: home, NO_COLOR: '1' }, maxBuffer: 32 * 1024 * 1024 },
282+
{ env: childEnv({ HOME: home, NO_COLOR: '1' }), maxBuffer: 32 * 1024 * 1024 },
282283
(err) => res(err ? Number((err as { code?: unknown }).code ?? 1) : 0),
283284
);
284285
});

packages/cli/test/generate-agent-retired.e2e.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { existsSync, mkdtempSync, rmSync } from 'node:fs';
3737
import { tmpdir } from 'node:os';
3838
import { join, resolve } from 'node:path';
3939
import { fileURLToPath } from 'node:url';
40+
import { childEnv } from './helpers/serve-process.js';
4041

4142
const HERE = resolve(fileURLToPath(import.meta.url), '..');
4243
const CLI = resolve(HERE, '../bin/run-dev.js');
@@ -56,7 +57,7 @@ function runTsx(args: string[], cwd: string): Promise<Run> {
5657
execFile(
5758
TSX,
5859
args,
59-
{ cwd, maxBuffer: 8 * 1024 * 1024, env: { ...process.env, NO_COLOR: '1' } },
60+
{ cwd, maxBuffer: 8 * 1024 * 1024, env: childEnv({ NO_COLOR: '1' }) },
6061
(err, stdout, stderr) => {
6162
resolvePromise({
6263
// `err.code` is the real exit status; null/undefined means the child

packages/cli/test/generate-skill.e2e.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ import { tmpdir } from 'node:os';
8181
import { dirname, join, matchesGlob, relative, resolve, sep } from 'node:path';
8282
import { fileURLToPath } from 'node:url';
8383
import { DEFAULT_METADATA_TYPE_REGISTRY } from '@objectstack/spec/kernel';
84+
import { childEnv } from './helpers/serve-process.js';
8485

8586
const HERE = resolve(fileURLToPath(import.meta.url), '..');
8687
const CLI = resolve(HERE, '../bin/run-dev.js');
@@ -114,7 +115,7 @@ function runTsx(args: string[], cwd: string): Promise<Run> {
114115
execFile(
115116
TSX,
116117
args,
117-
{ cwd, maxBuffer: 8 * 1024 * 1024, env: { ...process.env, NO_COLOR: '1' } },
118+
{ cwd, maxBuffer: 8 * 1024 * 1024, env: childEnv({ NO_COLOR: '1' }) },
118119
(err, stdout, stderr) => {
119120
resolvePromise({
120121
// `err.code` is the real exit status; null/undefined means the child

packages/cli/test/hook-body-build-reach.e2e.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import { mkdtempSync, rmSync, writeFileSync, readFileSync } from 'node:fs';
5151
import { tmpdir } from 'node:os';
5252
import { join, resolve } from 'node:path';
5353
import { fileURLToPath } from 'node:url';
54+
import { childEnv } from './helpers/serve-process.js';
5455

5556
const HERE = resolve(fileURLToPath(import.meta.url), '..');
5657
const CLI = resolve(HERE, '../bin/run-dev.js');
@@ -67,7 +68,7 @@ function runCli(args: string[], cwd: string): Promise<Run> {
6768
execFile(
6869
TSX,
6970
[CLI, ...args],
70-
{ cwd, maxBuffer: 16 * 1024 * 1024, env: { ...process.env, NO_COLOR: '1' } },
71+
{ cwd, maxBuffer: 16 * 1024 * 1024, env: childEnv({ NO_COLOR: '1' }) },
7172
(err, stdout, stderr) => {
7273
resolvePromise({
7374
code: err ? (typeof (err as { code?: unknown }).code === 'number' ? (err as unknown as { code: number }).code : 1) : 0,

packages/cli/test/init-created-files-summary.e2e.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import { mkdtempSync, rmSync, mkdirSync, writeFileSync, chmodSync, readdirSync }
5757
import { tmpdir } from 'node:os';
5858
import { join, resolve } from 'node:path';
5959
import { fileURLToPath } from 'node:url';
60+
import { childEnv } from './helpers/serve-process.js';
6061

6162
const HERE = resolve(fileURLToPath(import.meta.url), '..');
6263
const CLI = resolve(HERE, '../bin/run-dev.js');
@@ -75,7 +76,7 @@ function runCli(args: string[], cwd: string, env: Record<string, string>): Promi
7576
execFile(
7677
TSX,
7778
[CLI, ...args],
78-
{ cwd, maxBuffer: 16 * 1024 * 1024, env: { ...process.env, NO_COLOR: '1', ...env } },
79+
{ cwd, maxBuffer: 16 * 1024 * 1024, env: childEnv({ NO_COLOR: '1', ...env }) },
7980
(err, stdout, stderr) => {
8081
resolvePromise({
8182
// The real exit status, not truthiness of `err` — a non-zero code

packages/cli/test/invocation-loudness.e2e.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { mkdtempSync, rmSync, symlinkSync } from 'node:fs';
4646
import { tmpdir } from 'node:os';
4747
import { join, resolve } from 'node:path';
4848
import { fileURLToPath } from 'node:url';
49+
import { childEnv } from './helpers/serve-process.js';
4950

5051
const HERE = resolve(fileURLToPath(import.meta.url), '..');
5152
const BIN = resolve(HERE, '../bin/run.js');
@@ -67,7 +68,7 @@ function runTsx(args: string[], cwd: string): Promise<Run> {
6768
execFile(
6869
TSX,
6970
args,
70-
{ cwd, maxBuffer: 8 * 1024 * 1024, env: { ...process.env, NO_COLOR: '1' } },
71+
{ cwd, maxBuffer: 8 * 1024 * 1024, env: childEnv({ NO_COLOR: '1' }) },
7172
(err, stdout, stderr) => {
7273
resolvePromise({
7374
// `err.code` is the real exit status; null/undefined means the child

packages/cli/test/json-stdout-purity.e2e.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import { mkdtempSync, rmSync, writeFileSync, readFileSync, readdirSync, statSync
6262
import { tmpdir } from 'node:os';
6363
import { join, resolve, relative, sep } from 'node:path';
6464
import { fileURLToPath } from 'node:url';
65+
import { childEnv } from './helpers/serve-process.js';
6566

6667
const HERE = resolve(fileURLToPath(import.meta.url), '..');
6768
const CLI = resolve(HERE, '../bin/run-dev.js');
@@ -144,7 +145,7 @@ function runCli(argv: string[], cwd: string, env: Record<string, string>): Promi
144145
execFile(
145146
TSX,
146147
[CLI, ...argv],
147-
{ cwd, maxBuffer: 32 * 1024 * 1024, env: { ...process.env, NO_COLOR: '1', ...env } },
148+
{ cwd, maxBuffer: 32 * 1024 * 1024, env: childEnv({ NO_COLOR: '1', ...env }) },
148149
(err, stdout, stderr) => {
149150
resolvePromise({
150151
code: err ? (typeof (err as { code?: unknown }).code === 'number' ? (err as unknown as { code: number }).code : 1) : 0,

packages/cli/test/login-json-ndjson.e2e.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import { mkdtempSync, rmSync, readFileSync, existsSync } from 'node:fs';
6666
import { tmpdir } from 'node:os';
6767
import { join, resolve } from 'node:path';
6868
import { fileURLToPath } from 'node:url';
69+
import { childEnv } from './helpers/serve-process.js';
6970

7071
const HERE = resolve(fileURLToPath(import.meta.url), '..');
7172
const CLI = resolve(HERE, '../bin/run-dev.js');
@@ -267,7 +268,7 @@ async function runDeviceLogin(outcome: 'token' | 'access_denied'): Promise<Devic
267268
'script',
268269
// -q quiet, -e propagate the child's exit status, -c the command.
269270
['-qec', shell, '/dev/null'],
270-
{ env: { ...process.env, HOME: home, NO_COLOR: '1' }, maxBuffer: 32 * 1024 * 1024 },
271+
{ env: childEnv({ HOME: home, NO_COLOR: '1' }), maxBuffer: 32 * 1024 * 1024 },
271272
(err) => res(err ? Number((err as { code?: unknown }).code ?? 1) : 0),
272273
);
273274
});

packages/cli/test/login-json-noninteractive.e2e.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import { mkdtempSync, rmSync, readFileSync } from 'node:fs';
5656
import { tmpdir } from 'node:os';
5757
import { join, resolve } from 'node:path';
5858
import { fileURLToPath } from 'node:url';
59+
import { childEnv } from './helpers/serve-process.js';
5960

6061
const HERE = resolve(fileURLToPath(import.meta.url), '..');
6162
const CLI = resolve(HERE, '../bin/run-dev.js');
@@ -99,7 +100,7 @@ function runLogin(args: string[], answer: Array<{ when: RegExp; send: string }>
99100
return new Promise<Run>((done) => {
100101
const child = spawn(TSX, [CLI, 'login', ...args], {
101102
stdio: ['pipe', 'pipe', 'pipe'],
102-
env: { ...process.env, HOME: home, NO_COLOR: '1' },
103+
env: childEnv({ HOME: home, NO_COLOR: '1' }),
103104
});
104105

105106
let stdout = '';

packages/cli/test/migrate-exit-code.e2e.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
3636
import { tmpdir } from 'node:os';
3737
import { join, resolve } from 'node:path';
3838
import { fileURLToPath } from 'node:url';
39+
import { childEnv } from './helpers/serve-process.js';
3940

4041
const HERE = resolve(fileURLToPath(import.meta.url), '..');
4142
const CLI = resolve(HERE, '../bin/run-dev.js');
@@ -80,7 +81,7 @@ function runCli(args: string[], cwd: string, env: Record<string, string> = {}):
8081
execFile(
8182
TSX,
8283
[CLI, ...args],
83-
{ cwd, maxBuffer: 16 * 1024 * 1024, env: { ...process.env, NO_COLOR: '1', ...env } },
84+
{ cwd, maxBuffer: 16 * 1024 * 1024, env: childEnv({ NO_COLOR: '1', ...env }) },
8485
(err, stdout, stderr) => {
8586
resolvePromise({
8687
// `err.code` is the real exit status; `null`/undefined means the

0 commit comments

Comments
 (0)