Skip to content
Source
Sign inSign up
Open History to see the last commit

launcherWatch.test.ts

23 lines855 Bytes

1import { it } from "@effect/vitest";
2import * as Effect from "effect/Effect";
3import * as Fiber from "effect/Fiber";
4import * as HostProcess from "@t3tools/shared/HostProcess";
5​
6import { awaitLauncherLoss } from "./launcherWatch.ts";
7​
8const launcherPid = 4100;
9// Orphans are adopted by init or a subreaper, so the new parent is not always 1.
10const subreaperPid = 1800;
11​
12const watch = (getParentPid: () => number, platform: NodeJS.Platform, startPid = launcherPid) =>
13 awaitLauncherLoss({ launcherPid: startPid, getParentPid }).pipe(
14 Effect.provideService(HostProcess.Platform, platform),
15 );
16​
17it.effect("notices a launcher that was already gone when the watch began", () =>
18 Effect.gen(function* () {
19 const fiber = yield* Effect.forkChild(watch(() => subreaperPid, "linux"));
20 yield* Effect.yieldNow;
21 yield* Fiber.join(fiber);
22 }),
23);