]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/clean: make 'go clean -testcache' a no-op if the cache directory...
authorBryan C. Mills <bcmills@google.com>
Thu, 19 Dec 2019 14:33:16 +0000 (09:33 -0500)
committerBryan C. Mills <bcmills@google.com>
Thu, 19 Dec 2019 17:22:29 +0000 (17:22 +0000)
Fixes #29100

Change-Id: I195191aad825266ab55d38addef9d662cfc72dff
Reviewed-on: https://go-review.googlesource.com/c/go/+/212099
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/internal/clean/clean.go
src/cmd/go/testdata/script/clean_testcache.txt

index 5f4bf4e6c8eb022e91f46790b48047b33c8a3bc9..69e17482b44d80274894a173be4233988335290c 100644 (file)
@@ -178,7 +178,9 @@ func runClean(cmd *base.Command, args []string) {
                                }
                        }
                        if err != nil {
-                               base.Errorf("go clean -testcache: %v", err)
+                               if _, statErr := os.Stat(dir); !os.IsNotExist(statErr) {
+                                       base.Errorf("go clean -testcache: %v", err)
+                               }
                        }
                }
        }
index dd7846462e153a98b9c9d0f2c120ec40a0cbfc3a..b3f32fe696af75b6ba36918f8c102dc5465baa05 100644 (file)
@@ -9,6 +9,13 @@ go clean -testcache
 go test x_test.go
 ! stdout 'cached'
 
+# golang.org/issue/29100: 'go clean -testcache' should succeed
+# if the cache directory doesn't exist at all.
+# It should not write a testexpire.txt file, since there are no
+# test results that need to be invalidated in the first place.
+env GOCACHE=$WORK/nonexistent
+go clean -testcache
+! exists $WORK/nonexistent
 
 -- x/x_test.go --
 package x_test
@@ -16,4 +23,4 @@ import (
     "testing"
 )
 func TestMain(t *testing.T) {
-}
\ No newline at end of file
+}