]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: clean the directory path containing the packages
authorMohit Agarwal <mohit@sdf.org>
Mon, 9 Nov 2015 19:26:14 +0000 (00:56 +0530)
committerIan Lance Taylor <iant@golang.org>
Mon, 9 Nov 2015 21:13:22 +0000 (21:13 +0000)
The heuristic for determining if the packages or commands are stale
fails as the mtime comparison happens even though the GOROOT and
current package paths are the same, since the path name isn't
canonicalized before the comparison (GOROOT is).

Fixes: #12690
Change-Id: Ia7d142fbbed8aac2bd2f71d1db4efd1f3ff5aece
Reviewed-on: https://go-review.googlesource.com/16483
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/go/go_test.go
src/go/build/build.go

index 43660d75ccdce3849761ff8b7d485f5f39f958bf..b07b7460548ab8ca9364a27db577406bc23125b4 100644 (file)
@@ -1191,6 +1191,17 @@ func TestPackageMainTestImportsArchiveNotBinary(t *testing.T) {
        tg.run("test", "main_test")
 }
 
+// Issue 12690
+func TestPackageNotStaleWithTrailingSlash(t *testing.T) {
+       tg := testgo(t)
+       defer tg.cleanup()
+       goroot := runtime.GOROOT()
+       tg.setenv("GOROOT", goroot+"/")
+       tg.wantNotStale("runtime", "with trailing slash in GOROOT, runtime listed as stale")
+       tg.wantNotStale("os", "with trailing slash in GOROOT, os listed as stale")
+       tg.wantNotStale("io", "with trailing slash in GOROOT, io listed as stale")
+}
+
 // With $GOBIN set, binaries get installed to $GOBIN.
 func TestInstallIntoGOBIN(t *testing.T) {
        tg := testgo(t)
index ce90f597fd1fcd2e4c1a70f339f5417ad7583dca..14a03fc0d4a91573c10d0d4398c5b08ae2fca848 100644 (file)
@@ -289,7 +289,7 @@ func defaultContext() Context {
 
        c.GOARCH = envOr("GOARCH", runtime.GOARCH)
        c.GOOS = envOr("GOOS", runtime.GOOS)
-       c.GOROOT = runtime.GOROOT()
+       c.GOROOT = pathpkg.Clean(runtime.GOROOT())
        c.GOPATH = envOr("GOPATH", "")
        c.Compiler = runtime.Compiler