Skip to content

Commit 498433a

Browse files
authored
test(ui): remove output-root wrapper seam (#121794)
1 parent e9b687a commit 498433a

2 files changed

Lines changed: 9 additions & 29 deletions

File tree

‎scripts/ui.mts‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22
// Routes UI package commands through the repo's Node/pnpm wrappers.
3-
import { spawn, spawnSync, type ChildProcess, type SpawnOptions } from "node:child_process";
3+
import { spawn, spawnSync, type ChildProcess } from "node:child_process";
44
import fs from "node:fs";
55
import { createRequire } from "node:module";
66
import path from "node:path";
@@ -19,11 +19,12 @@ const FORWARDED_SIGNAL_KILL_GRACE_MS = 250;
1919
type UiSpawnCall = {
2020
args: string[];
2121
command: string;
22-
options: SpawnOptions & {
22+
options: {
2323
cwd: string;
2424
env: NodeJS.ProcessEnv;
2525
shell: boolean;
2626
stdio: "inherit";
27+
windowsVerbatimArguments?: boolean;
2728
};
2829
};
2930

@@ -137,10 +138,11 @@ function runSpawnCall(spawnCall: UiSpawnCall, label: string): void {
137138
return;
138139
}
139140

140-
let forwardedSignal: NodeJS.Signals | null = null;
141+
const forwardedSignals = ["SIGTERM", "SIGHUP"] as const;
142+
let forwardedSignal: (typeof forwardedSignals)[number] | null = null;
141143
let forwardedSignalPids: number[] = [];
142-
let forceKillTimer: NodeJS.Timeout | null = null;
143-
let forwardedSignalDrainTimer: NodeJS.Timeout | null = null;
144+
let forceKillTimer: ReturnType<typeof setTimeout> | null = null;
145+
let forwardedSignalDrainTimer: ReturnType<typeof setInterval> | null = null;
144146
const clearForwardedSignalTimers = () => {
145147
if (forceKillTimer) {
146148
clearTimeout(forceKillTimer);
@@ -166,7 +168,6 @@ function runSpawnCall(spawnCall: UiSpawnCall, label: string): void {
166168
// Keep UI dev children in the foreground process group for native TTY
167169
// resize/job-control behavior. Forward wrapper shutdown signals to the
168170
// captured child tree instead of using a detached process group.
169-
const forwardedSignals: NodeJS.Signals[] = ["SIGTERM", "SIGHUP"];
170171
const signalHandlers = new Map(
171172
forwardedSignals.map((signal) => [
172173
signal,
@@ -338,10 +339,6 @@ function resolveScriptAction(action: string): "dev" | "build" | "test" | null {
338339
return null;
339340
}
340341

341-
export function assertUiBuildOutputRoot(params: { rootDir?: string; fs?: typeof fs } = {}): void {
342-
assertRealOutputRoot(path.join(params.rootDir ?? repoRoot, "dist"), { fs: params.fs ?? fs });
343-
}
344-
345342
function main(argv: string[] = process.argv.slice(2)): void {
346343
const [action, ...rest] = argv;
347344
if (!action) {
@@ -355,7 +352,7 @@ function main(argv: string[] = process.argv.slice(2)): void {
355352
process.exit(2);
356353
}
357354
if (action === "build") {
358-
assertUiBuildOutputRoot();
355+
assertRealOutputRoot(path.join(repoRoot, "dist"));
359356
}
360357

361358
if (process.env.OPENCLAW_BUILD_ALL_NO_PNPM === "1" && action === "build") {

‎test/scripts/ui.test.ts‎

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,13 @@ import { spawn, spawnSync, type ChildProcess } from "node:child_process";
33
import fs from "node:fs";
44
import os from "node:os";
55
import path from "node:path";
6-
import { afterEach, describe, expect, it } from "vitest";
6+
import { describe, expect, it } from "vitest";
77
import {
8-
assertUiBuildOutputRoot,
98
isDirectScriptExecution,
109
resolvePnpmSpawnCall,
1110
resolveSpawnCall,
1211
shouldUseCmdExeForCommand,
1312
} from "../../scripts/ui.mts";
14-
import { useAutoCleanupTempDirTracker } from "../helpers/temp-dir.js";
15-
16-
const tempDirs = useAutoCleanupTempDirTracker(afterEach);
17-
1813
// writeFileSync creates the file before its content lands, so an existence
1914
// poll can observe an empty file on loaded runners; wait for bytes instead.
2015
function readNonEmpty(file: string): string | null {
@@ -59,18 +54,6 @@ async function waitForExit(
5954
}
6055

6156
describe("scripts/ui windows spawn behavior", () => {
62-
it("rejects a symlinked dist root before launching a UI build", () => {
63-
const rootDir = tempDirs.make("openclaw-ui-output-root-");
64-
const targetDir = path.join(rootDir, "live-gateway-dist");
65-
fs.mkdirSync(targetDir);
66-
fs.writeFileSync(path.join(targetDir, "sentinel.js"), "keep\n");
67-
fs.symlinkSync(targetDir, path.join(rootDir, "dist"), "dir");
68-
69-
expect(() => assertUiBuildOutputRoot({ rootDir })).toThrow(/symbolic link/u);
70-
expect(fs.readFileSync(path.join(targetDir, "sentinel.js"), "utf8")).toBe("keep\n");
71-
expect(fs.readlinkSync(path.join(rootDir, "dist"))).toBe(targetDir);
72-
});
73-
7457
it("wraps Windows command launchers with cmd.exe without enabling shell mode", () => {
7558
expect(
7659
shouldUseCmdExeForCommand("C:\\Users\\dev\\AppData\\Local\\pnpm\\pnpm.CMD", "win32"),

0 commit comments

Comments
 (0)