Skip to content

Commit d0a6458

Browse files
committed
test: harden packaged runtime smoke
1 parent db2e453 commit d0a6458

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

universal-refiner/package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

universal-refiner/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@
4343
"license": "MIT",
4444
"type": "module",
4545
"dependencies": {
46+
"@hono/node-server": "^1.19.13",
4647
"@modelcontextprotocol/sdk": "^1.29.0",
4748
"better-sqlite3": "^12.8.0",
4849
"chokidar": "^5.0.0",
4950
"flexsearch": "^0.7.43",
51+
"hono": "^4.12.25",
5052
"typescript": "^5.9.3",
5153
"zod": "^4.3.6"
5254
},

universal-refiner/scripts/acceptance/package-runtime-smoke.mjs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ try {
3434
await access(installedEntry);
3535
const port = await reservePort();
3636

37-
runtime = spawn(process.execPath, [installedEntry], {
37+
runtime = spawn(bin, [], {
3838
cwd: runtimeDir,
3939
env: {
4040
...process.env,
4141
PORT: String(port),
4242
PROMPT_REFINER_BACKGROUND: "true",
4343
},
4444
stdio: ["ignore", "pipe", "pipe"],
45+
shell: process.platform === "win32",
4546
windowsHide: true,
4647
});
4748

@@ -55,13 +56,24 @@ try {
5556
await waitForHealth(port, () => `${stdout}\n${stderr}`, timeoutMs);
5657
console.log(`Package runtime smoke passed: installed ${packed[0].name}-${packed[0].version} and served /api/health on ${port}.`);
5758
} finally {
58-
if (runtime && !runtime.killed) {
59-
runtime.kill("SIGTERM");
60-
await waitForClose(runtime, 5_000);
61-
}
59+
if (runtime) await terminateRuntime(runtime, 5_000);
6260
await rm(tempRoot, { recursive: true, force: true });
6361
}
6462

63+
async function terminateRuntime(child, timeoutMs) {
64+
if (child.exitCode !== null || child.signalCode !== null) return;
65+
if (process.platform === "win32" && child.pid) {
66+
const killer = spawn("taskkill", ["/pid", String(child.pid), "/t", "/f"], {
67+
stdio: "ignore",
68+
windowsHide: true,
69+
});
70+
await waitForClose(killer, timeoutMs);
71+
} else {
72+
child.kill("SIGTERM");
73+
}
74+
await waitForClose(child, timeoutMs);
75+
}
76+
6577
async function waitForClose(child, timeoutMs) {
6678
if (child.exitCode !== null || child.signalCode !== null) return;
6779
await Promise.race([

0 commit comments

Comments
 (0)