fix: Windows compatibility for tests, scripts, and Vitest Explorer#876
Open
fix: Windows compatibility for tests, scripts, and Vitest Explorer#876
Conversation
0121302 to
12b454f
Compare
…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.
252a255 to
d57a977
Compare
| // 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")); |
There was a problem hiding this comment.
is it a problem if these also begin with /?
Collaborator
Author
There was a problem hiding this comment.
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
VAR=valuesyntax in npm scripts doesn't work on Windows. Addedcross-envtobuild:production,test,test:extension, andtest:webviewscripts.vitest.nodeExecutablefromnode_modules/.bin/electron(doesn't exist on Windows, onlyelectron.cmddoes) tonode_modules/electron/dist/electronwhich resolves cross-platform.execFilecannot spawn.cmdfiles on Windows (EINVAL). Replaced platform-specific.cmd/shell script creation with a unified approach usingprocess.execPathto runecho-args.jsdirectly on both platforms.path.join()so separators match the OS.compile-tests:integrationscript and included it in thebuildstep so the Mocha test explorer can discover integration tests afterpnpm build.