Black Lives Matter. Support the Equal Justice Initiative.

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

Documentation: cmd/go/testdata/script

     1  # Download modules and populate go.sum.
     2  go get -d -modcacherw
     3  exists $GOPATH/pkg/mod/rsc.io/quote@v1.5.2/go.mod
     4  
     5  # 'go mod verify' should fail if we delete a file.
     6  go mod verify
     7  rm $GOPATH/pkg/mod/rsc.io/quote@v1.5.2/go.mod
     8  ! go mod verify
     9  
    10  # Create a .partial file to simulate an failure extracting the zip file.
    11  cp empty $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.partial
    12  
    13  # 'go mod verify' should not fail, since the module hasn't been completely
    14  # ingested into the cache.
    15  go mod verify
    16  
    17  # 'go list' should not load packages from the directory.
    18  # NOTE: the message "directory $dir outside available modules" is reported
    19  # for directories not in the main module, active modules in the module cache,
    20  # or local replacements. In this case, the directory is in the right place,
    21  # but it's incomplete, so 'go list' acts as if it's not an active module.
    22  ! go list $GOPATH/pkg/mod/rsc.io/quote@v1.5.2
    23  stderr 'outside available modules'
    24  
    25  # 'go list -m' should not print the directory.
    26  go list -m -f '{{.Dir}}' rsc.io/quote
    27  ! stdout .
    28  
    29  # 'go mod download' should re-extract the module and remove the .partial file.
    30  go mod download -modcacherw rsc.io/quote
    31  ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.partial
    32  exists $GOPATH/pkg/mod/rsc.io/quote@v1.5.2/go.mod
    33  
    34  # 'go list' should succeed.
    35  go list $GOPATH/pkg/mod/rsc.io/quote@v1.5.2
    36  stdout '^rsc.io/quote$'
    37  
    38  # 'go list -m' should print the directory.
    39  go list -m -f '{{.Dir}}' rsc.io/quote
    40  stdout 'pkg[/\\]mod[/\\]rsc.io[/\\]quote@v1.5.2'
    41  
    42  # go mod verify should fail if we delete a file.
    43  go mod verify
    44  rm $GOPATH/pkg/mod/rsc.io/quote@v1.5.2/go.mod
    45  ! go mod verify
    46  
    47  # 'go mod download' should not leave behind a directory or a .partial file
    48  # if there is an error extracting the zip file.
    49  rm $GOPATH/pkg/mod/rsc.io/quote@v1.5.2
    50  cp empty $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip
    51  ! go mod download
    52  stderr 'not a valid zip file'
    53  ! exists $GOPATH/pkg/mod/rsc.io/quote@v1.5.2
    54  ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.partial
    55  
    56  -- go.mod --
    57  module m
    58  
    59  go 1.14
    60  
    61  require rsc.io/quote v1.5.2
    62  
    63  -- use.go --
    64  package use
    65  
    66  import _ "rsc.io/quote"
    67  
    68  -- empty --
    69  

View as plain text