feat(process): record provider and verifier run lineage
This commit is contained in:
Vendored
+37
-1
@@ -7,7 +7,7 @@ const fixturePath = fileURLToPath(
|
||||
|
||||
/** Spawn one deterministic process-lifecycle fixture with piped diagnostics. */
|
||||
export const spawnProviderProcessFixture = (
|
||||
mode: "burst" | "exit" | "graceful" | "stubborn",
|
||||
mode: "burst" | "detached-child" | "exit" | "graceful" | "stubborn",
|
||||
value?: number,
|
||||
): ChildProcess =>
|
||||
spawn(
|
||||
@@ -52,6 +52,42 @@ export const waitForProviderProcessReady = (
|
||||
child.once("exit", onExit);
|
||||
});
|
||||
|
||||
/** Read the distinct process-group leader created by the detached-child mode. */
|
||||
export const waitForDetachedProviderChild = (
|
||||
child: ChildProcess,
|
||||
timeoutMs = 2_000,
|
||||
): Promise<number> =>
|
||||
new Promise((resolve, reject) => {
|
||||
const stdout = child.stdout;
|
||||
if (stdout === null) {
|
||||
reject(new Error("Provider process fixture stdout is unavailable"));
|
||||
return;
|
||||
}
|
||||
let output = "";
|
||||
const detach = (): void => {
|
||||
clearTimeout(timer);
|
||||
stdout.off("data", onData);
|
||||
child.off("exit", onExit);
|
||||
};
|
||||
const onData = (chunk: Buffer | string): void => {
|
||||
output += chunk.toString();
|
||||
const match = /(?:^|\n)ready:(\d+)\n/u.exec(output);
|
||||
if (match?.[1] === undefined) return;
|
||||
detach();
|
||||
resolve(Number(match[1]));
|
||||
};
|
||||
const onExit = (): void => {
|
||||
detach();
|
||||
reject(new Error("Provider process fixture exited before readiness"));
|
||||
};
|
||||
const timer = setTimeout(() => {
|
||||
detach();
|
||||
reject(new Error("Provider process fixture readiness timed out"));
|
||||
}, timeoutMs);
|
||||
stdout.on("data", onData);
|
||||
child.once("exit", onExit);
|
||||
});
|
||||
|
||||
/** Kill a fixture if necessary and wait for its process handle to settle. */
|
||||
export const stopProviderProcessFixture = async (
|
||||
child: ChildProcess,
|
||||
|
||||
Reference in New Issue
Block a user