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

     1  # https://golang.org/issue/46141: 'go mod tidy' for a Go 1.17 module should by
     2  # default preserve enough checksums for the module to be used by Go 1.16.
     3  #
     4  # We don't have a copy of Go 1.16 handy, but we can simulate it by editing the
     5  # 'go' version in the go.mod file to 1.16, without actually updating the
     6  # requirements to match.
     7  
     8  [short] skip
     9  
    10  env MODFMT='{{with .Module}}{{.Path}} {{.Version}}{{end}}'
    11  
    12  
    13  # For this module, Go 1.17 produces an error for one module, and Go 1.16
    14  # produces a different error for a different module.
    15  
    16  cp go.mod go.mod.orig
    17  
    18  ! go mod tidy
    19  
    20  stderr '^example\.com/m imports\n\texample\.net/added: module example\.net/added@latest found \(v0\.3\.0, replaced by \./a1\), but does not contain package example\.net/added$'
    21  
    22  cmp go.mod go.mod.orig
    23  
    24  
    25  # When we run 'go mod tidy -e', we should proceed past the first error and follow
    26  # it with a second error describing the version descrepancy.
    27  #
    28  # We should not provide advice on how to push past the version descrepancy,
    29  # because the '-e' flag should already do that, writing out an otherwise-tidied
    30  # go.mod file.
    31  
    32  go mod tidy -e
    33  
    34  stderr '^example\.com/m imports\n\texample\.net/added: module example\.net/added@latest found \(v0\.3\.0, replaced by \./a1\), but does not contain package example\.net/added\nexample\.net/added failed to load from any module,\n\tbut go 1\.16 would load it from example\.net/added@v0\.2\.0$'
    35  
    36  ! stderr '\n\tgo mod tidy'
    37  
    38  cmp go.mod go.mod.tidy
    39  
    40  
    41  -- go.mod --
    42  module example.com/m
    43  
    44  go 1.17
    45  
    46  replace (
    47  	example.net/added v0.1.0 => ./a1
    48  	example.net/added v0.2.0 => ./a2
    49  	example.net/added v0.3.0 => ./a1
    50  	example.net/lazy v0.1.0 => ./lazy
    51  	example.net/pruned v0.1.0 => ./pruned
    52  )
    53  
    54  require (
    55  	example.net/added v0.1.0
    56  	example.net/lazy v0.1.0
    57  )
    58  -- go.mod.tidy --
    59  module example.com/m
    60  
    61  go 1.17
    62  
    63  replace (
    64  	example.net/added v0.1.0 => ./a1
    65  	example.net/added v0.2.0 => ./a2
    66  	example.net/added v0.3.0 => ./a1
    67  	example.net/lazy v0.1.0 => ./lazy
    68  	example.net/pruned v0.1.0 => ./pruned
    69  )
    70  
    71  require example.net/lazy v0.1.0
    72  -- m.go --
    73  package m
    74  
    75  import (
    76  	_ "example.net/added"
    77  	_ "example.net/lazy"
    78  )
    79  
    80  -- a1/go.mod --
    81  module example.net/added
    82  
    83  go 1.17
    84  -- a2/go.mod --
    85  module example.net/added
    86  
    87  go 1.17
    88  -- a2/added.go --
    89  package added
    90  
    91  -- lazy/go.mod --
    92  module example.net/lazy
    93  
    94  go 1.17
    95  
    96  require example.net/pruned v0.1.0
    97  -- lazy/lazy.go --
    98  package lazy
    99  
   100  -- pruned/go.mod --
   101  module example.net/pruned
   102  
   103  go 1.17
   104  
   105  require example.net/added v0.2.0
   106  

View as plain text