test(cli): align Kuna readiness and cancellation expectations
This commit is contained in:
1 parent
0bc2b42001
commit
4108d1363a
2 files changed
+17
-9
No files matched your search
@@ -40,11 +40,13 @@ 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, runId: process.env.REA_PROCESS_RUN_ID}));
|
||||
require("node:fs").writeFileSync(${JSON.stringify(ready)}, JSON.stringify({pid: process.pid${runIdField}}));
|
||||
process.on("SIGTERM", () => {});
|
||||
setInterval(() => { if (require("node:fs").existsSync(${JSON.stringify(release)})) process.exit(0); }, 25).unref();
|
||||
setTimeout(() => process.exit(99), 20000);
|
||||
@@ -94,12 +96,18 @@ setTimeout(() => process.exit(99), 20000);
|
||||
{ timeout: 10_000 },
|
||||
)
|
||||
.toBe(true);
|
||||
const observed = z
|
||||
.strictObject({
|
||||
pid: z.number().int().positive(),
|
||||
runId: z.string().uuid().optional(),
|
||||
})
|
||||
.parse(JSON.parse(await readFile(ready, "utf8")));
|
||||
const readyRecord: unknown = JSON.parse(await readFile(ready, "utf8"));
|
||||
const observed: { readonly pid: number; readonly runId?: string } =
|
||||
provider === "jadx"
|
||||
? z
|
||||
.strictObject({
|
||||
pid: z.number().int().positive(),
|
||||
runId: z.string().uuid(),
|
||||
})
|
||||
.parse(readyRecord)
|
||||
: z
|
||||
.strictObject({ pid: z.number().int().positive() })
|
||||
.parse(readyRecord);
|
||||
if (provider === "jadx") {
|
||||
if (observed.runId === undefined)
|
||||
throw new Error("Missing JADX run token");
|
||||
|
||||
@@ -8,7 +8,7 @@ import { cliTest } from "../../support/cli/cliFixture.js";
|
||||
import { writeFakeKuna } from "../providers/kuna/fakeKuna.js";
|
||||
|
||||
cliTest.skipIf(process.platform === "win32").for(["blocked", "ready"] as const)(
|
||||
"setup dry-run advertises Kuna only with a %s cache",
|
||||
"setup dry-run reports Kuna readiness for a %s cache",
|
||||
async (cache, { cli }) => {
|
||||
const root = await createTestTempDirectory("rea-setup-provider-readiness-");
|
||||
const home = join(root, "home");
|
||||
@@ -37,7 +37,7 @@ cliTest.skipIf(process.platform === "win32").for(["blocked", "ready"] as const)(
|
||||
providerInspections: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "kuna",
|
||||
available: true,
|
||||
available: cache === "ready",
|
||||
checks: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
name: "cache",
|
||||
|
||||
Reference in new issue
Block a user