test(plugins): run the plugin SDK and .cmd launch wraps on real Windows

The plugin SDK tests ran only on Ubuntu, so cmd.exe never saw a launch wrap.
A Windows job now runs them, with real .cmd launcher tests for arguments
that cmd.exe reads as syntax. The terminal and worktree wrap test uses a .cmd
launcher in a directory with spaces and parentheses on Windows. The plugin
configuration e2e suite joins the integration run, which it was missing from.
This commit is contained in:
Mohamed Boudra
2026-11-25 17:37:32 +01:00
parent 5dcd1e1e57
commit f088fa5049
5 changed files with 122 additions and 5 deletions
+23
View File
@@ -131,6 +131,29 @@ jobs:
if: ${{ !cancelled() && steps.install.outcome == 'success' && (needs.changes.outputs.full != 'false' || needs.changes.outputs.sdk != 'false') }}
run: npm run typecheck:examples --workspace=@getpaseo/client
# Plugin process launches and launch wraps quote for cmd.exe, which only real Windows checks.
sdk-tests-windows:
name: sdk-tests (windows-latest)
needs: changes
if: ${{ !cancelled() && (needs.changes.outputs.full != 'false' || needs.changes.outputs.sdk != 'false') }}
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"
- name: Install dependencies
run: node scripts/npm-retry.mjs ci
- name: Build plugin SDK
run: npm run build:relay && npm run build:client && npm run build:plugin
- name: Run plugin SDK tests
run: npm run test --workspace=@getpaseo/plugin
# The locked Playwright installers do not support ubuntu-latest's Ubuntu 26.04.
typecheck:
name: typecheck
@@ -104,3 +104,82 @@ test("spawnProcess starts a wrap's executable with the command after the wrap ar
...argumentsToPreserve,
]);
});
// Arguments that cmd.exe reads as syntax unless they are escaped for it. A `.cmd` launcher reads
// its arguments a second time when it forwards them with `%*`.
const commandScriptArguments = [
...argumentsToPreserve,
'say "hi"',
'"quoted"',
"",
"a & b",
"(parenthesized) arg",
"100% done",
"%PATH%",
"!bang!",
"C:\\path with space\\",
'mixed "a & b" quote',
];
async function writeCommandScriptLauncher(): Promise<string> {
const reader = await writeArgumentReader();
const directory = await mkdtemp(path.join(os.tmpdir(), "plugin wrap (x86) & launcher "));
roots.push(directory);
const launcher = path.join(directory, "sandbox run.cmd");
await writeFile(launcher, `@"${process.execPath}" "${reader}" %*\r\n`);
return launcher;
}
async function readStdout(child: ReturnType<typeof spawnProcess>): Promise<string> {
let stdout = "";
child.stdout?.setEncoding("utf8");
child.stdout?.on("data", (chunk: string) => {
stdout += chunk;
});
await new Promise<void>((resolve, reject) => {
child.once("error", reject);
child.once("close", (code) => {
if (code === 0) resolve();
else reject(new Error(`Child exited with ${code}`));
});
});
return stdout;
}
// Real cmd.exe: a `.cmd` launch wrap in a directory with spaces and cmd.exe syntax forwards the
// harness command and every argument to the program it starts, unchanged.
test.runIf(process.platform === "win32")(
"a .cmd launch wrap forwards the command and its arguments unchanged on Windows",
async () => {
const launcher = await writeCommandScriptLauncher();
const child = spawnProcess("harness", commandScriptArguments, {
wrap: [launcher, "--sandbox profile", 'say "hi"', ""],
stdio: "pipe",
});
expect(JSON.parse(await readStdout(child))).toEqual([
"--sandbox profile",
'say "hi"',
"",
"harness",
...commandScriptArguments,
]);
},
);
test.runIf(process.platform === "win32")(
"execCommand runs a .cmd script with its arguments unchanged on Windows",
async () => {
const launcher = await writeCommandScriptLauncher();
const { stdout } = await execCommand(launcher, commandScriptArguments);
expect(JSON.parse(stdout)).toEqual(commandScriptArguments);
},
);
test.runIf(process.platform === "win32")(
"a bare command name gets its arguments unchanged through cmd.exe on Windows",
async () => {
const reader = await writeArgumentReader();
const { stdout } = await execCommand("node", [reader, ...commandScriptArguments]);
expect(JSON.parse(stdout)).toEqual(commandScriptArguments);
},
);
+1 -1
View File
@@ -90,7 +90,7 @@
"speech:transcribe:local": "tsx scripts/transcribe-local-wav.ts",
"test": "npm run test:unit && npm run test:integration",
"test:unit": "vitest run --fileParallelism --exclude \"**/*.e2e.test.ts\"",
"test:integration": "vitest run --fileParallelism --maxWorkers=3 src/server/git-filename-diffs.e2e.test.ts src/server/daemon-e2e/checkout-diff-content.e2e.test.ts src/server/daemon-e2e/create-agent-mode.e2e.test.ts src/server/daemon-e2e/filesystem.e2e.test.ts src/server/daemon-e2e/file-download.e2e.test.ts src/server/daemon-e2e/cli-logs-follow.e2e.test.ts src/server/creation/creation.e2e.test.ts src/server/daemon-e2e/creation-status.e2e.test.ts src/server/daemon-e2e/persisted-creation-caller.e2e.test.ts src/server/daemon-e2e/terminal-workspace-sdk.e2e.test.ts src/server/daemon-e2e/terminal-worker-lifecycle.e2e.test.ts src/server/workspace-create-worktree-source.e2e.test.ts src/server/daemon-e2e/models.e2e.test.ts src/server/daemon-e2e/live-preferences.e2e.test.ts src/server/daemon-e2e/oversized-message.e2e.test.ts src/server/agent/model-catalog.e2e.test.ts src/server/plugins/plugin-paseo-api.e2e.test.ts src/server/plugins/usage-sources.e2e.test.ts src/server/plugins/lifecycle.e2e.test.ts src/server/plugins/worktree-manager.e2e.test.ts src/server/connected-hosts/hosts.e2e.test.ts src/server/owned-subscriptions.e2e.test.ts && vitest run --fileParallelism --maxWorkers=3 src/server/agent/providers/omp/history.e2e.test.ts src/server/daemon-e2e/git-operations.e2e.test.ts src/server/session.create-agent-worktree-autoarchive.e2e.test.ts src/server/agent/providers/opencode-bridge.local.e2e.test.ts src/server/daemon-e2e/relay-transport.e2e.test.ts src/server/agent/agent-mcp.e2e.test.ts -t \"agent MCP protocol negotiation|merges into|creates a worktree and auto-archives both|versioned runtime|oversized attachments|connected hosts|password-protected daemon refuses|replays selected OMP history\"",
"test:integration": "vitest run --fileParallelism --maxWorkers=3 src/server/git-filename-diffs.e2e.test.ts src/server/daemon-e2e/checkout-diff-content.e2e.test.ts src/server/daemon-e2e/create-agent-mode.e2e.test.ts src/server/daemon-e2e/filesystem.e2e.test.ts src/server/daemon-e2e/file-download.e2e.test.ts src/server/daemon-e2e/cli-logs-follow.e2e.test.ts src/server/creation/creation.e2e.test.ts src/server/daemon-e2e/creation-status.e2e.test.ts src/server/daemon-e2e/persisted-creation-caller.e2e.test.ts src/server/daemon-e2e/terminal-workspace-sdk.e2e.test.ts src/server/daemon-e2e/terminal-worker-lifecycle.e2e.test.ts src/server/workspace-create-worktree-source.e2e.test.ts src/server/daemon-e2e/models.e2e.test.ts src/server/daemon-e2e/live-preferences.e2e.test.ts src/server/daemon-e2e/oversized-message.e2e.test.ts src/server/agent/model-catalog.e2e.test.ts src/server/plugins/plugin-paseo-api.e2e.test.ts src/server/plugins/usage-sources.e2e.test.ts src/server/plugins/lifecycle.e2e.test.ts src/server/plugins/agent-configuration.e2e.test.ts src/server/plugins/worktree-manager.e2e.test.ts src/server/connected-hosts/hosts.e2e.test.ts src/server/owned-subscriptions.e2e.test.ts && vitest run --fileParallelism --maxWorkers=3 src/server/agent/providers/omp/history.e2e.test.ts src/server/daemon-e2e/git-operations.e2e.test.ts src/server/session.create-agent-worktree-autoarchive.e2e.test.ts src/server/agent/providers/opencode-bridge.local.e2e.test.ts src/server/daemon-e2e/relay-transport.e2e.test.ts src/server/agent/agent-mcp.e2e.test.ts -t \"agent MCP protocol negotiation|merges into|creates a worktree and auto-archives both|versioned runtime|oversized attachments|connected hosts|password-protected daemon refuses|replays selected OMP history\"",
"test:hub-cli-contract": "vitest run --maxWorkers=1 src/server/hub/hub-cli-contract.test.ts",
"test:integration:all": "npm run test:e2e",
"test:integration:real": "vitest run real.e2e.test.ts",
@@ -630,8 +630,11 @@ test("plugins wrap or refuse terminals and worktree setup and teardown commands"
const repository = path.join(root, "repository");
const pluginDirectory = path.join(root, "plugin");
const hookLog = path.join(root, "hooks.jsonl");
const launchLog = path.join(root, "launches.jsonl");
const launcher = path.join(root, "launcher.cjs");
// Spaces and cmd.exe syntax in the sandbox's install path, as in `C:\Program Files (x86)`.
const sandboxDirectory = path.join(root, "sandbox launcher (x86)");
await mkdir(sandboxDirectory);
const launchLog = path.join(sandboxDirectory, "launches.jsonl");
const launcher = path.join(sandboxDirectory, "launcher.cjs");
// The sandbox stand-in: records the argv after its own two, marks the environment, runs the rest.
await writeFile(
launcher,
@@ -644,6 +647,10 @@ for (const signal of ["SIGTERM", "SIGHUP", "SIGINT"]) process.on(signal, () => c
child.on("exit", (code) => process.exit(code ?? 1));
`,
);
// Windows sandboxes ship a `.cmd` entry point, which runs through cmd.exe and forwards `%*`.
const commandScript = path.join(sandboxDirectory, "sandbox run.cmd");
await writeFile(commandScript, `@"${process.execPath}" "${launcher}" %*\r\n`);
const wrapPrefix = process.platform === "win32" ? [commandScript] : [process.execPath, launcher];
// Node one-liners read the environment the same way under bash, PowerShell, and cmd.exe.
const setupCommand = `node -e "require('fs').writeFileSync('setup.txt', 'setup:' + process.env.HOOK_MARK + ':' + process.env.WRAPPED)"`;
const teardownCommand = `node -e "require('fs').writeFileSync(require('path').join(process.env.PASEO_SOURCE_CHECKOUT_PATH, '..', 'teardown.txt'), 'teardown:' + process.env.HOOK_MARK + ':' + process.env.WRAPPED)"`;
@@ -679,7 +686,7 @@ child.on("exit", (code) => process.exit(code ?? 1));
`
import { appendFile } from "node:fs/promises";
const log = (entry) => appendFile(${JSON.stringify(hookLog)}, JSON.stringify(entry) + "\\n");
const wrap = (tag) => [${JSON.stringify(process.execPath)}, ${JSON.stringify(launcher)}, ${JSON.stringify(launchLog)}, tag];
const wrap = (tag) => [...${JSON.stringify(wrapPrefix)}, ${JSON.stringify(launchLog)}, tag];
export default function contribute(server) {
server.addHook("terminal.create.before", async ({ request }) => {
await log({ hook: "terminal", request });
+9 -1
View File
@@ -19,6 +19,7 @@ const desktopPackagePath = new URL("packages/desktop/package.json", repoRoot);
const gatedCiJobs = new Map([
["quality", { name: "quality", contracts: ["format", "quality", "relay", "sdk"] }],
["sdk-tests-windows", { name: "sdk-tests (windows-latest)", contract: "sdk" }],
["typecheck", { name: "typecheck", contract: "quality" }],
["server-tests-ubuntu", { name: "server-tests (ubuntu-latest)", contracts: ["server", "hub"] }],
["server-tests-windows", { name: "server-tests (windows-latest)", contracts: ["server", "hub"] }],
@@ -437,7 +438,7 @@ test("stable iOS releases upload once and distribute to external testers before
test("eight Playwright shards share two-worker coverage", () => {
const source = readFileSync(ciWorkflowPath, "utf8");
const jobs = jobBlocks(source);
assert.equal(jobs.size, 21);
assert.equal(jobs.size, 22);
for (let shard = 1; shard <= 8; shard++) {
const job = jobs.get(`playwright-${shard}`).join("\n");
assert.match(job, new RegExp(`PLAYWRIGHT_SHARD: "${shard}/8"`));
@@ -517,6 +518,13 @@ test("quality preserves commands and routes each domain independently after fail
assert.equal(accepts(jobCondition, {}, { cancelled: true }), false);
});
test("plugin SDK tests run on real Windows", () => {
const sdk = jobBlocks(readFileSync(ciWorkflowPath, "utf8")).get("sdk-tests-windows").join("\n");
assert.match(sdk, /^ runs-on: windows-latest$/m);
assert.match(sdk, /run: npm run test --workspace=@getpaseo\/plugin$/m);
assert.doesNotMatch(sdk, /continue-on-error/);
});
test("Windows units and integration run independently with complete routed coverage", () => {
const source = readFileSync(ciWorkflowPath, "utf8");
const jobs = jobBlocks(source);