Skip to content

Commit

Permalink
exec(test): Do not clear PATH; this breaks coverage on Windows (#2150)
Browse files Browse the repository at this point in the history
## Changes
When setting up PATH in tests, put desired entry first but keep the rest
as well. Otherwise it fails on Windows

```
D:/a/cli/cli/libs/exec/exec_test.go:108
Error: Received unexpected error:
exit status 0xc0000135
```

Explanation from Claude:
> The error code 0xc0000135 is a Windows error indicating "Unable to
locate DLL"
> When code coverage is enabled, Go instruments the binary with coverage
tracking code, which requires additional DLL dependencies on Windows.

## Tests
Separate draft PR with coverage enabled on CI:
#2141
  • Loading branch information
denik authored Jan 15, 2025
1 parent 983a8a6 commit 40e96b5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libs/exec/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func testExecutorWithShell(t *testing.T, shell string) {

// Create temporary directory with only the shell executable in the PATH.
tmpDir := t.TempDir()
t.Setenv("PATH", tmpDir)
t.Setenv("PATH", fmt.Sprintf("%s%c%s", tmpDir, os.PathListSeparator, os.Getenv("PATH")))
if runtime.GOOS == "windows" {
err = os.Symlink(p, fmt.Sprintf("%s/%s.exe", tmpDir, shell))
require.NoError(t, err)
Expand Down

0 comments on commit 40e96b5

Please sign in to comment.