exec(test): Do not clear PATH; this breaks coverage on Windows (#2150)

## 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:
https://github.com/databricks/cli/pull/2141
This commit is contained in:
Denis Bilenko 2025-01-15 12:05:46 +01:00 committed by GitHub
parent 983a8a6633
commit 40e96b5af2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -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)