]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: fix staleness test for releases, also deflake it
authorAndrew Gerrand <adg@golang.org>
Fri, 3 Jun 2016 01:33:37 +0000 (11:33 +1000)
committerAndrew Gerrand <adg@golang.org>
Fri, 3 Jun 2016 02:46:58 +0000 (02:46 +0000)
Fixes #15933

Change-Id: I2cd6365e6d0ca1cafdc812fbfaaa55aa64b2b289
Reviewed-on: https://go-review.googlesource.com/23731
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

index 50e6b500dab3d781877568bbac62d1c81d927b80..1bee5e6609826d17baab5a18bb85dbee0af254c7 100644 (file)
@@ -1332,15 +1332,31 @@ func TestPackageMainTestImportsArchiveNotBinary(t *testing.T) {
        tg.run("test", "main_test")
 }
 
+// The runtime version string takes one of two forms:
+// "go1.X[.Y]" for Go releases, and "devel +hash" at tip.
+// Determine whether we are in a released copy by
+// inspecting the version.
+var isGoRelease = strings.HasPrefix(runtime.Version(), "go1")
+
 // Issue 12690
 func TestPackageNotStaleWithTrailingSlash(t *testing.T) {
        tg := testgo(t)
        defer tg.cleanup()
+
+       // Make sure the packages below are not stale.
+       tg.run("install", "runtime", "os", "io")
+
        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")
+
+       want := ""
+       if isGoRelease {
+               want = "standard package in Go release distribution"
+       }
+
+       tg.wantNotStale("runtime", want, "with trailing slash in GOROOT, runtime listed as stale")
+       tg.wantNotStale("os", want, "with trailing slash in GOROOT, os listed as stale")
+       tg.wantNotStale("io", want, "with trailing slash in GOROOT, io listed as stale")
 }
 
 // With $GOBIN set, binaries get installed to $GOBIN.