...

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

Documentation: cmd/go/testdata/script

     1# build with no newer version to satisfy exclude
     2env GO111MODULE=on
     3cp go.mod go.mod.orig
     4
     5# With the selected version excluded, commands that query that version without
     6# updating go.mod should fail.
     7
     8! go list -mod=readonly -m all
     9stderr '^go: ignoring requirement on excluded version rsc.io/sampler v1\.99\.99$'
    10stderr '^go: updates to go.mod needed, disabled by -mod=readonly; to update it:\n\tgo mod tidy$'
    11! stdout '^rsc.io/sampler v1.99.99'
    12cmp go.mod go.mod.orig
    13
    14! go list -mod=vendor -m rsc.io/sampler
    15stderr '^go: ignoring requirement on excluded version rsc.io/sampler v1\.99\.99$'
    16stderr '^go: updates to go.mod needed, disabled by -mod=vendor; to update it:\n\tgo mod tidy$'
    17! stdout '^rsc.io/sampler v1.99.99'
    18cmp go.mod go.mod.orig
    19
    20# The failure message should be clear when -mod=vendor is implicit.
    21
    22go mod edit -go=1.14
    23! go list -m rsc.io/sampler
    24stderr '^go: ignoring requirement on excluded version rsc.io/sampler v1\.99\.99$'
    25stderr '^go: updates to go.mod needed, disabled by -mod=vendor\n\t\(Go version in go.mod is at least 1.14 and vendor directory exists\.\)\n\tto update it:\n\tgo mod tidy$'
    26! stdout '^rsc.io/sampler v1.99.99'
    27go mod edit -go=1.13
    28cmp go.mod go.mod.orig
    29
    30
    31# With the selected version excluded, commands that load only modules should
    32# drop the excluded module.
    33
    34go list -m -mod=mod all
    35stderr '^go: dropping requirement on excluded version rsc.io/sampler v1\.99\.99$'
    36stdout '^x$'
    37! stdout '^rsc.io/sampler'
    38cmp go.mod go.moddrop
    39
    40# With the latest version excluded, 'go list' should resolve needed packages
    41# from the next-highest version.
    42
    43cp go.mod.orig go.mod
    44go list -mod=mod -f '{{with .Module}}{{.Path}} {{.Version}}{{end}}' all
    45stderr '^go: dropping requirement on excluded version rsc.io/sampler v1\.99\.99$'
    46stdout '^x $'
    47! stdout '^rsc.io/sampler v1.99.99'
    48stdout '^rsc.io/sampler v1.3.0'
    49
    50# build with newer version available
    51cp go.mod2 go.mod
    52go list -mod=mod -f '{{with .Module}}{{.Path}} {{.Version}}{{end}}' all
    53stderr '^go: dropping requirement on excluded version rsc.io/quote v1\.5\.1$'
    54stdout 'rsc.io/quote v1.5.2'
    55
    56# build with excluded newer version
    57cp go.mod3 go.mod
    58go list -mod=mod -f '{{with .Module}}{{.Path}} {{.Version}}{{end}}' all
    59! stderr '^go: dropping requirement'
    60stdout 'rsc.io/quote v1.5.1'
    61
    62-- x.go --
    63package x
    64import _ "rsc.io/quote"
    65
    66-- go.mod --
    67module x
    68
    69go 1.13
    70
    71exclude rsc.io/sampler v1.99.99
    72
    73require rsc.io/sampler v1.99.99
    74-- vendor/modules.txt --
    75# rsc.io/sampler v1.99.99
    76## explicit
    77-- go.moddrop --
    78module x
    79
    80go 1.13
    81
    82exclude rsc.io/sampler v1.99.99
    83-- go.mod2 --
    84module x
    85
    86go 1.13
    87
    88exclude rsc.io/quote v1.5.1
    89require rsc.io/quote v1.5.1
    90-- go.mod3 --
    91module x
    92
    93go 1.13
    94
    95exclude rsc.io/quote v1.5.2
    96require rsc.io/quote v1.5.1

View as plain text