diff --git a/testdata/script/gotoolchain.txtar b/testdata/script/gotoolchain.txtar index 5f8af1d..29c16af 100644 --- a/testdata/script/gotoolchain.txtar +++ b/testdata/script/gotoolchain.txtar @@ -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