fix(server-tests): unblock Windows CI for Claude SDK + .exe launch test

- spawn.launch-regression: insert `--` between `node -e <body>` and the
  user JSON args. Without it Node treats `--config` as a CLI option and
  exits with code 9 ("bad option"). The `--` stops Node's flag parsing
  so userArgs land in process.argv intact.
- claude-agent.integration + claude-sdk-behavior: inject
  spawnClaudeCodeProcess that routes the SDK's launch through our
  spawnProcess (shell: false). On Windows the SDK's default spawn fails
  with EINVAL when pathToClaudeCodeExecutable resolves to a `.cmd` shim
  (CVE-2024-27980). This mirrors what claude-agent.ts does in production.
- 3 cleanup sites (event-stream, integration, sdk-behavior): swallow
  EBUSY/ENOTEMPTY/EPERM around rmSync. The maxRetries window doesn't
  reliably win the Windows cwd-lock race after Claude exits; the OS will
  reap the tmpdir.
This commit is contained in:
Mohamed Boudra
2026-05-08 17:43:15 +07:00
parent b131876e69
commit e490bf1dab
4 changed files with 61 additions and 4 deletions
@@ -158,6 +158,8 @@ function makeLaunchFixture(ext: "exe" | "cmd" | "bat"): LaunchFixture {
if (ext === "exe") {
// Copy node.exe to <command>.exe and run our assert body via -e.
// The `--` separator stops Node from parsing userArgs as Node options
// (e.g. `--config` would otherwise trigger "bad option" → exit 9).
// With -e there is no script slot, so process.argv = [node, ...userArgs] → slice(1).
const binaryPath = path.join(root, `${command}.exe`);
copyFileSync(process.execPath, binaryPath);
@@ -165,7 +167,7 @@ function makeLaunchFixture(ext: "exe" | "cmd" | "bat"): LaunchFixture {
root,
command,
binaryPath,
args: ["-e", ASSERT_SCRIPT_BODY, ...userArgs],
args: ["-e", ASSERT_SCRIPT_BODY, "--", ...userArgs],
expectedArgvJson,
sliceFrom: 1,
};