Skip to content

Commit 1610771

Browse files
authored
test(tooling): remove obsolete runner facades (#124159)
1 parent 6325814 commit 1610771

9 files changed

Lines changed: 16 additions & 190 deletions
Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Delegates explicit test targets to the repository test-projects runner.
2-
import { spawn, type ChildProcess } from "node:child_process";
2+
import { spawn } from "node:child_process";
33
import path from "node:path";
44
import {
55
createVitestProcessCompletion,
@@ -29,16 +29,12 @@ export function resolveTestProjectsRunnerSpawnParams(
2929
};
3030
}
3131

32-
export function spawnTestProjectsRunner(
33-
argv: string[],
34-
env: NodeJS.ProcessEnv,
35-
options: { runnerPath?: string } = {},
36-
) {
32+
export function spawnTestProjectsRunner(argv: string[], env: NodeJS.ProcessEnv) {
3733
let forwardedSignal: NodeJS.Signals | null = null;
3834
const spawnParams = resolveTestProjectsRunnerSpawnParams(env);
3935
const child = spawn(
4036
process.execPath,
41-
["--import", "tsx", options.runnerPath ?? testProjectsRunnerPath, ...argv],
37+
["--import", "tsx", testProjectsRunnerPath, ...argv],
4238
spawnParams,
4339
);
4440
const teardown = installVitestProcessGroupCleanup({
@@ -55,30 +51,3 @@ export function spawnTestProjectsRunner(
5551
}).finally(teardown);
5652
return { child, completion, getForwardedSignal: () => forwardedSignal };
5753
}
58-
59-
export function runTestProjectsDelegation(
60-
argv: string[],
61-
env: NodeJS.ProcessEnv,
62-
options: { runnerPath?: string } = {},
63-
): ChildProcess {
64-
const { child, completion, getForwardedSignal } = spawnTestProjectsRunner(argv, env, options);
65-
completion.then(
66-
({ code, signal }) => {
67-
const forwardedSignal = getForwardedSignal();
68-
if (forwardedSignal) {
69-
process.kill(process.pid, forwardedSignal);
70-
return;
71-
}
72-
if (signal) {
73-
process.kill(process.pid, signal);
74-
return;
75-
}
76-
process.exit(code ?? 1);
77-
},
78-
(error: unknown) => {
79-
console.error(error);
80-
process.exit(1);
81-
},
82-
);
83-
return child;
84-
}

‎scripts/test-projects.test-support.mts‎

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ const EXTENSION_CODEX_APP_SERVER_TOOLS_VITEST_CONFIG =
215215
"test/vitest/vitest.extension-codex-app-server-tools.config.ts";
216216
const EXTENSION_CODEX_SURFACE_VITEST_CONFIG =
217217
"test/vitest/vitest.extension-codex-surface.config.ts";
218-
const EXTENSION_CHANNELS_VITEST_CONFIG = "test/vitest/vitest.extension-channels.config.ts";
219218
const EXTENSION_DIFFS_VITEST_CONFIG = "test/vitest/vitest.extension-diffs.config.ts";
220219
const EXTENSION_DISCORD_VITEST_CONFIG = "test/vitest/vitest.extension-discord.config.ts";
221220
const EXTENSION_FEISHU_VITEST_CONFIG = "test/vitest/vitest.extension-feishu.config.ts";
@@ -505,7 +504,6 @@ const VITEST_CONFIG_BY_KIND: Record<string, string> = {
505504
extensionIrc: EXTENSION_IRC_VITEST_CONFIG,
506505
extensionLine: EXTENSION_LINE_VITEST_CONFIG,
507506
extensionMattermost: EXTENSION_MATTERMOST_VITEST_CONFIG,
508-
extensionChannel: EXTENSION_CHANNELS_VITEST_CONFIG,
509507
extensionTelegram: EXTENSION_TELEGRAM_VITEST_CONFIG,
510508
extensionVoiceCall: EXTENSION_VOICE_CALL_VITEST_CONFIG,
511509
extensionWhatsApp: EXTENSION_WHATSAPP_VITEST_CONFIG,
@@ -3305,9 +3303,6 @@ function classifyTarget(arg: string, cwd: string) {
33053303
if (isQaExtensionRoot(extensionRoot)) {
33063304
return "extensionQa";
33073305
}
3308-
if (isChannelSurfaceTestFile(relative)) {
3309-
return "extensionChannel";
3310-
}
33113306
if (isAcpxExtensionRoot(extensionRoot)) {
33123307
return "extensionAcpx";
33133308
}
@@ -4161,7 +4156,7 @@ export function withRetryNoOutputTimeout<T extends { env?: NodeJS.ProcessEnv }>(
41614156

41624157
export function createVitestRunSpecs(
41634158
args: string[],
4164-
params: { baseEnv?: NodeJS.ProcessEnv; cwd?: string; tempDir?: string } = {},
4159+
params: { baseEnv?: NodeJS.ProcessEnv; cwd?: string } = {},
41654160
) {
41664161
const cwd = params.cwd ?? process.cwd();
41674162
const baseEnv = params.baseEnv ?? process.env;
@@ -4171,10 +4166,7 @@ export function createVitestRunSpecs(
41714166
);
41724167
return plans.map((plan, index) => {
41734168
const includeFilePath = plan.includePatterns
4174-
? path.join(
4175-
params.tempDir ?? os.tmpdir(),
4176-
`openclaw-vitest-include-${randomUUID()}-${index}.json`,
4177-
)
4169+
? path.join(os.tmpdir(), `openclaw-vitest-include-${randomUUID()}-${index}.json`)
41784170
: null;
41794171
return {
41804172
config: plan.config,
@@ -4322,21 +4314,17 @@ function formatFailedShardStatus(failure: FailedVitestShard) {
43224314
return details.length > 0 ? ` (${details.join(", ")})` : "";
43234315
}
43244316

4325-
export function formatFailedShardDigest(
4326-
failures: FailedVitestShard[],
4327-
options: { limit?: number } = {},
4328-
) {
4317+
export function formatFailedShardDigest(failures: FailedVitestShard[]) {
43294318
if (failures.length === 0) {
43304319
return [];
43314320
}
43324321

4333-
const limit = options.limit ?? FAILED_SHARD_DIGEST_LIMIT;
43344322
const orderedFailures = failures.toSorted((left, right) => {
43354323
const leftOrder = typeof left.order === "number" ? left.order : Number.MAX_SAFE_INTEGER;
43364324
const rightOrder = typeof right.order === "number" ? right.order : Number.MAX_SAFE_INTEGER;
43374325
return leftOrder - rightOrder || left.config.localeCompare(right.config);
43384326
});
4339-
const shown = orderedFailures.slice(0, limit);
4327+
const shown = orderedFailures.slice(0, FAILED_SHARD_DIGEST_LIMIT);
43404328
const lines = [`[test] failed shard digest (${failures.length}):`];
43414329
for (const failure of shown) {
43424330
const includePatterns = failure.includePatterns ?? [];
@@ -4350,15 +4338,3 @@ export function formatFailedShardDigest(
43504338
}
43514339
return lines;
43524340
}
4353-
4354-
export function buildVitestArgs(args: string[], cwd = process.cwd()) {
4355-
const [plan] = buildVitestRunPlans(args, cwd);
4356-
if (!plan) {
4357-
return createVitestArgs({
4358-
config: DEFAULT_VITEST_CONFIG,
4359-
forwardedArgs: [],
4360-
watchMode: false,
4361-
});
4362-
}
4363-
return createVitestArgs(plan);
4364-
}

‎src/scripts/test-projects.test.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { resolveVitestCliEntry, resolveVitestNodeArgs } from "../../scripts/run-
1010
const {
1111
applyParallelVitestCachePaths,
1212
buildFullSuiteVitestRunPlans,
13-
buildVitestArgs,
1413
buildVitestRunPlans,
1514
createVitestRunSpecs,
1615
findUnmatchedExplicitTestTargets,
@@ -48,7 +47,11 @@ describe("test-projects args", () => {
4847
});
4948

5049
it("keeps watch mode explicit without leaking the sentinel to Vitest", () => {
51-
expect(buildVitestArgs(["--watch", "--", "src/foo.test.ts"])).toEqual([
50+
const spec = expectDefined(
51+
createVitestRunSpecs(["--watch", "--", "src/foo.test.ts"])[0],
52+
"watch run spec",
53+
);
54+
expect(spec.pnpmArgs).toEqual([
5255
...VITEST_NODE_PREFIX,
5356
"--config",
5457
"test/vitest/vitest.unit.config.ts",
@@ -57,7 +60,8 @@ describe("test-projects args", () => {
5760
});
5861

5962
it("uses run mode by default", () => {
60-
expect(buildVitestArgs(["src/foo.test.ts"])).toEqual([
63+
const spec = expectDefined(createVitestRunSpecs(["src/foo.test.ts"])[0], "run spec");
64+
expect(spec.pnpmArgs).toEqual([
6165
...VITEST_NODE_PREFIX,
6266
"run",
6367
"--config",

‎test/scripts/run-vitest.test.ts‎

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ import fs from "node:fs";
55
import os from "node:os";
66
import nodePath from "node:path";
77
import { setTimeout as delay } from "node:timers/promises";
8-
import { pathToFileURL } from "node:url";
98
import { describe, expect, it, vi } from "vitest";
109
import {
1110
resolveTestProjectsRunnerEnv,
1211
resolveTestProjectsRunnerSpawnParams,
13-
runTestProjectsDelegation,
1412
} from "../../scripts/lib/test-projects-delegation.mts";
1513
import {
1614
DEFAULT_EXTRA_LONG_RUNNING_VITEST_NO_OUTPUT_TIMEOUT_MS,
@@ -796,92 +794,6 @@ describe("scripts/run-vitest", () => {
796794
});
797795
});
798796

799-
posixIt("cleans delegated test-project children when the wrapper is signaled", async () => {
800-
expect(runTestProjectsDelegation).toBeTypeOf("function");
801-
const fixturePath = nodePath.join(
802-
os.tmpdir(),
803-
`openclaw-run-vitest-delegated-signal-${process.pid}-${Date.now()}.mjs`,
804-
);
805-
const childPidPath = nodePath.join(
806-
os.tmpdir(),
807-
`openclaw-run-vitest-delegated-child-${process.pid}-${Date.now()}.pid`,
808-
);
809-
const descendantPidPath = nodePath.join(
810-
os.tmpdir(),
811-
`openclaw-run-vitest-delegated-descendant-${process.pid}-${Date.now()}.pid`,
812-
);
813-
814-
fs.writeFileSync(
815-
fixturePath,
816-
[
817-
'import { spawn } from "node:child_process";',
818-
'import fs from "node:fs";',
819-
'const child = spawn(process.execPath, ["-e", "process.on(\\\'SIGTERM\\\', () => {}); setInterval(() => {}, 1000);"], { stdio: "ignore" });',
820-
"fs.writeFileSync(process.env.OPENCLAW_DELEGATED_SIGNAL_CHILD_PID, String(process.pid));",
821-
"fs.writeFileSync(process.env.OPENCLAW_DELEGATED_SIGNAL_DESCENDANT_PID, String(child.pid));",
822-
"await new Promise(() => {});",
823-
"",
824-
].join("\n"),
825-
);
826-
827-
const runner = spawn(
828-
process.execPath,
829-
[
830-
"--import",
831-
"tsx",
832-
"--input-type=module",
833-
"--eval",
834-
`import { runTestProjectsDelegation } from ${JSON.stringify(
835-
pathToFileURL(nodePath.resolve("scripts/lib/test-projects-delegation.mts")).href,
836-
)}; runTestProjectsDelegation([], process.env, { runnerPath: ${JSON.stringify(fixturePath)} });`,
837-
],
838-
{
839-
env: {
840-
...process.env,
841-
OPENCLAW_DELEGATED_SIGNAL_CHILD_PID: childPidPath,
842-
OPENCLAW_DELEGATED_SIGNAL_DESCENDANT_PID: descendantPidPath,
843-
},
844-
stdio: "ignore",
845-
},
846-
);
847-
let childPid = 0;
848-
let descendantPid = 0;
849-
850-
try {
851-
await waitFor(
852-
() => fs.existsSync(childPidPath) && fs.existsSync(descendantPidPath),
853-
LOAD_SENSITIVE_PROCESS_TIMEOUT_MS,
854-
);
855-
childPid = Number(fs.readFileSync(childPidPath, "utf8"));
856-
descendantPid = Number(fs.readFileSync(descendantPidPath, "utf8"));
857-
expect(Number.isInteger(childPid)).toBe(true);
858-
expect(Number.isInteger(descendantPid)).toBe(true);
859-
expect(isProcessAlive(childPid)).toBe(true);
860-
expect(isProcessAlive(descendantPid)).toBe(true);
861-
862-
expect(runner.pid).toBeGreaterThan(0);
863-
process.kill(runner.pid!, "SIGTERM");
864-
const result = await waitForClose(runner, LOAD_SENSITIVE_PROCESS_TIMEOUT_MS);
865-
866-
expect(result).toEqual({ code: null, signal: "SIGTERM" });
867-
await waitFor(() => !isProcessAlive(childPid), LOAD_SENSITIVE_PROCESS_TIMEOUT_MS);
868-
await waitFor(() => !isProcessAlive(descendantPid), LOAD_SENSITIVE_PROCESS_TIMEOUT_MS);
869-
} finally {
870-
if (runner.pid && isProcessAlive(runner.pid)) {
871-
process.kill(runner.pid, "SIGKILL");
872-
}
873-
if (childPid && isProcessAlive(childPid)) {
874-
process.kill(childPid, "SIGKILL");
875-
}
876-
if (descendantPid && isProcessAlive(descendantPid)) {
877-
process.kill(descendantPid, "SIGKILL");
878-
}
879-
fs.rmSync(fixturePath, { force: true });
880-
fs.rmSync(childPidPath, { force: true });
881-
fs.rmSync(descendantPidPath, { force: true });
882-
}
883-
});
884-
885797
it("spawns vitest in a detached process group on Unix hosts", () => {
886798
expect(resolveVitestSpawnParams({ PATH: "/usr/bin" }, "darwin")).toEqual({
887799
env: { PATH: "/usr/bin" },

‎test/scripts/test-projects.test.ts‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
applyFullExtensionsHeapBudget,
1515
applyParallelVitestCachePaths,
1616
buildFullSuiteVitestRunPlans,
17-
buildVitestArgs,
1817
buildVitestRunPlans,
1918
createVitestRunSpecs,
2019
findUnmatchedExplicitTestTargets,
@@ -2171,7 +2170,6 @@ describe("scripts/test-projects changed-target routing", () => {
21712170
fs.writeFileSync(includeFile, JSON.stringify(files));
21722171
const specs = createVitestRunSpecs([config], {
21732172
baseEnv: { OPENCLAW_VITEST_INCLUDE_FILE: includeFile },
2174-
tempDir,
21752173
});
21762174

21772175
expect(specs).toHaveLength(5);
@@ -2227,7 +2225,6 @@ describe("scripts/test-projects changed-target routing", () => {
22272225
fs.writeFileSync(includeFile, JSON.stringify([`${directory}/src/example.test.ts`]));
22282226
const [spec] = createVitestRunSpecs([directory], {
22292227
baseEnv: { OPENCLAW_VITEST_INCLUDE_FILE: includeFile },
2230-
tempDir,
22312228
});
22322229

22332230
expect(spec).toMatchObject({
@@ -2429,7 +2426,7 @@ describe("scripts/test-projects changed-target routing", () => {
24292426
includePatterns: ["ui/src/e2e/**/*.test.ts"],
24302427
});
24312428

2432-
expect(buildVitestArgs(["ui/src/e2e"])).toContain("--configLoader");
2429+
expect(createVitestRunSpecs(["ui/src/e2e"])[0]?.pnpmArgs).toContain("--configLoader");
24332430
});
24342431

24352432
it("routes auto-reply route source files to route regression tests", () => {
@@ -2544,13 +2541,11 @@ describe("scripts/test-projects changed-target routing", () => {
25442541
});
25452542

25462543
it("uses collision-resistant include-file names for scoped Vitest specs", () => {
2547-
const tempDir = path.join("tmp", "openclaw-vitest-specs");
25482544
const [spec] = createVitestRunSpecs(["src/plugin-sdk/temp-path.test.ts"], {
25492545
baseEnv: {},
2550-
tempDir,
25512546
});
25522547

2553-
expect(path.dirname(spec?.includeFilePath ?? "")).toBe(tempDir);
2548+
expect(path.dirname(spec?.includeFilePath ?? "")).toBe(os.tmpdir());
25542549
expect(path.basename(spec?.includeFilePath ?? "")).toMatch(
25552550
/^openclaw-vitest-include-[0-9a-f-]{36}-0\.json$/u,
25562551
);

‎test/vitest-scoped-config.test.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { createCronVitestConfig } from "./vitest/vitest.cron.config.ts";
2626
import { createDaemonVitestConfig } from "./vitest/vitest.daemon.config.ts";
2727
import { createExtensionAcpxVitestConfig } from "./vitest/vitest.extension-acpx.config.ts";
2828
import { createExtensionBrowserVitestConfig } from "./vitest/vitest.extension-browser.config.ts";
29-
import { createExtensionChannelsVitestConfig } from "./vitest/vitest.extension-channels.config.ts";
3029
import { createExtensionDiffsVitestConfig } from "./vitest/vitest.extension-diffs.config.ts";
3130
import { createExtensionDiscordVitestConfig } from "./vitest/vitest.extension-discord.config.ts";
3231
import { createExtensionFeishuVitestConfig } from "./vitest/vitest.extension-feishu.config.ts";
@@ -524,7 +523,6 @@ describe("scoped vitest configs", () => {
524523
const defaultCliConfig = createCliVitestConfig({});
525524
const defaultExtensionsConfig = createExtensionsVitestConfig({});
526525
const defaultExtensionAcpxConfig = createExtensionAcpxVitestConfig({});
527-
const defaultExtensionChannelsConfig = createExtensionChannelsVitestConfig({});
528526
const defaultExtensionBrowserConfig = createExtensionBrowserVitestConfig({});
529527
const defaultExtensionDiffsConfig = createExtensionDiffsVitestConfig({});
530528
const defaultExtensionDiscordConfig = createExtensionDiscordVitestConfig({});
@@ -584,7 +582,6 @@ describe("scoped vitest configs", () => {
584582
for (const config of [
585583
defaultAcpConfig,
586584
defaultExtensionsConfig,
587-
defaultExtensionChannelsConfig,
588585
defaultExtensionDiscordConfig,
589586
defaultExtensionImessageConfig,
590587
defaultExtensionLineConfig,
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
export const channelTestRoots: string[];
2-
export const extensionChannelTestRoots: string[];
32
export const coreChannelTestRoots: string[];
43
export const channelTestPrefixes: string[];
5-
export const extensionChannelTestInclude: string[];
64
export const coreChannelTestInclude: string[];
75
export const extensionExcludedChannelTestGlobs: string[];
86
export function isChannelSurfaceTestFile(filePath: string): boolean;

‎test/vitest/vitest.channel-paths.mjs‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,10 @@ const normalizeRepoPath = (value) => value.split(path.sep).join("/");
77

88
const channelTestRoots = ["src/channels", ...splitChannelExtensionTestRoots];
99

10-
const splitChannelExtensionTestRootSet = new Set(splitChannelExtensionTestRoots);
11-
12-
const extensionChannelTestRoots = channelTestRoots.filter(
13-
(root) =>
14-
root.startsWith(BUNDLED_PLUGIN_PATH_PREFIX) && !splitChannelExtensionTestRootSet.has(root),
15-
);
1610
const coreChannelTestRoots = channelTestRoots.filter(
1711
(root) => !root.startsWith(BUNDLED_PLUGIN_PATH_PREFIX),
1812
);
1913
const channelTestPrefixes = channelTestRoots.map((root) => `${root}/`);
20-
export const extensionChannelTestInclude = extensionChannelTestRoots.map(
21-
(root) => `${root}/**/*.test.ts`,
22-
);
2314
export const coreChannelTestInclude = coreChannelTestRoots.map((root) => `${root}/**/*.test.ts`);
2415

2516
export const extensionExcludedChannelTestGlobs = channelTestRoots

‎test/vitest/vitest.extension-channels.config.ts‎

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)