mirror of
https://github.com/morluto/rea
synced 2026-10-25 22:08:11 -04:00
test(cli): accept opaque Kuna doctor run tokens (#5677)
* test(cli): accept opaque Kuna doctor run tokens The doctor cancellation fixture parsed REA_PROCESS_RUN_ID as a UUID. Kuna version probes publish rea-kuna-version-<uuid>, so both signal cases failed before checking cancellation. Accept that opaque token and keep the JADX ownership check on a UUID. Co-authored-by: morluto <morluto@users.noreply.github.com> * test(cli): require the Kuna doctor run token An omitted REA_PROCESS_RUN_ID disappears from the ready JSON. The Kuna cancellation case now rejects that record unless runId is a non-empty ownership token. JADX still requires a UUID. Co-authored-by: morluto <morluto@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: morluto <morluto@users.noreply.github.com>
This commit is contained in:
@@ -40,13 +40,11 @@ cliTest.skipIf(!["darwin", "linux"].includes(process.platform)).for(
|
||||
const executable =
|
||||
provider === "kuna" ? join(root, "kuna") : join(jdk, "bin", "java");
|
||||
const probeArgument = provider === "kuna" ? "--version" : "--list-modules";
|
||||
const runIdField =
|
||||
provider === "jadx" ? ",runId:process.env.REA_PROCESS_RUN_ID" : "";
|
||||
await writeFile(
|
||||
executable,
|
||||
`#!${process.execPath}
|
||||
if (!process.argv.slice(2).includes(${JSON.stringify(probeArgument)})) process.exit(7);
|
||||
require("node:fs").writeFileSync(${JSON.stringify(ready)}, JSON.stringify({pid: process.pid${runIdField}}));
|
||||
require("node:fs").writeFileSync(${JSON.stringify(ready)}, JSON.stringify({pid: process.pid, runId: process.env.REA_PROCESS_RUN_ID}));
|
||||
process.on("SIGTERM", () => {});
|
||||
setInterval(() => { if (require("node:fs").existsSync(${JSON.stringify(release)})) process.exit(0); }, 25).unref();
|
||||
setTimeout(() => process.exit(99), 20000);
|
||||
@@ -97,7 +95,10 @@ setTimeout(() => process.exit(99), 20000);
|
||||
)
|
||||
.toBe(true);
|
||||
const readyRecord: unknown = JSON.parse(await readFile(ready, "utf8"));
|
||||
const observed: { readonly pid: number; readonly runId?: string } =
|
||||
// JADX publishes a UUID. Kuna publishes an opaque
|
||||
// `rea-kuna-version-<uuid>` token. Both are required: JSON.stringify
|
||||
// drops an undefined REA_PROCESS_RUN_ID, and that omission must fail.
|
||||
const observed =
|
||||
provider === "jadx"
|
||||
? z
|
||||
.strictObject({
|
||||
@@ -106,11 +107,12 @@ setTimeout(() => process.exit(99), 20000);
|
||||
})
|
||||
.parse(readyRecord)
|
||||
: z
|
||||
.strictObject({ pid: z.number().int().positive() })
|
||||
.strictObject({
|
||||
pid: z.number().int().positive(),
|
||||
runId: z.string().min(1),
|
||||
})
|
||||
.parse(readyRecord);
|
||||
if (provider === "jadx") {
|
||||
if (observed.runId === undefined)
|
||||
throw new Error("Missing JADX run token");
|
||||
ownership = {
|
||||
leaderPid: observed.pid,
|
||||
processGroupId: observed.pid,
|
||||
@@ -131,8 +133,7 @@ setTimeout(() => process.exit(99), 20000);
|
||||
state: "empty",
|
||||
});
|
||||
} else {
|
||||
// Kuna's version probe uses a joined direct execFile child, without a
|
||||
// detached run-token group. Do not invent a group owner from its PID.
|
||||
// Do not invent a group owner from the probe PID.
|
||||
expect(() => process.kill(observed.pid, 0)).toThrowError(
|
||||
expect.objectContaining({ code: "ESRCH" }),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user