1 env TESTGO_VERSION=go1.21
2 env TESTGO_VERSION_SWITCH=switch
3
4 # GOTOOLCHAIN=auto should run the newer toolchain
5 env GOTOOLCHAIN=auto
6 cp go.mod.new go.mod
7 go get rsc.io/needgo121 rsc.io/needgo122 rsc.io/needgo123 rsc.io/needall
8 stderr '^go: rsc.io/needall@v0.0.1 requires go >= 1.23; switching to go1.23.9$'
9 ! stderr '\(running'
10 stderr '^go: added rsc.io/needall v0.0.1'
11 grep 'go 1.23' go.mod
12 grep 'toolchain go1.23.9' go.mod
13
14 # GOTOOLCHAIN=min+auto should run the newer toolchain
15 env GOTOOLCHAIN=go1.21+auto
16 cp go.mod.new go.mod
17 go get rsc.io/needgo121 rsc.io/needgo122 rsc.io/needgo123 rsc.io/needall
18 stderr '^go: rsc.io/needall@v0.0.1 requires go >= 1.23; switching to go1.23.9$'
19 ! stderr '\(running'
20 stderr '^go: added rsc.io/needall v0.0.1'
21 grep 'go 1.23' go.mod
22 grep 'toolchain go1.23.9' go.mod
23
24 # GOTOOLCHAIN=go1.21 should NOT run the newer toolchain
25 env GOTOOLCHAIN=go1.21
26 cp go.mod.new go.mod
27 ! go get rsc.io/needgo121 rsc.io/needgo122 rsc.io/needgo123 rsc.io/needall
28 ! stderr switching
29 stderr 'rsc.io/needgo122@v0.0.1 requires go >= 1.22'
30 stderr 'rsc.io/needgo123@v0.0.1 requires go >= 1.23'
31 stderr 'rsc.io/needall@v0.0.1 requires go >= 1.23'
32 stderr 'requires go >= 1.23'
33 ! stderr 'requires go >= 1.21' # that's us!
34 cmp go.mod go.mod.new
35
36 # GOTOOLCHAIN=local should NOT run the newer toolchain
37 env GOTOOLCHAIN=local
38 cp go.mod.new go.mod
39 ! go get rsc.io/needgo121 rsc.io/needgo122 rsc.io/needgo123 rsc.io/needall
40 ! stderr switching
41 stderr 'rsc.io/needgo122@v0.0.1 requires go >= 1.22'
42 stderr 'rsc.io/needgo123@v0.0.1 requires go >= 1.23'
43 stderr 'rsc.io/needall@v0.0.1 requires go >= 1.23'
44 stderr 'requires go >= 1.23'
45 ! stderr 'requires go >= 1.21' # that's us!
46 cmp go.mod go.mod.new
47
48 # go get go@1.22 should resolve to the latest 1.22
49 env GOTOOLCHAIN=local
50 cp go.mod.new go.mod
51 ! go get go@1.22
52 stderr '^go: updating go.mod requires go >= 1.22.9 \(running go 1.21; GOTOOLCHAIN=local\)'
53
54 env GOTOOLCHAIN=auto
55 cp go.mod.new go.mod
56 go get go@1.22
57 stderr '^go: updating go.mod requires go >= 1.22.9; switching to go1.22.9$'
58
59 # go get go@1.22rc1 should use 1.22rc1 exactly, not a later release.
60 env GOTOOLCHAIN=local
61 cp go.mod.new go.mod
62 ! go get go@1.22rc1
63 stderr '^go: updating go.mod requires go >= 1.22rc1 \(running go 1.21; GOTOOLCHAIN=local\)'
64
65 env GOTOOLCHAIN=auto
66 cp go.mod.new go.mod
67 go get go@1.22rc1
68 stderr '^go: updating go.mod requires go >= 1.22rc1; switching to go1.22.9$'
69 stderr '^go: upgraded go 1.1 => 1.22rc1$'
70 stderr '^go: added toolchain go1.22.9$'
71
72 # go get go@1.22.1 should use 1.22.1 exactly, not a later release.
73 env GOTOOLCHAIN=local
74 cp go.mod.new go.mod
75 ! go get go@1.22.1
76 stderr '^go: updating go.mod requires go >= 1.22.1 \(running go 1.21; GOTOOLCHAIN=local\)'
77
78 env GOTOOLCHAIN=auto
79 cp go.mod.new go.mod
80 go get go@1.22.1
81 stderr '^go: updating go.mod requires go >= 1.22.1; switching to go1.22.9$'
82 stderr '^go: upgraded go 1.1 => 1.22.1$'
83 stderr '^go: added toolchain go1.22.9$'
84
85 # go get needgo122 (says 'go 1.22') should use 1.22.0, the earliest release we have available
86 # (ignoring prereleases).
87 env GOTOOLCHAIN=local
88 cp go.mod.new go.mod
89 ! go get rsc.io/needgo122
90 stderr '^go: rsc.io/needgo122@v0.0.1 requires go >= 1.22 \(running go 1.21; GOTOOLCHAIN=local\)'
91
92 env GOTOOLCHAIN=auto
93 cp go.mod.new go.mod
94 go get rsc.io/needgo122
95 stderr '^go: upgraded go 1.1 => 1.22$'
96 stderr '^go: rsc.io/needgo122@v0.0.1 requires go >= 1.22; switching to go1.22.9$'
97 stderr '^go: added toolchain go1.22.9$'
98
99 # go get needgo1223 (says 'go 1.22.3') should use go 1.22.3
100 env GOTOOLCHAIN=local
101 cp go.mod.new go.mod
102 ! go get rsc.io/needgo1223
103 stderr '^go: rsc.io/needgo1223@v0.0.1 requires go >= 1.22.3 \(running go 1.21; GOTOOLCHAIN=local\)'
104
105 env GOTOOLCHAIN=auto
106 cp go.mod.new go.mod
107 go get rsc.io/needgo1223
108 stderr '^go: upgraded go 1.1 => 1.22.3$'
109 stderr '^go: rsc.io/needgo1223@v0.0.1 requires go >= 1.22.3; switching to go1.22.9$'
110 stderr '^go: added toolchain go1.22.9$'
111
112 # go get needgo124 (says 'go 1.24') should use go 1.24rc1, the only version available
113 env GOTOOLCHAIN=local
114 cp go.mod.new go.mod
115 ! go get rsc.io/needgo124
116 stderr '^go: rsc.io/needgo124@v0.0.1 requires go >= 1.24 \(running go 1.21; GOTOOLCHAIN=local\)'
117
118 env GOTOOLCHAIN=auto
119 cp go.mod.new go.mod
120 go get rsc.io/needgo124
121 stderr '^go: rsc.io/needgo124@v0.0.1 requires go >= 1.24; switching to go1.24rc1$'
122 stderr '^go: upgraded go 1.1 => 1.24$'
123 stderr '^go: added toolchain go1.24rc1$'
124
125 # The -C flag should not happen more than once due to switching.
126 mkdir dir dir/dir
127 cp go.mod.new go.mod
128 cp go.mod.new dir/go.mod
129 cp go.mod.new dir/dir/go.mod
130 cp p.go dir/p.go
131 cp p.go dir/dir/p.go
132 go get -C dir rsc.io/needgo124
133 stderr '^go: rsc.io/needgo124@v0.0.1 requires go >= 1.24; switching to go1.24rc1$'
134 stderr '^go: upgraded go 1.1 => 1.24$'
135 stderr '^go: added toolchain go1.24rc1$'
136 cmp go.mod.new go.mod
137 cmp go.mod.new dir/dir/go.mod
138 grep 'go 1.24$' dir/go.mod
139
140 -- go.mod.new --
141 module m
142 go 1.1
143
144 -- p.go --
145 package p
146
View as plain text