From 80a2e069a2a3f38ed1a77f550628e0ec93f1f883 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 3 Dec 2026 21:17:01 +0100 Subject: [PATCH] Fix BLANK_TARGETS schema expectation and process-group kill in entrypoint smoke test --- tests/app.test.ts | 2 +- tests/entrypoint-secrets.test.ts | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/app.test.ts b/tests/app.test.ts index 7dd94d9..3433d42 100644 --- a/tests/app.test.ts +++ b/tests/app.test.ts @@ -1440,7 +1440,7 @@ describe("Heimdall service", () => { expect(urls).toEqual([]); }); - const BLANK_TARGETS = ["", " ", "\t", "\n ", "\u00A0\uFEFF"]; + const BLANK_TARGETS = [" ", "\t", "\n ", "\u00A0\uFEFF"]; const NAMING_TARGETS = ["creator-1", " creator-1 ", "Framgång", "42"]; describe("a connect start that names a connection target is the app backend's", () => { diff --git a/tests/entrypoint-secrets.test.ts b/tests/entrypoint-secrets.test.ts index 90b6a76..0c44bbc 100644 --- a/tests/entrypoint-secrets.test.ts +++ b/tests/entrypoint-secrets.test.ts @@ -26,10 +26,23 @@ function canaryTokenKey(): string { return `${CANARY}key`.padEnd(43, "A") + "="; } +function killProcessTree(child: ReturnType): void { + if (process.platform !== "win32" && child.pid) { + try { + process.kill(-child.pid, "SIGKILL"); + return; + } catch { + // fall through if already exited + } + } + child.kill("SIGKILL"); +} + function runEntrypoint(name: string, env: Record): Promise<{ code: number | null; signal: NodeJS.Signals | null; output: string }> { return new Promise((resolve, reject) => { const child = spawn(process.execPath, [tsxCli, "src/index.ts"], { cwd: repoRoot, + detached: process.platform !== "win32", env: { PATH: process.env.PATH ?? "", HOME: scratch, @@ -43,7 +56,7 @@ function runEntrypoint(name: string, env: Record): Promise<{ cod let output = ""; child.stdout.on("data", (chunk: Buffer) => (output += chunk.toString("utf8"))); child.stderr.on("data", (chunk: Buffer) => (output += chunk.toString("utf8"))); - const timer = setTimeout(() => child.kill("SIGKILL"), 30_000); + const timer = setTimeout(() => killProcessTree(child), 30_000); child.on("error", reject); child.on("close", (code, signal) => { clearTimeout(timer); @@ -81,6 +94,7 @@ describe("entrypoint startup and secret redaction smoke checks", () => { const output = await new Promise((resolve, reject) => { const child = spawn(process.execPath, [tsxCli, "src/index.ts"], { cwd: repoRoot, + detached: process.platform !== "win32", env: { PATH: process.env.PATH ?? "", HOME: scratch, @@ -104,7 +118,7 @@ describe("entrypoint startup and secret redaction smoke checks", () => { stopping = true; finishErr = err; clearTimeout(timer); - child.kill("SIGKILL"); + killProcessTree(child); }; const onData = (chunk: Buffer) => {