From 526fd9d54586b85bc7e7f19a5f920f6475432a45 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sat, 25 Apr 2026 18:44:18 -0700 Subject: [PATCH] test: stabilize pty and agentic test lanes --- scripts/test-projects.test-support.mjs | 6 +++++- src/agents/bash-tools.exec.pty.test.ts | 14 ++++++++++++-- .../bash-tools.process.send-keys.test.ts | 18 ++++++++++++++++-- test/scripts/test-projects.test.ts | 14 +++++++++++++- 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/scripts/test-projects.test-support.mjs b/scripts/test-projects.test-support.mjs index be50d2708f8..dc06c8fd6d5 100644 --- a/scripts/test-projects.test-support.mjs +++ b/scripts/test-projects.test-support.mjs @@ -97,6 +97,7 @@ const EXTENSION_VOICE_CALL_VITEST_CONFIG = "test/vitest/vitest.extension-voice-c const EXTENSION_WHATSAPP_VITEST_CONFIG = "test/vitest/vitest.extension-whatsapp.config.ts"; const EXTENSION_ZALO_VITEST_CONFIG = "test/vitest/vitest.extension-zalo.config.ts"; const EXTENSIONS_VITEST_CONFIG = "test/vitest/vitest.extensions.config.ts"; +const FULL_AGENTIC_VITEST_CONFIG = "test/vitest/vitest.full-agentic.config.ts"; const FULL_EXTENSIONS_VITEST_CONFIG = "test/vitest/vitest.full-extensions.config.ts"; const GATEWAY_CLIENT_VITEST_CONFIG = "test/vitest/vitest.gateway-client.config.ts"; const GATEWAY_CORE_VITEST_CONFIG = "test/vitest/vitest.gateway-core.config.ts"; @@ -1056,7 +1057,10 @@ export function buildFullSuiteVitestRunPlans(args, cwd = process.cwd()) { ) { return []; } - const expandShard = expandToProjectConfigs || shard.config === FULL_EXTENSIONS_VITEST_CONFIG; + const expandShard = + expandToProjectConfigs || + shard.config === FULL_AGENTIC_VITEST_CONFIG || + shard.config === FULL_EXTENSIONS_VITEST_CONFIG; const configs = expandShard ? shard.projects : [shard.config]; return configs.map((config) => ({ config, diff --git a/src/agents/bash-tools.exec.pty.test.ts b/src/agents/bash-tools.exec.pty.test.ts index 15d73594f01..368bc970a7f 100644 --- a/src/agents/bash-tools.exec.pty.test.ts +++ b/src/agents/bash-tools.exec.pty.test.ts @@ -12,6 +12,16 @@ function currentEnv(): Record { ); } +function shellQuote(value: string): string { + return `'${value.replaceAll("'", process.platform === "win32" ? "''" : "'\\''")}'`; +} + +function currentNodeEvalCommand(source: string): string { + const node = shellQuote(process.execPath); + const script = shellQuote(source); + return process.platform === "win32" ? `& ${node} -e ${script}` : `${node} -e ${script}`; +} + async function runPtyCommand(command: string) { const handle = await runExecProcess({ command, @@ -29,7 +39,7 @@ async function runPtyCommand(command: string) { test("exec supports pty output", async () => { const result = await runPtyCommand( - 'node -e "process.stdout.write(String.fromCharCode(111,107))"', + currentNodeEvalCommand("process.stdout.write(String.fromCharCode(111,107))"), ); expect(result.status).toBe("completed"); @@ -38,7 +48,7 @@ test("exec supports pty output", async () => { test("exec sets OPENCLAW_SHELL in pty mode", async () => { const result = await runPtyCommand( - "node -e \"process.stdout.write(process.env.OPENCLAW_SHELL || '')\"", + currentNodeEvalCommand('process.stdout.write(process.env.OPENCLAW_SHELL || "")'), ); expect(result.status).toBe("completed"); diff --git a/src/agents/bash-tools.process.send-keys.test.ts b/src/agents/bash-tools.process.send-keys.test.ts index 380e541919e..cb60e129187 100644 --- a/src/agents/bash-tools.process.send-keys.test.ts +++ b/src/agents/bash-tools.process.send-keys.test.ts @@ -17,6 +17,16 @@ function currentEnv(): Record { return env; } +function shellQuote(value: string): string { + return `'${value.replaceAll("'", process.platform === "win32" ? "''" : "'\\''")}'`; +} + +function currentNodeEvalCommand(source: string): string { + const node = shellQuote(process.execPath); + const script = shellQuote(source); + return process.platform === "win32" ? `& ${node} -e ${script}` : `${node} -e ${script}`; +} + async function startPtySession(command: string) { const processTool = createProcessTool(); const run = await runExecProcess({ @@ -64,7 +74,9 @@ async function waitForSessionCompletion(params: { test("process send-keys encodes Enter for pty sessions", async () => { const { processTool, sessionId } = await startPtySession( - 'node -e "const dataEvent=String.fromCharCode(100,97,116,97);process.stdin.on(dataEvent,d=>{process.stdout.write(d);if(d.includes(10)||d.includes(13))process.exit(0);});"', + currentNodeEvalCommand( + "const dataEvent=String.fromCharCode(100,97,116,97);process.stdin.on(dataEvent,d=>{process.stdout.write(d);if(d.includes(10)||d.includes(13))process.exit(0);});", + ), ); await processTool.execute("toolcall", { @@ -78,7 +90,9 @@ test("process send-keys encodes Enter for pty sessions", async () => { test("process submit sends Enter for pty sessions", async () => { const { processTool, sessionId } = await startPtySession( - 'node -e "const dataEvent=String.fromCharCode(100,97,116,97);const submitted=String.fromCharCode(115,117,98,109,105,116,116,101,100);process.stdin.on(dataEvent,d=>{if(d.includes(10)||d.includes(13)){process.stdout.write(submitted);process.exit(0);}});"', + currentNodeEvalCommand( + "const dataEvent=String.fromCharCode(100,97,116,97);const submitted=String.fromCharCode(115,117,98,109,105,116,116,101,100);process.stdin.on(dataEvent,d=>{if(d.includes(10)||d.includes(13)){process.stdout.write(submitted);process.exit(0);}});", + ), ); await processTool.execute("toolcall", { diff --git a/test/scripts/test-projects.test.ts b/test/scripts/test-projects.test.ts index 609ae435004..26889c3c1f7 100644 --- a/test/scripts/test-projects.test.ts +++ b/test/scripts/test-projects.test.ts @@ -635,7 +635,19 @@ describe("scripts/test-projects full-suite sharding", () => { "test/vitest/vitest.full-core-contracts.config.ts", "test/vitest/vitest.full-core-bundled.config.ts", "test/vitest/vitest.full-core-runtime.config.ts", - "test/vitest/vitest.full-agentic.config.ts", + "test/vitest/vitest.gateway-core.config.ts", + "test/vitest/vitest.gateway-client.config.ts", + "test/vitest/vitest.gateway-methods.config.ts", + "test/vitest/vitest.gateway-server.config.ts", + "test/vitest/vitest.cli.config.ts", + "test/vitest/vitest.commands-light.config.ts", + "test/vitest/vitest.commands.config.ts", + "test/vitest/vitest.agents.config.ts", + "test/vitest/vitest.daemon.config.ts", + "test/vitest/vitest.plugin-sdk-light.config.ts", + "test/vitest/vitest.plugin-sdk.config.ts", + "test/vitest/vitest.plugins.config.ts", + "test/vitest/vitest.channels.config.ts", "test/vitest/vitest.full-auto-reply.config.ts", "test/vitest/vitest.extension-acpx.config.ts", "test/vitest/vitest.extension-bluebubbles.config.ts",