Black Lives Matter. Support the Equal Justice Initiative.

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

Documentation: cmd/go/testdata/script

     1  # Regression test for golang.org/issue/34822: the 'go' command should prefer not
     2  # to update the go.mod file if the changes only affect formatting, and should only
     3  # remove redundant requirements in 'go mod tidy'.
     4  
     5  env GO111MODULE=on
     6  [short] skip
     7  
     8  # Control case: verify that go.mod.tidy is actually tidy.
     9  cp go.mod.tidy go.mod
    10  go list -mod=mod all
    11  cmp go.mod go.mod.tidy
    12  
    13  
    14  # If the only difference in the go.mod file is the line endings,
    15  # it should not be overwritten automatically.
    16  cp go.mod.crlf go.mod
    17  go list all
    18  cmp go.mod go.mod.crlf
    19  
    20  # However, 'go mod tidy' should fix whitespace even if there are no other changes.
    21  go mod tidy
    22  cmp go.mod go.mod.tidy
    23  
    24  
    25  # Out-of-order requirements should not be overwritten automatically...
    26  cp go.mod.unsorted go.mod
    27  go list all
    28  cmp go.mod go.mod.unsorted
    29  
    30  # ...but 'go mod edit -fmt' should sort them.
    31  go mod edit -fmt
    32  cmp go.mod go.mod.tidy
    33  
    34  
    35  # "// indirect" comments should be removed if direct dependencies are seen.
    36  # changes.
    37  cp go.mod.indirect go.mod
    38  go list -mod=mod all
    39  cmp go.mod go.mod.tidy
    40  
    41  # "// indirect" comments should be added if appropriate.
    42  cp go.mod.toodirect go.mod
    43  go list all
    44  cmp go.mod go.mod.toodirect
    45  go mod vendor # loads everything, so adds "// indirect" comments.
    46  cmp go.mod go.mod.tidy
    47  rm -r vendor
    48  
    49  
    50  # Redundant requirements should be preserved...
    51  cp go.mod.redundant go.mod
    52  go list all
    53  cmp go.mod go.mod.redundant
    54  go mod vendor
    55  cmp go.mod go.mod.redundant
    56  rm -r vendor
    57  
    58  # ...except by 'go mod tidy'.
    59  go mod tidy
    60  cmp go.mod go.mod.tidy
    61  
    62  
    63  # A missing "go" version directive should be added.
    64  # However, that should not remove other redundant requirements.
    65  # In fact, it may *add* redundant requirements due to activating lazy loading.
    66  cp go.mod.nogo go.mod
    67  go list -mod=mod all
    68  cmpenv go.mod go.mod.addedgo
    69  
    70  
    71  -- go.mod.tidy --
    72  module m
    73  
    74  go 1.14
    75  
    76  require (
    77  	rsc.io/quote v1.5.2
    78  	rsc.io/testonly v1.0.0 // indirect
    79  )
    80  -- x.go --
    81  package x
    82  import _ "rsc.io/quote"
    83  -- go.mod.crlf --
    84  module m
    85  
    86  go 1.14
    87  
    88  require (
    89  	rsc.io/quote v1.5.2
    90  	rsc.io/testonly v1.0.0 // indirect
    91  )
    92  -- go.mod.unsorted --
    93  module m
    94  
    95  go 1.14
    96  
    97  require (
    98  	rsc.io/testonly v1.0.0 // indirect
    99  	rsc.io/quote v1.5.2
   100  )
   101  -- go.mod.indirect --
   102  module m
   103  
   104  go 1.14
   105  
   106  require (
   107  	rsc.io/quote v1.5.2 // indirect
   108  	rsc.io/testonly v1.0.0 // indirect
   109  )
   110  -- go.mod.toodirect --
   111  module m
   112  
   113  go 1.14
   114  
   115  require (
   116  	rsc.io/quote v1.5.2
   117  	rsc.io/testonly v1.0.0
   118  )
   119  -- go.mod.redundant --
   120  module m
   121  
   122  go 1.14
   123  
   124  require (
   125  	rsc.io/quote v1.5.2
   126  	rsc.io/sampler v1.3.0 // indirect
   127  	rsc.io/testonly v1.0.0 // indirect
   128  )
   129  -- go.mod.nogo --
   130  module m
   131  
   132  require (
   133  	rsc.io/quote v1.5.2
   134  	rsc.io/sampler v1.3.0 // indirect
   135  	rsc.io/testonly v1.0.0 // indirect
   136  )
   137  -- go.mod.addedgo --
   138  module m
   139  
   140  go $goversion
   141  
   142  require (
   143  	rsc.io/quote v1.5.2
   144  	rsc.io/sampler v1.3.0 // indirect
   145  	rsc.io/testonly v1.0.0 // indirect
   146  )
   147  
   148  require golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c // indirect
   149  

View as plain text