Skip to content

Commit 02ed90d

Browse files
committed
test(cli): the no-storage pin joins the built-entrypoint population by name
check:cli-test-child-env pins the set of files that spawn bin/run.js, so the pin joins it in the same change, and its controls keep each child's env a literal at the spawn call the gate reads NODE_ENV from. Claude-Session: https://claude.ai/code/session_01Q9PZ5Pzqcus4woVvTZwWNU Co-authored-by: Claude <noreply@anthropic.com>
1 parent 029a2c8 commit 02ed90d

2 files changed

Lines changed: 31 additions & 17 deletions

File tree

‎packages/cli/test/serve-no-storage-boot-guard.integration.test.ts‎

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,14 @@ afterAll(() => {
224224
if (root) rmSync(root, { recursive: true, force: true });
225225
});
226226

227+
/** A boot the guard must leave alone: it reaches its banner, refused nothing, printed no line. */
228+
function expectSilentBoot(output: string, ready: boolean): void {
229+
const seen = `\n--- output ---\n${output}`;
230+
expect(ready, `the boot did not reach its banner${seen}`).toBe(true);
231+
expect(output, `the boot was refused${seen}`).not.toContain(REFUSAL_HEAD);
232+
expect(output, `the boot got the no-storage line${seen}`).not.toContain(LINE_HEAD);
233+
}
234+
227235
describe('os serve — a production host config with no storage (#23573)', () => {
228236
it(
229237
'refuses before any plugin starts when the auth service needs a driver, naming the remedies',
@@ -274,27 +282,27 @@ describe('os serve — a production host config with no storage (#23573)', () =>
274282
'stays silent and boots when a plugin no driver test names registers a driver in init()',
275283
async () => {
276284
const { output, ready } = await boot(driverDir, { OS_AUTH_SECRET: AUTH_SECRET });
277-
const seen = `\n--- output ---\n${output}`;
278-
279-
expect(ready, `a boot with a driver-providing plugin no longer reaches its banner${seen}`).toBe(true);
280-
expect(output, `a boot with a driver was refused${seen}`).not.toContain(REFUSAL_HEAD);
281-
expect(output, `a boot with a driver got the no-storage line${seen}`).not.toContain(LINE_HEAD);
285+
expectSilentBoot(output, ready);
282286
},
283287
240_000,
284288
);
285289

286-
it.each([
287-
['OS_DATABASE_URL set', { OS_AUTH_SECRET: AUTH_SECRET, OS_DATABASE_URL: 'file:./ctl.db' }, [] as string[]],
288-
['--dev', { OS_AUTH_SECRET: AUTH_SECRET }, ['--dev']],
289-
])(
290-
'control: %s boots and says nothing about storage',
291-
async (_label, env, args) => {
292-
const { output, ready } = await boot(plainDir, env, args);
293-
const seen = `\n--- output ---\n${output}`;
290+
// Two `it`s, not an `it.each`: each spawn's env stays a literal at its call,
291+
// which is what `check:cli-test-child-env` reads the child's NODE_ENV from.
292+
it(
293+
'control: OS_DATABASE_URL set boots and says nothing about storage',
294+
async () => {
295+
const { output, ready } = await boot(plainDir, { OS_AUTH_SECRET: AUTH_SECRET, OS_DATABASE_URL: 'file:./ctl.db' });
296+
expectSilentBoot(output, ready);
297+
},
298+
240_000,
299+
);
294300

295-
expect(ready, `the control did not reach its banner${seen}`).toBe(true);
296-
expect(output, `the control was refused${seen}`).not.toContain(REFUSAL_HEAD);
297-
expect(output, `the control got the no-storage line${seen}`).not.toContain(LINE_HEAD);
301+
it(
302+
'control: --dev boots and says nothing about storage',
303+
async () => {
304+
const { output, ready } = await boot(plainDir, { OS_AUTH_SECRET: AUTH_SECRET }, ['--dev']);
305+
expectSilentBoot(output, ready);
298306
},
299307
240_000,
300308
);

‎scripts/check-cli-test-child-env.mjs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2635,7 +2635,7 @@ export function selfTest() {
26352635
.filter((abs) => builtEntrypointSpawns(abs, readFileSync(abs, 'utf8')).spawns > 0)
26362636
.map((abs) => relative(REPO_ROOT, abs).split(sep).join('/'))
26372637
.sort();
2638-
t('the built-entrypoint population is exactly the seven files that spawn bin/run.js',
2638+
t('the built-entrypoint population is exactly the eight files that spawn bin/run.js',
26392639
JSON.stringify(builtFiles) === JSON.stringify([
26402640
// [#21733] Joined the population deliberately: the card's acceptance is
26412641
// a plain `os dev` restart on the BUILT packages, and its production leg
@@ -2653,6 +2653,12 @@ export function selfTest() {
26532653
'packages/cli/test/published-entry-node-env-source-reroute.test.ts',
26542654
'packages/cli/test/serve-mcp-capability-collision.e2e.test.ts',
26552655
'packages/cli/test/serve-mcp-stdio-answers.e2e.test.ts',
2656+
// [#23573] Joined the population deliberately: the no-storage boot
2657+
// guard is registered only when a PRODUCTION storage step declared
2658+
// nothing, and `bin/run-dev.js` sets `NODE_ENV=development` before argv
2659+
// is parsed, where the step always declares a SQLite default. Every
2660+
// spawn hands its child `NODE_ENV: undefined`.
2661+
'packages/cli/test/serve-no-storage-boot-guard.integration.test.ts',
26562662
'packages/cli/test/serve-node-env-production-default.e2e.test.ts',
26572663
// [#16630] Joined the population deliberately: the degraded-boot the
26582664
// ready line has to report is only reachable in PRODUCTION posture, and

0 commit comments

Comments
 (0)