make gotoolchain.txtar upgrade to the host's GOVERSION

On CI we test on go1.23.x and go1.24.x, so if we always upgrade
to the latest go1.24.x, that will cause garble to complain
when running on go1.23.x:

    garble was built with "go1.23.7" and can't be used with the newer "go1.24.1"

Moreover, the test hard-coded go1.24.1, which is currently the latest
go1.24.x but will not be for long, so this test was brittle.
master
Daniel Martí 3 days ago committed by Paul Scheduikat
parent db3003b9fa
commit 8ee4c91196

@ -1,20 +1,33 @@
# Test that garble works with transparent upgrades via GOTOOLCHAIN.
# We want the upgraded toolchain to match the garble binary
# which we will exec below, as otherwise garble will complain.
# Tell GOTOOLCHAIN to upgrade to the same version thanks to `go mod init`
# setting up a `go` directive with its Go version.
cd mod
go mod init test
exec cat go.mod
cd ..
go env GOVERSION
setenvfile GOVERSION_UPGRADE stdout
# To test that garble works with transparent upgrades via GOTOOLCHAIN,
# use a relatively old version, but still new enough to support GOTOOLCHAIN.
env GOVERSION_BASE=go1.23.0
setup-go ${GOVERSION_BASE}
# We want to use the real GOPROXY so that we can download the newer
# toolchain, and we use the host's GOMODCACHE so we can reuse it.
setup-go go1.23.7
env GOPROXY=proxy.golang.org
env GOMODCACHE=${HOST_GOMODCACHE}
# Verify that we are using an older version of Go.
exec go version
stdout 'go version go1\.23\.7'
cd mod
stdout 'go version '${GOVERSION_BASE@R}
# The builds inside the module use the upgraded toolchain.
cd mod
exec go run .
stderr 'hello from go1\.24\.1'
stderr 'hello from '${GOVERSION_UPGRADE@R}
# Note that garble hides runtime.Version by design, but we know that it requires
# the Go toolchain version to match the exact same version that built garble,
@ -22,10 +35,6 @@ stderr 'hello from go1\.24\.1'
exec garble run .
stderr 'hello from unknown'
-- mod/go.mod --
module test
go 1.24.1
-- mod/main.go --
package main

Loading…
Cancel
Save