]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: fix TestExecutableGOROOT if GOROOT is a symlink
authorIan Lance Taylor <iant@golang.org>
Mon, 15 May 2017 23:54:38 +0000 (16:54 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 17 May 2017 01:22:12 +0000 (01:22 +0000)
Fixes #20365.

Change-Id: If1a4866193cff3bc836d8bbf18b6a1f5deb9808d
Reviewed-on: https://go-review.googlesource.com/43550
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
src/cmd/go/go_test.go

index 093119e03e5d2ed75ff6e61806cd2431e0b09917..d09b190781c5bf3ebd5a4984810165ff4c6f031b 100644 (file)
@@ -3969,9 +3969,13 @@ func TestExecutableGOROOT(t *testing.T) {
                out, err := cmd.CombinedOutput()
                if err != nil {
                        t.Fatalf("copied go tool failed %v: %s", err, out)
-                       return ""
                }
-               return strings.TrimSpace(string(out))
+               root := strings.TrimSpace(string(out))
+               resolved, err := filepath.EvalSymlinks(root)
+               if err != nil {
+                       t.Fatalf("EvalSymlinks(%q) failed: %v", root, err)
+               }
+               return resolved
        }
 
        // Filenames are case insensitive on Windows.
@@ -3995,7 +3999,11 @@ func TestExecutableGOROOT(t *testing.T) {
 
        // Now the executable's path looks like a GOROOT.
        tg.tempDir("newgoroot/pkg/tool")
-       if got, want := goroot(newGoTool), tg.path("newgoroot"); !equal(got, want) {
+       resolvedNewGOROOT, err := filepath.EvalSymlinks(tg.path("newgoroot"))
+       if err != nil {
+               t.Fatalf("could not eval newgoroot symlinks: %v", err)
+       }
+       if got, want := goroot(newGoTool), resolvedNewGOROOT; !equal(got, want) {
                t.Fatalf("%s env GOROOT = %q with pkg/tool, want %q", newGoTool, got, want)
        }
 
@@ -4005,11 +4013,6 @@ func TestExecutableGOROOT(t *testing.T) {
        symGoTool := tg.path("notgoroot/bin/go" + exeSuffix)
        tg.must(os.Symlink(newGoTool, symGoTool))
 
-       resolvedNewGOROOT, err := filepath.EvalSymlinks(tg.path("newgoroot"))
-       if err != nil {
-               t.Fatalf("could not eval newgoroot symlinks: %v", err)
-       }
-
        if got, want := goroot(symGoTool), resolvedNewGOROOT; !equal(got, want) {
                t.Fatalf("%s env GOROOT = %q, want %q", symGoTool, got, want)
        }