Vendor OpenClaw source as Adolf fork baseline
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
This commit is contained in:
328
test/scripts/ui.test.ts
Normal file
328
test/scripts/ui.test.ts
Normal file
@@ -0,0 +1,328 @@
|
||||
// Ui tests cover ui script behavior.
|
||||
import { spawn, spawnSync, type ChildProcess } from "node:child_process";
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
isDirectScriptExecution,
|
||||
resolvePnpmSpawnCall,
|
||||
resolveSpawnCall,
|
||||
shouldUseCmdExeForCommand,
|
||||
} from "../../scripts/ui.js";
|
||||
|
||||
async function waitFor(predicate: () => boolean, label: string, timeoutMs = 3_000): Promise<void> {
|
||||
const startedAt = Date.now();
|
||||
while (!predicate()) {
|
||||
if (Date.now() - startedAt > timeoutMs) {
|
||||
throw new Error(`timed out waiting for ${label}`);
|
||||
}
|
||||
await new Promise<void>((resolve) => {
|
||||
setTimeout(resolve, 25);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function waitForExit(
|
||||
child: ChildProcess,
|
||||
timeoutMs = 3_000,
|
||||
): Promise<{ code: number | null; signal: NodeJS.Signals | null }> {
|
||||
return await new Promise((resolve, reject) => {
|
||||
const timer = setTimeout(() => {
|
||||
child.kill("SIGKILL");
|
||||
reject(new Error("timed out waiting for child exit"));
|
||||
}, timeoutMs);
|
||||
child.once("exit", (code, signal) => {
|
||||
clearTimeout(timer);
|
||||
resolve({ code, signal });
|
||||
});
|
||||
child.once("error", (error) => {
|
||||
clearTimeout(timer);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
describe("scripts/ui windows spawn behavior", () => {
|
||||
it("wraps Windows command launchers with cmd.exe without enabling shell mode", () => {
|
||||
expect(
|
||||
shouldUseCmdExeForCommand("C:\\Users\\dev\\AppData\\Local\\pnpm\\pnpm.CMD", "win32"),
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
resolveSpawnCall(
|
||||
"C:\\Program Files\\nodejs\\pnpm.cmd",
|
||||
["run", "build", "-t", "path with spaces"],
|
||||
{ PATH: "C:\\bin" },
|
||||
{ comSpec: "C:\\Windows\\System32\\cmd.exe", cwd: "C:\\repo\\ui", platform: "win32" },
|
||||
),
|
||||
).toEqual({
|
||||
command: "C:\\Windows\\System32\\cmd.exe",
|
||||
args: [
|
||||
"/d",
|
||||
"/s",
|
||||
"/c",
|
||||
'""C:\\Program Files\\nodejs\\pnpm.cmd" run build -t "path with spaces""',
|
||||
],
|
||||
options: {
|
||||
cwd: "C:\\repo\\ui",
|
||||
stdio: "inherit",
|
||||
env: { PATH: "C:\\bin" },
|
||||
shell: false,
|
||||
windowsVerbatimArguments: true,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("does not use cmd.exe for non-command launchers", () => {
|
||||
expect(shouldUseCmdExeForCommand("C:\\Program Files\\nodejs\\node.exe", "win32")).toBe(false);
|
||||
expect(shouldUseCmdExeForCommand("C:\\tools\\pnpm.com", "win32")).toBe(false);
|
||||
expect(shouldUseCmdExeForCommand("/usr/local/bin/pnpm", "linux")).toBe(false);
|
||||
|
||||
expect(
|
||||
resolveSpawnCall(
|
||||
"C:\\Program Files\\nodejs\\pnpm.exe",
|
||||
["run", "build"],
|
||||
{ PATH: "C:\\bin" },
|
||||
{ cwd: "C:\\repo\\ui", platform: "win32" },
|
||||
),
|
||||
).toEqual({
|
||||
command: "C:\\Program Files\\nodejs\\pnpm.exe",
|
||||
args: ["run", "build"],
|
||||
options: {
|
||||
cwd: "C:\\repo\\ui",
|
||||
stdio: "inherit",
|
||||
env: { PATH: "C:\\bin" },
|
||||
shell: false,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects unsafe cmd.exe arguments before launch", () => {
|
||||
expect(() =>
|
||||
resolveSpawnCall("C:\\tools\\pnpm.cmd", ["run", "build", "evil&calc"], undefined, {
|
||||
platform: "win32",
|
||||
}),
|
||||
).toThrow(/unsafe windows cmd\.exe argument/i);
|
||||
expect(() =>
|
||||
resolveSpawnCall("C:\\tools\\pnpm.cmd", ["run", "build", "%PATH%"], undefined, {
|
||||
platform: "win32",
|
||||
}),
|
||||
).toThrow(/unsafe windows cmd\.exe argument/i);
|
||||
});
|
||||
|
||||
it("uses a trusted cmd.exe path when no explicit Windows launcher is injected", () => {
|
||||
expect(
|
||||
resolveSpawnCall(
|
||||
"C:\\tools\\pnpm.cmd",
|
||||
["run", "build"],
|
||||
{
|
||||
ComSpec: "C:\\Users\\test\\bin\\cmd.exe",
|
||||
SystemRoot: "D:\\Windows",
|
||||
},
|
||||
{ cwd: "C:\\repo\\ui", platform: "win32" },
|
||||
).command,
|
||||
).toBe("D:\\Windows\\System32\\cmd.exe");
|
||||
});
|
||||
|
||||
it("routes Windows Corepack pnpm entrypoints through node", () => {
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-pnpm-runner-"));
|
||||
const npmExecPath = path.join(tempDir, "pnpm.mjs");
|
||||
fs.writeFileSync(npmExecPath, "console.log('pnpm');\n");
|
||||
|
||||
try {
|
||||
expect(
|
||||
resolvePnpmSpawnCall(
|
||||
["run", "build"],
|
||||
{
|
||||
npm_execpath: npmExecPath,
|
||||
ComSpec: "C:\\Windows\\System32\\cmd.exe",
|
||||
},
|
||||
{
|
||||
cwd: "C:\\repo\\ui",
|
||||
nodeExecPath: "C:\\Program Files\\nodejs\\node.exe",
|
||||
platform: "win32",
|
||||
},
|
||||
),
|
||||
).toEqual({
|
||||
command: "C:\\Program Files\\nodejs\\node.exe",
|
||||
args: [npmExecPath, "run", "build"],
|
||||
options: {
|
||||
cwd: "C:\\repo\\ui",
|
||||
stdio: "inherit",
|
||||
env: {
|
||||
npm_execpath: npmExecPath,
|
||||
ComSpec: "C:\\Windows\\System32\\cmd.exe",
|
||||
},
|
||||
shell: false,
|
||||
windowsVerbatimArguments: undefined,
|
||||
},
|
||||
});
|
||||
} finally {
|
||||
fs.rmSync(tempDir, { force: true, recursive: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps non-Windows launches direct even with shell metacharacters", () => {
|
||||
expect(
|
||||
resolveSpawnCall(
|
||||
"/usr/local/bin/pnpm",
|
||||
["run", "build", "contains&metacharacters"],
|
||||
{ PATH: "/bin" },
|
||||
{ cwd: "/repo/ui", platform: "linux" },
|
||||
),
|
||||
).toEqual({
|
||||
command: "/usr/local/bin/pnpm",
|
||||
args: ["run", "build", "contains&metacharacters"],
|
||||
options: {
|
||||
cwd: "/repo/ui",
|
||||
stdio: "inherit",
|
||||
env: { PATH: "/bin" },
|
||||
shell: false,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("detects direct execution through a junctioned script path", () => {
|
||||
const realScriptPath = path.resolve("repo/openclaw/scripts/ui.js");
|
||||
const junctionScriptPath = path.resolve("linked/openclaw/scripts/ui.js");
|
||||
const realpath = (entry: string) => (entry === junctionScriptPath ? realScriptPath : entry);
|
||||
|
||||
expect(isDirectScriptExecution(junctionScriptPath, realScriptPath, realpath)).toBe(true);
|
||||
});
|
||||
|
||||
it("honors build-all no-pnpm mode before requiring a pnpm runner", () => {
|
||||
const result = spawnSync(process.execPath, ["scripts/ui.js", "build", "--help"], {
|
||||
cwd: path.resolve("."),
|
||||
encoding: "utf8",
|
||||
env: {
|
||||
...process.env,
|
||||
OPENCLAW_BUILD_ALL_NO_PNPM: "1",
|
||||
PATH: "",
|
||||
},
|
||||
});
|
||||
|
||||
const output = `${result.stdout}${result.stderr}`;
|
||||
expect(result.status).toBe(0);
|
||||
expect(output).not.toContain("Missing UI runner");
|
||||
expect(output).toContain("vite");
|
||||
});
|
||||
|
||||
it.runIf(process.platform !== "win32").each(["SIGTERM", "SIGHUP"] as const)(
|
||||
"terminates the pnpm child on wrapper %s",
|
||||
async (signal) => {
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-ui-wrapper-signals-"));
|
||||
const runnerPath = path.join(tempDir, "pnpm.mjs");
|
||||
const readyFile = path.join(tempDir, "ready");
|
||||
const signaledFile = path.join(tempDir, "signaled");
|
||||
const handlerLines = ["SIGTERM", "SIGHUP"].flatMap((handledSignal) => [
|
||||
`process.on('${handledSignal}', () => {`,
|
||||
` fs.writeFileSync(process.env.SIGNALED_FILE, '${handledSignal}');`,
|
||||
" setTimeout(() => process.exit(0), 25);",
|
||||
"});",
|
||||
]);
|
||||
|
||||
fs.writeFileSync(
|
||||
runnerPath,
|
||||
[
|
||||
"import fs from 'node:fs';",
|
||||
...handlerLines,
|
||||
"fs.writeFileSync(process.env.READY_FILE, process.argv.slice(2).join(' '));",
|
||||
"setInterval(() => {}, 1000);",
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
const wrapper = spawn(process.execPath, ["scripts/ui.js", "install"], {
|
||||
cwd: path.resolve("."),
|
||||
env: {
|
||||
...process.env,
|
||||
npm_execpath: runnerPath,
|
||||
READY_FILE: readyFile,
|
||||
SIGNALED_FILE: signaledFile,
|
||||
},
|
||||
stdio: "ignore",
|
||||
});
|
||||
|
||||
try {
|
||||
await waitFor(() => fs.existsSync(readyFile), "UI runner readiness");
|
||||
expect(fs.readFileSync(readyFile, "utf8")).toBe("install");
|
||||
wrapper.kill(signal);
|
||||
|
||||
const exit = await waitForExit(wrapper);
|
||||
expect(exit).toEqual({ code: null, signal });
|
||||
expect(fs.readFileSync(signaledFile, "utf8")).toBe(signal);
|
||||
} finally {
|
||||
wrapper.kill("SIGKILL");
|
||||
fs.rmSync(tempDir, { force: true, recursive: true });
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
it.runIf(process.platform !== "win32")(
|
||||
"cleans pnpm descendants before forwarding wrapper SIGTERM",
|
||||
async () => {
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-ui-wrapper-tree-"));
|
||||
const runnerPath = path.join(tempDir, "pnpm.mjs");
|
||||
const readyFile = path.join(tempDir, "ready");
|
||||
const descendantPidFile = path.join(tempDir, "descendant.pid");
|
||||
let descendantPid: number | undefined;
|
||||
|
||||
fs.writeFileSync(
|
||||
runnerPath,
|
||||
[
|
||||
"import { spawn } from 'node:child_process';",
|
||||
"import fs from 'node:fs';",
|
||||
"fs.writeFileSync(process.env.READY_FILE, 'ready');",
|
||||
"const child = spawn(process.execPath, ['-e', \"process.on('SIGTERM', () => {}); setInterval(() => {}, 1000);\"], { stdio: 'ignore' });",
|
||||
"child.unref();",
|
||||
"fs.writeFileSync(process.env.DESCENDANT_PID_FILE, String(child.pid));",
|
||||
"process.on('SIGTERM', () => process.exit(0));",
|
||||
"setInterval(() => {}, 1000);",
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
const wrapper = spawn(process.execPath, ["scripts/ui.js", "install"], {
|
||||
cwd: path.resolve("."),
|
||||
env: {
|
||||
...process.env,
|
||||
DESCENDANT_PID_FILE: descendantPidFile,
|
||||
npm_execpath: runnerPath,
|
||||
READY_FILE: readyFile,
|
||||
},
|
||||
stdio: "ignore",
|
||||
});
|
||||
|
||||
try {
|
||||
await waitFor(() => fs.existsSync(descendantPidFile), "UI runner descendant readiness");
|
||||
descendantPid = Number(fs.readFileSync(descendantPidFile, "utf8"));
|
||||
await new Promise<void>((resolve) => {
|
||||
setTimeout(resolve, 300);
|
||||
});
|
||||
|
||||
wrapper.kill("SIGTERM");
|
||||
const exit = await waitForExit(wrapper, 8_000);
|
||||
|
||||
expect(exit).toEqual({ code: null, signal: "SIGTERM" });
|
||||
await waitFor(
|
||||
() => !descendantPid || !pidAlive(descendantPid),
|
||||
"UI runner descendant exit",
|
||||
);
|
||||
} finally {
|
||||
wrapper.kill("SIGKILL");
|
||||
if (descendantPid && pidAlive(descendantPid)) {
|
||||
process.kill(descendantPid, "SIGKILL");
|
||||
}
|
||||
fs.rmSync(tempDir, { force: true, recursive: true });
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
function pidAlive(pid: number): boolean {
|
||||
try {
|
||||
process.kill(pid, 0);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user