MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / setup

Function setup

e2e/setup/selfhost.globalsetup.ts:24–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22 : resolve(RUNS_DIR, "selfhost", "server-logs", "boot.log");
23
24export default async function setup(): Promise<(() => Promise<void>) | void> {
25 if (process.env.E2E_SELFHOST_URL) {
26 await waitForHttp(process.env.E2E_SELFHOST_URL);
27 return;
28 }
29
30 if (bootLogFile) mkdirSync(resolve(bootLogFile, ".."), { recursive: true });
31
32 // Claim a free port (preferred block first, walk forward past squatters),
33 // boot, and retry on EADDRINUSE (a Linux-CI ephemeral socket can grab a
34 // claimed port between probe and bind). The claimed port is published via env
35 // so the test workers derive the same URL; the imported targets/selfhost
36 // constants were computed BEFORE the claim — don't use them for ports here.
37 const { teardown } = await claimAndBoot(
38 [{ envVar: "E2E_SELFHOST_PORT", offset: 4, label: "selfhost vite dev" }],
39 async (ports) => {
40 const port = ports.E2E_SELFHOST_PORT!;
41 // Shrink the sandbox execution budget and publish the value to the test
42 // workers (spawned after this globalsetup, so they inherit the env): the
43 // sandbox-deadline scenario reads it to scale its approval delays.
44 process.env[SANDBOX_TIMEOUT_ENV] = String(E2E_SANDBOX_TIMEOUT_MS);
45 // Fresh data dir per suite run — hermetic; in-suite isolation comes from
46 // fresh identities, not resets (bootSelfhost wipes it).
47 const procs = await bootSelfhost({
48 port,
49 webBaseUrl: `http://localhost:${port}`,
50 admin: SELFHOST_ADMIN,
51 logFile: bootLogFile,
52 sandboxTimeoutMs: E2E_SANDBOX_TIMEOUT_MS,
53 });
54 return { teardown: procs.teardown, value: procs };
55 },
56 { label: "selfhost", retryWhen: isBootReadinessTimeout },
57 );
58 return teardown;
59}

Callers

nothing calls this directly

Calls 4

waitForHttpFunction · 0.90
claimAndBootFunction · 0.90
bootSelfhostFunction · 0.90
resolveFunction · 0.50

Tested by

no test coverage detected