reject invalid Go toolchain versions early

Otherwise we might do odd things, such as trying to open the linker
patches directory "patches/" given that go/version.Lang
returns an empty string for invalid versions.

See #978.
This commit is contained in:
Daniel Martí
2025-10-17 17:28:21 +01:00
committed by Paul Scheduikat
parent 9d7c84b0c6
commit 15a385283b
2 changed files with 11 additions and 2 deletions

View File

@@ -9,15 +9,20 @@ env TOOLCHAIN_GOVERSION=''
! exec garble build
stderr 'Go version is too old; please upgrade to go1\.25\.0 or newer'
# A clearly invalid go version.
env TOOLCHAIN_GOVERSION='bogus version'
! exec garble build
stderr 'Go version "bogus version" appears to be invalid or too old; use go1\.25\.0 or newer'
# We should error on a devel version that's too old;
# note that they started with the string "devel",
# and very old ones didn't even have "goN.M" in them.
env TOOLCHAIN_GOVERSION='devel +afb5fca Sun Aug 07 00:00:00 2020 +0000'
! exec garble build
stderr 'Go version "devel \+afb5.*2020.*" is too old; please upgrade to go1\.25\.0 or newer'
stderr 'Go version .* appears to be invalid or too old'
env TOOLCHAIN_GOVERSION='devel go1.15-afb5fca Sun Aug 07 00:00:00 2020 +0000'
! exec garble build
stderr 'Go version "devel go1\.15-.*2020.*" is too old; please upgrade to go1\.25\.0 or newer'
stderr 'Go version .* appears to be invalid or too old'
# A current devel version should be fine.
# Note that we don't look at devel version timestamps.