|
1 | 1 | env GO111MODULE=on
|
2 | 2 |
|
| 3 | +# 'mod download' should download the module to the cache. |
3 | 4 | go mod download rsc.io/ [email protected]
|
4 | 5 | exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.info
|
5 | 6 | exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod
|
6 | 7 | exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.zip
|
7 | 8 |
|
| 9 | +# '-n' should print commands but not actually execute them. |
8 | 10 | go clean -modcache -n
|
9 | 11 | stdout '^rm -rf .*pkg.mod$'
|
10 | 12 | exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.info
|
11 | 13 | exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod
|
12 | 14 | exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.zip
|
13 | 15 |
|
| 16 | +# 'go clean -modcache' should actually delete the files. |
14 | 17 | go clean -modcache
|
15 | 18 | ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.info
|
16 | 19 | ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod
|
17 | 20 | ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.zip
|
18 | 21 |
|
| 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 | + |
19 | 39 | -- go.mod --
|
20 | 40 | module m
|
21 |
| - |
22 | 41 | -- 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