mirror of
https://github.com/golang/go
synced 2024-09-15 14:10:17 +00:00
cmd/go/internal/clean: fix clean -testcache does not clean test cache
Truncate changes the size of the file. It does not change the I/O offset. Fixes #29757 Change-Id: I1aa9223a86d6a8ce3c0efc3ac1d7d7647b77f589 Reviewed-on: https://go-review.googlesource.com/c/158117 Reviewed-by: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
parent
5fae09b738
commit
34817dd365
|
@ -152,7 +152,9 @@ func runClean(cmd *base.Command, args []string) {
|
|||
prev, _ := strconv.ParseInt(strings.TrimSpace(string(buf)), 10, 64)
|
||||
if now > prev {
|
||||
if err = f.Truncate(0); err == nil {
|
||||
_, err = fmt.Fprintf(f, "%d\n", now)
|
||||
if _, err = f.Seek(0, 0); err == nil {
|
||||
_, err = fmt.Fprintf(f, "%d\n", now)
|
||||
}
|
||||
}
|
||||
}
|
||||
if closeErr := f.Close(); err == nil {
|
||||
|
|
16
src/cmd/go/testdata/script/clean_testcache.txt
vendored
Normal file
16
src/cmd/go/testdata/script/clean_testcache.txt
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
# go clean -testcache
|
||||
# should work (see golang.org/issue/29757).
|
||||
cd x
|
||||
go test x_test.go
|
||||
go clean -testcache
|
||||
go test x_test.go
|
||||
! stdout 'cached'
|
||||
|
||||
|
||||
-- x/x_test.go --
|
||||
package x_test
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
func TestMain(t *testing.T) {
|
||||
}
|
Loading…
Reference in a new issue