Black Lives Matter. Support the Equal Justice Initiative.

Text file src/cmd/go/testdata/script/mod_clean_cache.txt

Documentation: cmd/go/testdata/script

     1  env GO111MODULE=on
     2  
     3  # 'mod download' should download the module to the cache.
     4  go mod download rsc.io/quote@v1.5.0
     5  exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.info
     6  exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod
     7  exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.zip
     8  
     9  # '-n' should print commands but not actually execute them.
    10  go clean -modcache -n
    11  stdout '^rm -rf .*pkg.mod$'
    12  exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.info
    13  exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod
    14  exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.zip
    15  
    16  # 'go clean -modcache' should actually delete the files.
    17  go clean -modcache
    18  ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.info
    19  ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod
    20  ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.zip
    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  go mod edit -require rsc.io/quote@v1.99999999.0-not-a-real-version
    34  go clean -modcache
    35  ! stderr 'finding rsc.io'
    36  go mod edit -droprequire rsc.io/quote
    37  
    38  -- go.mod --
    39  module m
    40  -- m.go --
    41  package m
    42  
    43  -- r/go.mod --
    44  module example.com/r
    45  require example.com/r/replaced v0.0.0
    46  replace example.com/r/replaced => ../replaced
    47  -- r/r.go --
    48  package r
    49  import _ "example.com/r/replaced"
    50  -- r/test.out --
    51  DELETE ME
    52  
    53  -- replaced/go.mod --
    54  module example.com/r/replaced
    55  -- replaced/replaced.go --
    56  package replaced
    57  -- replaced/test.out --
    58  DO NOT DELETE
    59  

View as plain text