Skip to content

Commit a197c7b

Browse files
author
Bryan C. Mills
committed
cmd/go/internal/clean: make 'go clean -testcache' a no-op if the cache directory is gone
Fixes #29100 Change-Id: I195191aad825266ab55d38addef9d662cfc72dff Reviewed-on: https://go-review.googlesource.com/c/go/+/212099 Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
1 parent 5481a97 commit a197c7b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/cmd/go/internal/clean/clean.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ func runClean(cmd *base.Command, args []string) {
178178
}
179179
}
180180
if err != nil {
181-
base.Errorf("go clean -testcache: %v", err)
181+
if _, statErr := os.Stat(dir); !os.IsNotExist(statErr) {
182+
base.Errorf("go clean -testcache: %v", err)
183+
}
182184
}
183185
}
184186
}

src/cmd/go/testdata/script/clean_testcache.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@ go clean -testcache
99
go test x_test.go
1010
! stdout 'cached'
1111

12+
# golang.org/issue/29100: 'go clean -testcache' should succeed
13+
# if the cache directory doesn't exist at all.
14+
# It should not write a testexpire.txt file, since there are no
15+
# test results that need to be invalidated in the first place.
16+
env GOCACHE=$WORK/nonexistent
17+
go clean -testcache
18+
! exists $WORK/nonexistent
1219

1320
-- x/x_test.go --
1421
package x_test
1522
import (
1623
"testing"
1724
)
1825
func TestMain(t *testing.T) {
19-
}
26+
}

0 commit comments

Comments
 (0)