diff options
author | Bryan C. Mills <bcmills@google.com> | 2023-06-14 17:16:59 -0400 |
---|---|---|
committer | Gopher Robot <gobot@golang.org> | 2023-06-14 21:53:21 +0000 |
commit | b01cd41b46eef0b7e60c6b1e84347a7ca9604224 (patch) | |
tree | cde79dc010920376c29373efa2a04a417cac0d9b /src/cmd/go/script_test.go | |
parent | 3aea422e2cb8b1ec2e0c2774be97fe96c7299838 (diff) | |
download | go-b01cd41b46eef0b7e60c6b1e84347a7ca9604224.tar.gz go-b01cd41b46eef0b7e60c6b1e84347a7ca9604224.zip |
cmd/go: use gover.Local for $goversion in TestScript
Previously we used the highest Go build tag found in the build
configuration, which matches gover.Local for development toolchains
(it is always a bare language version), but is too low for releases.
Updates #57001.
Change-Id: I74c2f7ab06231858eee99ecd11ed3759853e01ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/503537
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/cmd/go/script_test.go')
-rw-r--r-- | src/cmd/go/script_test.go | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/src/cmd/go/script_test.go b/src/cmd/go/script_test.go index d0099888d9..624c5bf501 100644 --- a/src/cmd/go/script_test.go +++ b/src/cmd/go/script_test.go @@ -14,20 +14,18 @@ import ( "bytes" "context" "flag" - "fmt" - "go/build" "internal/testenv" "internal/txtar" "net/url" "os" "path/filepath" - "regexp" "runtime" "strings" "testing" "time" "cmd/go/internal/cfg" + "cmd/go/internal/gover" "cmd/go/internal/script" "cmd/go/internal/script/scripttest" "cmd/go/internal/vcweb/vcstest" @@ -209,10 +207,6 @@ func scriptEnv(srv *vcstest.Server, srvCertFile string) ([]string, error) { if err != nil { return nil, err } - version, err := goVersion() - if err != nil { - return nil, err - } env := []string{ pathEnvName() + "=" + testBin + string(filepath.ListSeparator) + os.Getenv(pathEnvName()), homeEnvName() + "=/no-home", @@ -243,7 +237,7 @@ func scriptEnv(srv *vcstest.Server, srvCertFile string) ([]string, error) { "GONOSUMDB=", "GOVCS=*:all", "devnull=" + os.DevNull, - "goversion=" + version, + "goversion=" + gover.Local(), "CMDGO_TEST_RUN_MAIN=true", "HGRCPATH=", "GOTOOLCHAIN=auto", @@ -281,16 +275,6 @@ func scriptEnv(srv *vcstest.Server, srvCertFile string) ([]string, error) { return env, nil } -// goVersion returns the current Go version. -func goVersion() (string, error) { - tags := build.Default.ReleaseTags - version := tags[len(tags)-1] - if !regexp.MustCompile(`^go([1-9][0-9]*)\.(0|[1-9][0-9]*)$`).MatchString(version) { - return "", fmt.Errorf("invalid go version %q", version) - } - return version[2:], nil -} - var extraEnvKeys = []string{ "SYSTEMROOT", // must be preserved on Windows to find DLLs; golang.org/issue/25210 "WINDIR", // must be preserved on Windows to be able to run PowerShell command; golang.org/issue/30711 |