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

cmd/go: TestShadowingLogic fails on windows xp #11459

Closed
alexbrainman opened this issue Jun 29, 2015 · 2 comments
Closed

cmd/go: TestShadowingLogic fails on windows xp #11459

alexbrainman opened this issue Jun 29, 2015 · 2 comments

Comments

@alexbrainman
Copy link
Member

C:\dev\go\src\cmd\go>go test -run=TestShadowingLogic
--- FAIL: TestShadowingLogic (0.78s)
        go_test.go:238: running testgo [list -f ({{.ImportPath}}) ({{.ConflictDir}}) ./testdata/shadow/root1/src/math]
        go_test.go:253: standard output:
        go_test.go:254: (_/c_/dev/go/src/cmd/go/testdata/shadow/root1/src/math) (C:\dev\go\src\math)

        go_test.go:1513: shadowed math is not shadowed; looking for (_/c_/dev/go/src/cmd/go/testdata/shadow/root1/src/math) (c:\dev\go\src\math)
        go_test.go:238: running testgo [list -f ({{.ImportPath}}) ({{.ConflictDir}}) ./testdata/shadow/root1/src/foo]
        go_test.go:253: standard output:
        go_test.go:254: (foo) ()

        go_test.go:238: running testgo [list -f ({{.ImportPath}}) ({{.ConflictDir}}) ./testdata/shadow/root2/src/foo]
        go_test.go:253: standard output:
        go_test.go:254: (_/c_/dev/go/src/cmd/go/testdata/shadow/root2/src/foo) (c:\dev\go\src\cmd\go\testdata\shadow\root1\src\foo)

        go_test.go:238: running testgo [install ./testdata/shadow/root2/src/foo]

        go_test.go:257: standard error:
        go_test.go:258: go install: no install location for c:\dev\go\src\cmd\go\testdata\shadow\root2\src\foo: hidden by c:\dev\go\src\cmd\go\testdata\shadow\root1\src\foo

        go_test.go:277: testgo failed as expected: exit status 1
FAIL
exit status 1
FAIL    cmd/go  8.104s

C:\dev\go\src\cmd\go>go version
go version devel +0bafe0e Mon Jun 29 03:54:33 2015 +0000 windows/386

C:\dev\go\src\cmd\go>go env
set GOARCH=386
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=386
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=c:\dev
set GORACE=
set GOROOT=c:\dev\go
set GOTOOLDIR=c:\dev\go\pkg\tool\windows_386
set CC=gcc
set GOGCCFLAGS=-m32 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1

C:\dev\go\src\cmd\go>

Test fails because go list output of {{.ConflictDir}} (C:\dev\go\src\math) does not match runtime.GOROOT()+... (c:\dev\go\src\math). It is the drive letter case that is different. My GOROOT is set to c:\dev\go, so I would expect go list output to be the same. It seems go list is using runtime.defaultGoroot, because TestMain clears GOROOT environment variable. And runtime.defaultGoroot strangely is set to C:\dev\go.

I use this batch file to set my environment:

set GOROOT=c:\dev\go
set GOROOT_BOOTSTRAP=c:\dev\go1.4
set GOPATH=c:\dev
set PATH=%PATH%;c:\dev\mingw\bin;c:\dev\my\bin\;%GOROOT%\bin
cd %GOROOT%\src
CMD

this is what I see when I run it:

C:\Documents and Settings\brainman\Desktop>set GOROOT=c:\dev\go

C:\Documents and Settings\brainman\Desktop>set GOROOT_BOOTSTRAP=c:\dev\go1.4

C:\Documents and Settings\brainman\Desktop>set GOPATH=c:\dev

C:\Documents and Settings\brainman\Desktop>set PATH=C:\Program Files\...

C:\Documents and Settings\brainman\Desktop>cd c:\dev\go\src

C:\dev\go\src>CMD
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\dev\go\src>

Note how command.com ignores my "cd c:\dev\go\src" command and sets prompt to "C:\dev\go\src". I can confirm this with:

C:\dev\go\src>echo %CD%
C:\dev\go\src

C:\dev\go\src>

Our make.bat uses %CD% to setup GOROOT_FINAL, and GOROOT_FINAL is used to setup runtime.defaultGoroot.

This only breaks on windows xp. My windows 7 current directory keeps drive letter case as specified.

I am wandering if I should adjust the test or there is something more sinister that we need to deal with.

Alex

cc @rsc

@ianlancetaylor
Copy link
Contributor

I vote for modifying the test. I suggest something like
if got := strings.TrimSpace(tg.getStdout()); got != want {
// issue 11459
if runtime.GOOS == "windows" && strings.EqualFold(got, want) {
} else {
t.Error(...)
}

@alexbrainman
Copy link
Member Author

Accidentally fixed by 6a90b1d. The change stops clearing GOROOT for the child go command execution. So now we're comparing %GOROOT% with itself.

Alex

@golang golang locked and limited conversation to collaborators Jul 11, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants