Skip to content

Commit c4a8a68

Browse files
author
Bryan C. Mills
committed
cmd/go: reproduce #28680
This change encodes the current behavior in mod_clean_cache.txt. A fix for that behavior will probably have to wait for 1.13. Updates #28680 Change-Id: I216b5a783971309cc75187502bddccc58c3a9c35 Reviewed-on: https://go-review.googlesource.com/c/153818 Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
1 parent cc8ae42 commit c4a8a68

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,59 @@
11
env GO111MODULE=on
22

3+
# 'mod download' should download the module to the cache.
34
go mod download rsc.io/[email protected]
45
exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.info
56
exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod
67
exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.zip
78

9+
# '-n' should print commands but not actually execute them.
810
go clean -modcache -n
911
stdout '^rm -rf .*pkg.mod$'
1012
exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.info
1113
exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod
1214
exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.zip
1315

16+
# 'go clean -modcache' should actually delete the files.
1417
go clean -modcache
1518
! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.info
1619
! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod
1720
! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.zip
1821

22+
# 'go clean -r -modcache' should clean only the dependencies that are within the
23+
# main module.
24+
# BUG(golang.org/issue/28680): Today, it cleans across module boundaries.
25+
cd r
26+
exists ./test.out
27+
exists ../replaced/test.out
28+
go clean -r -modcache
29+
! exists ./test.out
30+
! exists ../replaced/test.out # BUG: should still exist
31+
32+
# 'go clean -modcache' should not download anything before cleaning.
33+
# BUG(golang.org/issue/28680): Today, it does.
34+
go mod edit -require rsc.io/[email protected]
35+
! go clean -modcache # BUG: should succeed
36+
stderr 'finding rsc.io' # BUG: should not resolve module
37+
go mod edit -droprequire rsc.io/quote
38+
1939
-- go.mod --
2040
module m
21-
2241
-- m.go --
23-
package m
42+
package m
43+
44+
-- r/go.mod --
45+
module example.com/r
46+
require example.com/r/replaced v0.0.0
47+
replace example.com/r/replaced => ../replaced
48+
-- r/r.go --
49+
package r
50+
import _ "example.com/r/replaced"
51+
-- r/test.out --
52+
DELETE ME
53+
54+
-- replaced/go.mod --
55+
module example.com/r/replaced
56+
-- replaced/replaced.go --
57+
package replaced
58+
-- replaced/test.out --
59+
DO NOT DELETE

0 commit comments

Comments
 (0)