test: stabilize pty and agentic test lanes

This commit is contained in:
Vincent Koc
2026-04-25 18:44:18 -07:00
parent d74f897c1c
commit 526fd9d545
4 changed files with 46 additions and 6 deletions

View File

@@ -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,

View File

@@ -12,6 +12,16 @@ function currentEnv(): Record<string, string> {
);
}
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");

View File

@@ -17,6 +17,16 @@ function currentEnv(): Record<string, string> {
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", {

View File

@@ -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",