Commit dddd1dd4 authored by Ian Lance Taylor's avatar Ian Lance Taylor

cmd/go: fix TestExecutableGOROOT on Windows

On Windows the drive letter is sometime "c:" and sometimes "C:".

Fixes #20336.

Change-Id: I38c86999af9522c51470d60016729d41cfec6b25
Reviewed-on: https://go-review.googlesource.com/43390
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 22538477
......@@ -3974,6 +3974,13 @@ func TestExecutableGOROOT(t *testing.T) {
return strings.TrimSpace(string(out))
}
// Filenames are case insensitive on Windows.
// There should probably be a path/filepath function for this.
equal := func(a, b string) bool { return a == b }
if runtime.GOOS == "windows" {
equal = strings.EqualFold
}
// macOS uses a symlink for /tmp.
resolvedTestGOROOT, err := filepath.EvalSymlinks(testGOROOT)
if err != nil {
......@@ -3982,13 +3989,13 @@ func TestExecutableGOROOT(t *testing.T) {
// Missing GOROOT/pkg/tool, the go tool should fall back to
// its default path.
if got, want := goroot(newGoTool), resolvedTestGOROOT; got != want {
if got, want := goroot(newGoTool), resolvedTestGOROOT; !equal(got, want) {
t.Fatalf("%s env GOROOT = %q, want %q", newGoTool, got, want)
}
// Now the executable's path looks like a GOROOT.
tg.tempDir("newgoroot/pkg/tool")
if got, want := goroot(newGoTool), tg.path("newgoroot"); got != want {
if got, want := goroot(newGoTool), tg.path("newgoroot"); !equal(got, want) {
t.Fatalf("%s env GOROOT = %q with pkg/tool, want %q", newGoTool, got, want)
}
......@@ -4003,7 +4010,7 @@ func TestExecutableGOROOT(t *testing.T) {
t.Fatalf("could not eval newgoroot symlinks: %v", err)
}
if got, want := goroot(symGoTool), resolvedNewGOROOT; got != want {
if got, want := goroot(symGoTool), resolvedNewGOROOT; !equal(got, want) {
t.Fatalf("%s env GOROOT = %q, want %q", symGoTool, got, want)
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment