aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2023-06-14 17:16:59 -0400
committerGopher Robot <gobot@golang.org>2023-06-14 21:53:21 +0000
commitb01cd41b46eef0b7e60c6b1e84347a7ca9604224 (patch)
treecde79dc010920376c29373efa2a04a417cac0d9b
parent3aea422e2cb8b1ec2e0c2774be97fe96c7299838 (diff)
downloadgo-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>
-rw-r--r--src/cmd/go/script_test.go20
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