Skip to content

fix: Windows compatibility for tests, scripts, and Vitest Explorer#876

Open
EhabY wants to merge 4 commits intomainfrom
fix/windows-cross-platform-compat
Open

fix: Windows compatibility for tests, scripts, and Vitest Explorer#876
EhabY wants to merge 4 commits intomainfrom
fix/windows-cross-platform-compat

Conversation

@EhabY
Copy link
Copy Markdown
Collaborator

@EhabY EhabY commented Apr 8, 2026

  • cross-env for npm scripts: Unix-style VAR=value syntax in npm scripts doesn't work on Windows. Added cross-env to build:production, test, test:extension, and test:webview scripts.
  • Vitest Explorer electron path: Changed vitest.nodeExecutable from node_modules/.bin/electron (doesn't exist on Windows, only electron.cmd does) to node_modules/electron/dist/electron which resolves cross-platform.
  • speedtest tests: execFile cannot spawn .cmd files on Windows (EINVAL). Replaced platform-specific .cmd/shell script creation with a unified approach using process.execPath to run echo-args.js directly on both platforms.
  • sshProcess tests: Path assertions used hardcoded forward slashes. Changed to path.join() so separators match the OS.
  • Integration test compilation: Added compile-tests:integration script and included it in the build step so the Mocha test explorer can discover integration tests after pnpm build.

@EhabY EhabY self-assigned this Apr 8, 2026
@EhabY EhabY force-pushed the fix/windows-cross-platform-compat branch 3 times, most recently from 0121302 to 12b454f Compare April 10, 2026 16:48
EhabY added 4 commits April 10, 2026 22:41
…t electron path

Unix-style `VAR=value` syntax in npm scripts doesn't work on Windows.
Added cross-env to build:production, test, test:extension, and test:webview scripts.
Changed vitest.nodeExecutable to point to the actual electron binary instead of
the .bin shim, which doesn't resolve on Windows (only electron.cmd exists there).
- speedtest tests: use process.execPath instead of .cmd wrapper since
  execFile cannot spawn .cmd files on Windows (EINVAL)
- sshProcess tests: use path.join for expected log paths so separators
  match the OS (backslashes on Windows, forward slashes on Unix)
- Build integration tests on project build.
Replace `as unknown as` cast chains with a generic type parameter and
Reflect.apply for type-safe argument forwarding. Preserve the custom
promisify symbol using Reflect.get/set instead of manual symbol casts.
Extract quoteCommand into shared platform utils and use it in
cliExec and cliConfig tests so assertions match Windows double
quotes vs Unix single quotes.
@EhabY EhabY force-pushed the fix/windows-cross-platform-compat branch from 252a255 to d57a977 Compare April 10, 2026 19:41
// With localeCompare: ["a", "Z"] -> reversed -> "Z" first
// With plain sort(): ["Z", "a"] -> reversed -> "a" first (WRONG)
expect(logPath).toBe("/proxy-logs/Z-999.log");
expect(logPath).toBe(path.join("/proxy-logs", "Z-999.log"));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it a problem if these also begin with /?

Copy link
Copy Markdown
Collaborator Author

@EhabY EhabY Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.join also normalizes so path.join("///proxy-logs/sss", "/abc/") would be \proxy-logs\sss\abc on Windows but /proxy-logs/sss/abc on Linux, the path separators only matter on the start of the first segment (to differentiate absolute from relative paths)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants