github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/testdata/script/mod_retention.txt (about)

     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 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 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  cp go.mod.nogo go.mod
    66  go list all
    67  cmp go.mod go.mod.redundant
    68  
    69  
    70  -- go.mod.tidy --
    71  module m
    72  
    73  go 1.14
    74  
    75  require (
    76  	rsc.io/quote v1.5.2
    77  	rsc.io/testonly v1.0.0 // indirect
    78  )
    79  -- x.go --
    80  package x
    81  import _ "rsc.io/quote"
    82  -- go.mod.crlf --
    83  module m
    84  
    85  go 1.14
    86  
    87  require (
    88  	rsc.io/quote v1.5.2
    89  	rsc.io/testonly v1.0.0 // indirect
    90  )
    91  -- go.mod.unsorted --
    92  module m
    93  
    94  go 1.14
    95  
    96  require (
    97  	rsc.io/testonly v1.0.0 // indirect
    98  	rsc.io/quote v1.5.2
    99  )
   100  -- go.mod.indirect --
   101  module m
   102  
   103  go 1.14
   104  
   105  require (
   106  	rsc.io/quote v1.5.2 // indirect
   107  	rsc.io/testonly v1.0.0 // indirect
   108  )
   109  -- go.mod.toodirect --
   110  module m
   111  
   112  go 1.14
   113  
   114  require (
   115  	rsc.io/quote v1.5.2
   116  	rsc.io/testonly v1.0.0
   117  )
   118  -- go.mod.redundant --
   119  module m
   120  
   121  go 1.14
   122  
   123  require (
   124  	rsc.io/quote v1.5.2
   125  	rsc.io/sampler v1.3.0 // indirect
   126  	rsc.io/testonly v1.0.0 // indirect
   127  )
   128  -- go.mod.nogo --
   129  module m
   130  
   131  require (
   132  	rsc.io/quote v1.5.2
   133  	rsc.io/sampler v1.3.0 // indirect
   134  	rsc.io/testonly v1.0.0 // indirect
   135  )