aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-12-17 02:07:56 -0500
committerRuss Cox <rsc@golang.org>2015-12-17 17:06:15 +0000
commit06b46c0d9c6d7c11f949c650149f1c4859e4ef49 (patch)
tree75e9f6205792aaa6e70fd5aaaaddb41207aac389
parente357eb97a695d62c3102973f7384a15cb664b519 (diff)
downloadgo-06b46c0d9c6d7c11f949c650149f1c4859e4ef49.tar.gz
go-06b46c0d9c6d7c11f949c650149f1c4859e4ef49.zip
cmd/go: don't be clever about mtime precision in test
This doesn't happen enough in the tests to be worth debugging. Empirically, I expect this to add 5 seconds to the overall 'go test -short cmd/go' on systems with precise file systems, and nothing on systems without them (like my Mac). Fixes #12205. Change-Id: I0a17cb37bdedcfc0f921c5ee658737f1698c153b Reviewed-on: https://go-review.googlesource.com/17953 Reviewed-by: Ian Lance Taylor <iant@golang.org>
-rw-r--r--src/cmd/go/go_test.go23
1 files changed, 3 insertions, 20 deletions
diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go
index 49fdd53230..20d3d4052f 100644
--- a/src/cmd/go/go_test.go
+++ b/src/cmd/go/go_test.go
@@ -89,8 +89,6 @@ func TestMain(m *testing.M) {
case "linux", "darwin", "freebsd", "windows":
canRace = canCgo && runtime.GOARCH == "amd64"
}
-
- measureTick("./testgo" + exeSuffix)
}
// Don't let these environment variables confuse the test.
@@ -109,24 +107,8 @@ func TestMain(m *testing.M) {
// The length of an mtime tick on this system. This is an estimate of
// how long we need to sleep to ensure that the mtime of two files is
// different.
-var mtimeTick time.Duration
-
-// measureTick sets mtimeTick by looking at the rounding of the mtime
-// of a file.
-func measureTick(path string) {
- st, err := os.Stat(path)
- if err != nil {
- // Default to one second, the most conservative value.
- mtimeTick = time.Second
- return
- }
- mtime := st.ModTime()
- t := time.Microsecond
- for mtime.Round(t).Equal(mtime) && t < time.Second {
- t *= 10
- }
- mtimeTick = t
-}
+// We used to try to be clever but that didn't always work (see golang.org/issue/12205).
+var mtimeTick time.Duration = 1 * time.Second
// Manage a single run of the testgo binary.
type testgoData struct {
@@ -1189,6 +1171,7 @@ func TestBuildOutputToDevNull(t *testing.T) {
func TestPackageMainTestImportsArchiveNotBinary(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
+ tg.parallel()
gobin := filepath.Join(tg.pwd(), "testdata", "bin")
tg.creatingTemp(gobin)
tg.setenv("GOBIN", gobin)