aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/mod_tidy_version.txt
blob: 5441d9cc06fc46c2df0e5ca8c3e441816c146948 (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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# https://golang.org/issue/45094: 'go mod tidy' now accepts a '-go' flag
# to change the language version in use.
#
# The package import graph used in this test looks like:
#
# m --- a --- b
#             |
#             b_test --- c
#                        |
#                        c_test --- d
#
# The module diagram looks like:
#
# m --- a --- b
# |
# + --- c
# |
# + --- d
#
# Module b omits its dependency on c, and module c omits its dependency on d.
#
# In go 1.15, the tidy main module must require a (because it is direct),
# c (because it is a missing test dependency of an imported package),
# and d (because it is a missing transitive test dependency).
#
# In go 1.16, the tidy main module can omit d because it is no longer
# included in "all".
#
# In go 1.17, the main module must explicitly require b
# (because it is transitively imported by the main module).


cp go.mod go.mod.orig

# An invalid argument should be rejected.

! go mod tidy -go=bananas
stderr '^go mod: invalid -go option "bananas"; expecting something like "-go 1.17"$'
cmp go.mod go.mod.orig


go mod tidy -go=1.15
cmp go.mod go.mod.115

go mod tidy
cmp go.mod go.mod.115


go mod tidy -go=1.16
cmp go.mod go.mod.116

go mod tidy
cmp go.mod go.mod.116


go mod tidy -go=1.17
cmp go.mod go.mod.117

go mod tidy
cmp go.mod go.mod.117


# If we downgrade back to 1.15, we should re-resolve d to v0.2.0 instead
# of the original v0.1.0 (because the original requirement is lost).

go mod tidy -go=1.15
cmp go.mod go.mod.115-2


# -go= (with an empty argument) maintains the existing version or adds the
#  default version (just like omitting the flag).

go mod tidy -go=''
cmp go.mod go.mod.115-2

cp go.mod.orig go.mod
go mod tidy -go=''
cmpenv go.mod go.mod.latest



-- go.mod --
module example.com/m

require (
	example.net/a v0.1.0
	example.net/c v0.1.0 // indirect
	example.net/d v0.1.0 // indirect
)

replace (
	example.net/a v0.1.0 => ./a
	example.net/a v0.2.0 => ./a
	example.net/b v0.1.0 => ./b
	example.net/b v0.2.0 => ./b
	example.net/c v0.1.0 => ./c
	example.net/c v0.2.0 => ./c
	example.net/d v0.1.0 => ./d
	example.net/d v0.2.0 => ./d
)
-- m.go --
package m

import _ "example.net/a"

-- go.mod.115 --
module example.com/m

go 1.15

require (
	example.net/a v0.1.0
	example.net/c v0.1.0 // indirect
	example.net/d v0.1.0 // indirect
)

replace (
	example.net/a v0.1.0 => ./a
	example.net/a v0.2.0 => ./a
	example.net/b v0.1.0 => ./b
	example.net/b v0.2.0 => ./b
	example.net/c v0.1.0 => ./c
	example.net/c v0.2.0 => ./c
	example.net/d v0.1.0 => ./d
	example.net/d v0.2.0 => ./d
)
-- go.mod.115-2 --
module example.com/m

go 1.15

require (
	example.net/a v0.1.0
	example.net/c v0.1.0 // indirect
	example.net/d v0.2.0 // indirect
)

replace (
	example.net/a v0.1.0 => ./a
	example.net/a v0.2.0 => ./a
	example.net/b v0.1.0 => ./b
	example.net/b v0.2.0 => ./b
	example.net/c v0.1.0 => ./c
	example.net/c v0.2.0 => ./c
	example.net/d v0.1.0 => ./d
	example.net/d v0.2.0 => ./d
)
-- go.mod.116 --
module example.com/m

go 1.16

require (
	example.net/a v0.1.0
	example.net/c v0.1.0 // indirect
)

replace (
	example.net/a v0.1.0 => ./a
	example.net/a v0.2.0 => ./a
	example.net/b v0.1.0 => ./b
	example.net/b v0.2.0 => ./b
	example.net/c v0.1.0 => ./c
	example.net/c v0.2.0 => ./c
	example.net/d v0.1.0 => ./d
	example.net/d v0.2.0 => ./d
)
-- go.mod.117 --
module example.com/m

go 1.17

require (
	example.net/a v0.1.0
	example.net/b v0.1.0 // indirect
	example.net/c v0.1.0 // indirect
)

replace (
	example.net/a v0.1.0 => ./a
	example.net/a v0.2.0 => ./a
	example.net/b v0.1.0 => ./b
	example.net/b v0.2.0 => ./b
	example.net/c v0.1.0 => ./c
	example.net/c v0.2.0 => ./c
	example.net/d v0.1.0 => ./d
	example.net/d v0.2.0 => ./d
)
-- go.mod.latest --
module example.com/m

go $goversion

require (
	example.net/a v0.1.0
	example.net/b v0.1.0 // indirect
	example.net/c v0.1.0 // indirect
)

replace (
	example.net/a v0.1.0 => ./a
	example.net/a v0.2.0 => ./a
	example.net/b v0.1.0 => ./b
	example.net/b v0.2.0 => ./b
	example.net/c v0.1.0 => ./c
	example.net/c v0.2.0 => ./c
	example.net/d v0.1.0 => ./d
	example.net/d v0.2.0 => ./d
)
-- a/go.mod --
module example.net/a

go 1.15

require example.net/b v0.1.0
-- a/a.go --
package a

import _ "example.net/b"

-- b/go.mod --
module example.net/b

go 1.15
-- b/b.go --
package b
-- b/b_test.go --
package b_test

import _ "example.net/c"

-- c/go.mod --
module example.net/c

go 1.15
-- c/c.go --
package c
-- c/c_test.go --
package c_test

import _ "example.net/d"

-- d/go.mod --
module example.net/d

go 1.15
-- d/d.go --
package d