...

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

Documentation: cmd/go/testdata/script

     1# Test that go.sum does not get updated when -mod=readonly flag is set
     2env GO111MODULE=on
     3
     4# When a sum is needed to load the build list, we get an error for the
     5# specific module. The .mod file is not downloaded, and go.sum is not written.
     6! go list -m all
     7stderr '^go: rsc.io/quote@v1.5.2: missing go.sum entry for go.mod file; to add it:\n\tgo mod download rsc.io/quote$'
     8! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod
     9! exists go.sum
    10
    11# If go.sum exists but contains hashes from an algorithm we don't know about,
    12# we should see the same error.
    13cp go.sum.h2only go.sum
    14! go list -m all
    15stderr '^go: rsc.io/quote@v1.5.2: missing go.sum entry for go.mod file; to add it:\n\tgo mod download rsc.io/quote$'
    16! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod
    17cmp go.sum go.sum.h2only
    18rm go.sum
    19
    20# If we replace a module, we should see a missing sum error for the replacement.
    21cp go.mod go.mod.orig
    22go mod edit -replace rsc.io/quote@v1.5.2=rsc.io/quote@v1.5.1
    23! go list -m all
    24stderr '^go: rsc.io/quote@v1.5.2 \(replaced by rsc.io/quote@v1.5.1\): missing go.sum entry for go.mod file; to add it:\n\tgo mod download rsc.io/quote$'
    25! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.1.mod
    26! exists go.sum
    27cp go.mod.orig go.mod
    28
    29# Control: when sums are present, loading the build list downloads .mod files.
    30cp go.sum.buildlistonly go.sum
    31go list -m all
    32exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod
    33
    34
    35# When a sum is needed to load a .mod file for a package outside the build list,
    36# we get a generic missing import error.
    37! go list example.com/doesnotexist
    38stderr '^no required module provides package example.com/doesnotexist; to add it:\n\tgo get example.com/doesnotexist$'
    39
    40# When a sum is needed to load a .zip file, we get a more specific error.
    41# The .zip file is not downloaded.
    42! go list rsc.io/quote
    43stderr '^missing go.sum entry for module providing package rsc.io/quote; to add:\n\tgo mod download rsc.io/quote$'
    44! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip
    45
    46# The error is attached to the package from the missing module. We can load
    47# a package that imports it without that error.
    48go list -e -deps -f '{{.ImportPath}}{{with .Error}} {{.Err}}{{end}}' .
    49stdout '^m$'
    50stdout '^rsc.io/quote missing go.sum entry for module providing package rsc.io/quote \(imported by m\); to add:\n\tgo get m$'
    51! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip
    52
    53# go.sum should not have been written.
    54cmp go.sum go.sum.buildlistonly
    55
    56# Control: when sums are present, 'go list' downloads .zip files.
    57cp go.sum.tidy go.sum
    58go list .
    59exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip
    60
    61-- go.mod --
    62module m
    63
    64go 1.15
    65
    66require rsc.io/quote v1.5.2
    67-- use.go --
    68package use
    69
    70import _ "rsc.io/quote"
    71-- go.sum.h2only --
    72golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h2:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
    73rsc.io/quote v1.5.2/go.mod h2:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0=
    74rsc.io/sampler v1.3.0/go.mod h2:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
    75-- go.sum.buildlistonly --
    76golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
    77rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0=
    78rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
    79-- go.sum.tidy --
    80golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:pvCbr/wm8HzDD3fVywevekufpn6tCGPY3spdHeZJEsw=
    81golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
    82rsc.io/quote v1.5.2 h1:3fEykkD9k7lYzXqCYrwGAf7iNhbk4yCjHmKBN9td4L0=
    83rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0=
    84rsc.io/sampler v1.3.0 h1:HLGR/BgEtI3r0uymSP/nl2uPLsUnNJX8toRyhfpBTII=
    85rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
    86rsc.io/testonly v1.0.0 h1:K/VWHdO+Jv7woUXG0GzVNx1czBXUt3Ib1deaMn+xk64=
    87rsc.io/testonly v1.0.0/go.mod h1:OqmGbIFOcF+XrFReLOGZ6BhMM7uMBiQwZsyNmh74SzY=

View as plain text