]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: use gover.Local for $goversion in TestScript
authorBryan C. Mills <bcmills@google.com>
Wed, 14 Jun 2023 21:16:59 +0000 (17:16 -0400)
committerGopher Robot <gobot@golang.org>
Wed, 14 Jun 2023 21:53:21 +0000 (21:53 +0000)
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>

src/cmd/go/script_test.go

index d0099888d9cc44603136adba86e5b28e55bc5386..624c5bf50106202ef24b6f1b90517cb63e71c8f9 100644 (file)
@@ -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