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

     1  # build with no newer version to satisfy exclude
     2  env GO111MODULE=on
     3  cp 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
     9  stderr '^go: ignoring requirement on excluded version rsc.io/sampler v1\.99\.99$'
    10  stderr '^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'
    12  cmp go.mod go.mod.orig
    13  
    14  ! go list -mod=vendor -m rsc.io/sampler
    15  stderr '^go: ignoring requirement on excluded version rsc.io/sampler v1\.99\.99$'
    16  stderr '^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'
    18  cmp go.mod go.mod.orig
    19  
    20  # The failure message should be clear when -mod=vendor is implicit.
    21  
    22  go mod edit -go=1.14
    23  ! go list -m rsc.io/sampler
    24  stderr '^go: ignoring requirement on excluded version rsc.io/sampler v1\.99\.99$'
    25  stderr '^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'
    27  go mod edit -go=1.13
    28  cmp 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  
    34  go list -m -mod=mod all
    35  stderr '^go: dropping requirement on excluded version rsc.io/sampler v1\.99\.99$'
    36  stdout '^x$'
    37  ! stdout '^rsc.io/sampler'
    38  cmp go.mod go.moddrop
    39  
    40  # With the latest version excluded, 'go list' should resolve needed packages
    41  # from the next-highest version.
    42  
    43  cp go.mod.orig go.mod
    44  go list -mod=mod -f '{{with .Module}}{{.Path}} {{.Version}}{{end}}' all
    45  stderr '^go: dropping requirement on excluded version rsc.io/sampler v1\.99\.99$'
    46  stdout '^x $'
    47  ! stdout '^rsc.io/sampler v1.99.99'
    48  stdout '^rsc.io/sampler v1.3.0'
    49  
    50  # build with newer version available
    51  cp go.mod2 go.mod
    52  go list -mod=mod -f '{{with .Module}}{{.Path}} {{.Version}}{{end}}' all
    53  stderr '^go: dropping requirement on excluded version rsc.io/quote v1\.5\.1$'
    54  stdout 'rsc.io/quote v1.5.2'
    55  
    56  # build with excluded newer version
    57  cp go.mod3 go.mod
    58  go list -mod=mod -f '{{with .Module}}{{.Path}} {{.Version}}{{end}}' all
    59  ! stderr '^go: dropping requirement'
    60  stdout 'rsc.io/quote v1.5.1'
    61  
    62  -- x.go --
    63  package x
    64  import _ "rsc.io/quote"
    65  
    66  -- go.mod --
    67  module x
    68  
    69  go 1.13
    70  
    71  exclude rsc.io/sampler v1.99.99
    72  
    73  require rsc.io/sampler v1.99.99
    74  -- vendor/modules.txt --
    75  # rsc.io/sampler v1.99.99
    76  ## explicit
    77  -- go.moddrop --
    78  module x
    79  
    80  go 1.13
    81  
    82  exclude rsc.io/sampler v1.99.99
    83  -- go.mod2 --
    84  module x
    85  
    86  go 1.13
    87  
    88  exclude rsc.io/quote v1.5.1
    89  require rsc.io/quote v1.5.1
    90  -- go.mod3 --
    91  module x
    92  
    93  go 1.13
    94  
    95  exclude rsc.io/quote v1.5.2
    96  require rsc.io/quote v1.5.1
    97  

View as plain text