Fix Windows test compatibility for ProcessBuilder usage#66
Merged
edburns merged 1 commit intogithub:mainfrom Apr 11, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Improves Windows compatibility for tests that spawn external processes via ProcessBuilder, avoiding failures due to Windows-specific executable resolution (.cmd) and Unix-only commands/paths.
Changes:
- Update
CapiProxyto start the test harness viacmd /c npx ...on Windows. - Update unit tests to avoid Unix-only process commands and to use a Windows-absolute nonexistent CLI path.
- Preserve existing behavior on Linux/macOS via runtime
os.namedetection.
Show a summary per file
| File | Description |
|---|---|
src/test/java/com/github/copilot/sdk/JsonRpcClientTest.java |
Switches dummy process creation to use a Windows-compatible command. |
src/test/java/com/github/copilot/sdk/CliServerManagerTest.java |
Uses a Windows-absolute nonexistent CLI path and updates stdio dummy process creation. |
src/test/java/com/github/copilot/sdk/CapiProxy.java |
Launches npx tsx server.ts through cmd /c on Windows to handle npx.cmd. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/test/java/com/github/copilot/sdk/JsonRpcClientTest.java:156
- Same issue as above: the Windows dummy process (
cmd /c type NUL) can exit immediately, so this test may not actually cover the “process becomes dead after being alive” scenario. Consider switching the Windows branch to a command that blocks on stdin so the process is reliably alive until you destroy it in the test.
boolean isWindows = System.getProperty("os.name").toLowerCase().contains("win");
Process proc = isWindows
? new ProcessBuilder("cmd", "/c", "type", "NUL").start()
: new ProcessBuilder("cat").start();
var client = JsonRpcClient.fromProcess(proc);
proc.destroy();
proc.waitFor(5, TimeUnit.SECONDS);
assertFalse(client.isConnected());
- Files reviewed: 3/3 changed files
- Comments generated: 2
6 tasks
On Windows, Java's ProcessBuilder cannot directly run shell wrappers like `npx` (installed as npx.cmd) or Unix commands like `cat`. Tests that used these commands failed with "Cannot run program" errors. Additionally, Unix-style paths like "/nonexistent/copilot" are not absolute on Windows, causing assertThrows(IOException) tests to pass unexpectedly when CliServerManager wrapped them with "cmd /c". Changes: - CapiProxy: use "cmd /c npx" on Windows to launch the test harness - CliServerManagerTest: replace "cat" with cross-platform dummy process; use a platform-appropriate nonexistent absolute path so IOException is thrown on all platforms - JsonRpcClientTest: replace "cat" with cross-platform dummy process All changes use runtime os.name detection and preserve existing behavior on Linux and macOS. Full test suite passes on all platforms (556 tests, 0 failures, 0 errors).
6cabb00 to
fc71b95
Compare
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.
Fixes #65 .
On Windows, Java's ProcessBuilder cannot directly run shell wrappers like
npx(installed as npx.cmd) or Unix commands likecat. Tests that used these commands failed with "Cannot run program" errors. Additionally, Unix-style paths like "/nonexistent/copilot" are not absolute on Windows, causing assertThrows(IOException) tests to pass unexpectedly when CliServerManager wrapped them with "cmd /c".Changes:
All changes use runtime os.name detection and preserve existing behavior on Linux and macOS. Full test suite passes on all platforms (556 tests, 0 failures, 0 errors).
Resolves #65