]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: fix TestExecutableGOROOT on Windows
authorIan Lance Taylor <iant@golang.org>
Fri, 12 May 2017 14:11:53 +0000 (07:11 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 12 May 2017 14:26:32 +0000 (14:26 +0000)
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: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/go/go_test.go

index 041773ba9128097d58606b59b9638ced2ceb9c57..093119e03e5d2ed75ff6e61806cd2431e0b09917 100644 (file)
@@ -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)
        }
 }