Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os/exec: TestCommand fails on Windows when NoDefaultCurrentDirectoryInExePath is set in the environment #62594

Closed
bcmills opened this issue Sep 12, 2023 · 1 comment
Assignees
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows Testing An issue that has been verified to require only test changes, not just a test failure.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Sep 12, 2023

In investigating the data race reported in https://go.dev/cl/527337, I looked at the existing tests that cover the call to lookExtensions is exec.Cmd.Start on Windows.

I found several test cases in TestCommand that look suspicious: they expect exec.LookPath to always resolve a bare filename relative to the current directory, possibly with an ErrDot error. However, if NoDefaultCurrentDirectoryInExePath is set in the environment, exec.LookPath does not even attempt to resolve in the current directory, so the tests presumably won't pass.

Running the tests on a gomote confirms that hypothesis as of https://go.dev/cl/527337:

gopher@GOLANG-BUILDLET C:\workdir\go\src>set NoDefaultCurrentDirectoryInExePath=TRUE

gopher@GOLANG-BUILDLET C:\workdir\go\src>..\bin\go test os/exec
--- FAIL: TestCommand (0.58s)
    --- FAIL: TestCommand/2 (0.06s)
        lp_windows_test.go:396: test={PATH:p2;p files:[a.exe p\a.exe p2\a.exe] dir: arg
0:a want:a.exe fails:false}: want "a.exe", got "p2\\a.exe"
    --- FAIL: TestCommand/10 (0.07s)
        lp_windows_test.go:396: test={PATH:p2;p files:[a.exe p\a.exe p2\a.exe] dir:p ar
g0:a.exe want:p\a.exe fails:false}: want "p\\a.exe", got "p2\\a.exe"
    --- FAIL: TestCommand/11 (0.06s)
        lp_windows_test.go:396: test={PATH:p2;p files:[a.exe p\a.exe p2\a.exe] dir:p ar
g0:a want:p\a.exe fails:false}: want "p\\a.exe", got "p2\\a.exe"
    --- FAIL: TestCommand/1 (0.06s)
        lp_windows_test.go:396: test={PATH:p2;p files:[a.exe p\a.exe p2\a.exe] dir: arg
0:a.exe want:a.exe fails:false}: want "a.exe", got "p2\\a.exe"
FAIL
FAIL    os/exec 0.947s
FAIL

(CC @golang/windows, @ianlancetaylor)

@bcmills bcmills added OS-Windows NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Sep 12, 2023
@bcmills bcmills added this to the Backlog milestone Sep 12, 2023
@bcmills bcmills self-assigned this Sep 12, 2023
@bcmills bcmills added the Testing An issue that has been verified to require only test changes, not just a test failure. label Sep 12, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/528035 mentions this issue: os/exec: simplify Windows-specific tests

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows Testing An issue that has been verified to require only test changes, not just a test failure.
Projects
None yet
Development

No branches or pull requests

2 participants