| 1 |
# This test verifies that 'go get' and 'go mod tidy' switch to a newer toolchain |
| 2 |
# if needed to process newly-resolved imports. |
| 3 |
|
| 4 |
env TESTGO_VERSION=go1.21.0 |
| 5 |
env TESTGO_VERSION_SWITCH=switch |
| 6 |
|
| 7 |
cp go.mod go.mod.orig |
| 8 |
|
| 9 |
# tidy reports needing 1.22.0 for b1 |
| 10 |
env GOTOOLCHAIN=local |
| 11 |
! go mod tidy |
| 12 |
stderr '^go: example imports\n\texample.net/b: module ./b1 requires go >= 1.22.0 \(running go 1.21.0; GOTOOLCHAIN=local\)$' |
| 13 |
env GOTOOLCHAIN=auto |
| 14 |
go mod tidy |
| 15 |
|
| 16 |
cmp stderr tidy-stderr.want |
| 17 |
cmp go.mod go.mod.tidy |
| 18 |
|
| 19 |
cp go.mod.orig go.mod |
| 20 |
env GOTOOLCHAIN=local |
| 21 |
! go get -v . |
| 22 |
stderr '^go: example.net/[email protected]: module ./b1 requires go >= 1.22.0 \(running go 1.21.0; GOTOOLCHAIN=local\)$' |
| 23 |
env GOTOOLCHAIN=auto |
| 24 |
go get -v . |
| 25 |
cmp stderr get-v-stderr.want |
| 26 |
cmp go.mod go.mod.tidy |
| 27 |
|
| 28 |
cp go.mod.orig go.mod |
| 29 |
env GOTOOLCHAIN=local |
| 30 |
! go get -u -v . |
| 31 |
stderr '^go: example.net/[email protected]: module ./a2 requires go >= 1.22.0 \(running go 1.21.0; GOTOOLCHAIN=local\)$' |
| 32 |
env GOTOOLCHAIN=auto |
| 33 |
go get -u -v . |
| 34 |
cmp stderr get-u-v-stderr.want |
| 35 |
cmp go.mod go.mod.upgraded |
| 36 |
|
| 37 |
-- tidy-stderr.want -- |
| 38 |
go: found example.net/b in example.net/b v0.1.0 |
| 39 |
go: module ./b1 requires go >= 1.22.0; switching to go1.22.9 |
| 40 |
go: found example.net/b in example.net/b v0.1.0 |
| 41 |
go: found example.net/c in example.net/c v0.1.0 |
| 42 |
-- get-v-stderr.want -- |
| 43 |
go: trying upgrade to example.net/[email protected] |
| 44 |
go: module ./b1 requires go >= 1.22.0; switching to go1.22.9 |
| 45 |
go: trying upgrade to example.net/[email protected] |
| 46 |
go: accepting indirect upgrade from [email protected] to 1.22.0 |
| 47 |
go: trying upgrade to example.net/[email protected] |
| 48 |
go: upgraded go 1.20 => 1.22.0 |
| 49 |
go: added example.net/b v0.1.0 |
| 50 |
go: added example.net/c v0.1.0 |
| 51 |
go: added example.net/d v0.1.0 |
| 52 |
-- get-u-v-stderr.want -- |
| 53 |
go: trying upgrade to example.net/[email protected] |
| 54 |
go: trying upgrade to example.net/[email protected] |
| 55 |
go: module ./a2 requires go >= 1.22.0; switching to go1.22.9 |
| 56 |
go: trying upgrade to example.net/[email protected] |
| 57 |
go: trying upgrade to example.net/[email protected] |
| 58 |
go: accepting indirect upgrade from [email protected] to 1.22.0 |
| 59 |
go: trying upgrade to example.net/[email protected] |
| 60 |
go: trying upgrade to example.net/[email protected] |
| 61 |
go: module ./d2 requires go >= 1.23.0; switching to go1.23.9 |
| 62 |
go: trying upgrade to example.net/[email protected] |
| 63 |
go: trying upgrade to example.net/[email protected] |
| 64 |
go: accepting indirect upgrade from [email protected] to 1.22.0 |
| 65 |
go: trying upgrade to example.net/[email protected] |
| 66 |
go: trying upgrade to example.net/[email protected] |
| 67 |
go: accepting indirect upgrade from [email protected] to 1.23.0 |
| 68 |
go: upgraded go 1.20 => 1.23.0 |
| 69 |
go: upgraded example.net/a v0.1.0 => v0.2.0 |
| 70 |
go: added example.net/b v0.1.0 |
| 71 |
go: added example.net/c v0.1.0 |
| 72 |
go: added example.net/d v0.2.0 |
| 73 |
-- go.mod -- |
| 74 |
module example |
| 75 |
|
| 76 |
go 1.20 |
| 77 |
|
| 78 |
require example.net/a v0.1.0 |
| 79 |
|
| 80 |
replace ( |
| 81 |
example.net/a v0.1.0 => ./a1 |
| 82 |
example.net/a v0.2.0 => ./a2 |
| 83 |
example.net/b v0.1.0 => ./b1 |
| 84 |
example.net/c v0.1.0 => ./c1 |
| 85 |
example.net/d v0.1.0 => ./d1 |
| 86 |
example.net/d v0.2.0 => ./d2 |
| 87 |
) |
| 88 |
-- go.mod.tidy -- |
| 89 |
module example |
| 90 |
|
| 91 |
go 1.22.0 |
| 92 |
|
| 93 |
require ( |
| 94 |
example.net/a v0.1.0 |
| 95 |
example.net/b v0.1.0 |
| 96 |
) |
| 97 |
|
| 98 |
require ( |
| 99 |
example.net/c v0.1.0 // indirect |
| 100 |
example.net/d v0.1.0 // indirect |
| 101 |
) |
| 102 |
|
| 103 |
replace ( |
| 104 |
example.net/a v0.1.0 => ./a1 |
| 105 |
example.net/a v0.2.0 => ./a2 |
| 106 |
example.net/b v0.1.0 => ./b1 |
| 107 |
example.net/c v0.1.0 => ./c1 |
| 108 |
example.net/d v0.1.0 => ./d1 |
| 109 |
example.net/d v0.2.0 => ./d2 |
| 110 |
) |
| 111 |
-- go.mod.upgraded -- |
| 112 |
module example |
| 113 |
|
| 114 |
go 1.23.0 |
| 115 |
|
| 116 |
require ( |
| 117 |
example.net/a v0.2.0 |
| 118 |
example.net/b v0.1.0 |
| 119 |
) |
| 120 |
|
| 121 |
require ( |
| 122 |
example.net/c v0.1.0 // indirect |
| 123 |
example.net/d v0.2.0 // indirect |
| 124 |
) |
| 125 |
|
| 126 |
replace ( |
| 127 |
example.net/a v0.1.0 => ./a1 |
| 128 |
example.net/a v0.2.0 => ./a2 |
| 129 |
example.net/b v0.1.0 => ./b1 |
| 130 |
example.net/c v0.1.0 => ./c1 |
| 131 |
example.net/d v0.1.0 => ./d1 |
| 132 |
example.net/d v0.2.0 => ./d2 |
| 133 |
) |
| 134 |
-- example.go -- |
| 135 |
package example |
| 136 |
|
| 137 |
import ( |
| 138 |
_ "example.net/a" |
| 139 |
_ "example.net/b" |
| 140 |
) |
| 141 |
-- a1/go.mod -- |
| 142 |
module example.net/a |
| 143 |
|
| 144 |
go 1.20 |
| 145 |
-- a1/a.go -- |
| 146 |
package a |
| 147 |
-- a2/go.mod -- |
| 148 |
module example.net/a |
| 149 |
|
| 150 |
go 1.22.0 |
| 151 |
|
| 152 |
toolchain go1.23.0 |
| 153 |
-- a2/a.go -- |
| 154 |
package a |
| 155 |
-- b1/go.mod -- |
| 156 |
module example.net/b |
| 157 |
|
| 158 |
go 1.22.0 |
| 159 |
|
| 160 |
toolchain go1.23.0 |
| 161 |
-- b1/b.go -- |
| 162 |
package b |
| 163 |
|
| 164 |
import _ "example.net/c" // Note: module b is intentionally untidy, as if due to a bad git merge |
| 165 |
-- c1/go.mod -- |
| 166 |
module example.net/c |
| 167 |
|
| 168 |
go 1.22.0 |
| 169 |
|
| 170 |
require example.net/d v0.1.0 |
| 171 |
-- c1/c.go -- |
| 172 |
package c |
| 173 |
|
| 174 |
import _ "example.net/d" |
| 175 |
-- d1/go.mod -- |
| 176 |
module example.net/d |
| 177 |
|
| 178 |
go 1.22.0 |
| 179 |
-- d1/d.go -- |
| 180 |
package d |
| 181 |
-- d2/go.mod -- |
| 182 |
module example.net/d |
| 183 |
|
| 184 |
go 1.23.0 |
| 185 |
-- d2/d.go -- |
| 186 |
package d |