aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/mod_retention.txt
blob: 481c10d2b7d26ae25a47a93733d2f0994c617def (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# Regression test for golang.org/issue/34822: the 'go' command should prefer not
# to update the go.mod file if the changes only affect formatting, and should only
# remove redundant requirements in 'go mod tidy'.

env GO111MODULE=on
[short] skip

# Control case: verify that go.mod.tidy is actually tidy.
cp go.mod.tidy go.mod
go list -mod=mod all
cmp go.mod go.mod.tidy


# If the only difference in the go.mod file is the line endings,
# it should not be overwritten automatically.
cp go.mod.crlf go.mod
go list all
cmp go.mod go.mod.crlf

# However, 'go mod tidy' should fix whitespace even if there are no other changes.
go mod tidy
cmp go.mod go.mod.tidy


# Out-of-order requirements should not be overwritten automatically...
cp go.mod.unsorted go.mod
go list all
cmp go.mod go.mod.unsorted

# ...but 'go mod edit -fmt' should sort them.
go mod edit -fmt
cmp go.mod go.mod.tidy


# "// indirect" comments should be removed if direct dependencies are seen.
# changes.
cp go.mod.indirect go.mod
go list -mod=mod all
cmp go.mod go.mod.tidy

# "// indirect" comments should be added if appropriate.
# TODO(#42504): add case for 'go list -mod=mod -tags=any all' when -tags=any
# is supported. Only a command that loads "all" without build constraints
# (except "ignore") has enough information to add "// indirect" comments.
# 'go mod tidy' and 'go mod vendor' are the only commands that do that,
# but 'go mod vendor' cannot write go.mod.
cp go.mod.toodirect go.mod
go list all
cmp go.mod go.mod.toodirect


# Redundant requirements should be preserved...
cp go.mod.redundant go.mod
go list all
cmp go.mod go.mod.redundant
go mod vendor
cmp go.mod go.mod.redundant
rm -r vendor

# ...except by 'go mod tidy'.
go mod tidy
cmp go.mod go.mod.tidy


# A missing "go" version directive should be added.
# However, that should not remove other redundant requirements.
# In fact, it may *add* redundant requirements due to activating lazy loading.
cp go.mod.nogo go.mod
go list -mod=mod all
cmpenv go.mod go.mod.addedgo


-- go.mod.tidy --
module m

go 1.14

require (
	rsc.io/quote v1.5.2
	rsc.io/testonly v1.0.0 // indirect
)
-- x.go --
package x
import _ "rsc.io/quote"
-- go.mod.crlf --
module m

go 1.14

require (
	rsc.io/quote v1.5.2
	rsc.io/testonly v1.0.0 // indirect
)
-- go.mod.unsorted --
module m

go 1.14

require (
	rsc.io/testonly v1.0.0 // indirect
	rsc.io/quote v1.5.2
)
-- go.mod.indirect --
module m

go 1.14

require (
	rsc.io/quote v1.5.2 // indirect
	rsc.io/testonly v1.0.0 // indirect
)
-- go.mod.toodirect --
module m

go 1.14

require (
	rsc.io/quote v1.5.2
	rsc.io/testonly v1.0.0
)
-- go.mod.redundant --
module m

go 1.14

require (
	rsc.io/quote v1.5.2
	rsc.io/sampler v1.3.0 // indirect
	rsc.io/testonly v1.0.0 // indirect
)
-- go.mod.nogo --
module m

require (
	rsc.io/quote v1.5.2
	rsc.io/sampler v1.3.0 // indirect
	rsc.io/testonly v1.0.0 // indirect
)
-- go.mod.addedgo --
module m

go $goversion

require (
	rsc.io/quote v1.5.2
	rsc.io/sampler v1.3.0 // indirect
	rsc.io/testonly v1.0.0 // indirect
)

require golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c // indirect