Skip to content

Commit b01cd41

Browse files
Bryan C. Millsgopherbot
Bryan C. Mills
authored andcommitted
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 <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Auto-Submit: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 3aea422 commit b01cd41

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

src/cmd/go/script_test.go

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,18 @@ import (
1414
"bytes"
1515
"context"
1616
"flag"
17-
"fmt"
18-
"go/build"
1917
"internal/testenv"
2018
"internal/txtar"
2119
"net/url"
2220
"os"
2321
"path/filepath"
24-
"regexp"
2522
"runtime"
2623
"strings"
2724
"testing"
2825
"time"
2926

3027
"cmd/go/internal/cfg"
28+
"cmd/go/internal/gover"
3129
"cmd/go/internal/script"
3230
"cmd/go/internal/script/scripttest"
3331
"cmd/go/internal/vcweb/vcstest"
@@ -209,10 +207,6 @@ func scriptEnv(srv *vcstest.Server, srvCertFile string) ([]string, error) {
209207
if err != nil {
210208
return nil, err
211209
}
212-
version, err := goVersion()
213-
if err != nil {
214-
return nil, err
215-
}
216210
env := []string{
217211
pathEnvName() + "=" + testBin + string(filepath.ListSeparator) + os.Getenv(pathEnvName()),
218212
homeEnvName() + "=/no-home",
@@ -243,7 +237,7 @@ func scriptEnv(srv *vcstest.Server, srvCertFile string) ([]string, error) {
243237
"GONOSUMDB=",
244238
"GOVCS=*:all",
245239
"devnull=" + os.DevNull,
246-
"goversion=" + version,
240+
"goversion=" + gover.Local(),
247241
"CMDGO_TEST_RUN_MAIN=true",
248242
"HGRCPATH=",
249243
"GOTOOLCHAIN=auto",
@@ -281,16 +275,6 @@ func scriptEnv(srv *vcstest.Server, srvCertFile string) ([]string, error) {
281275
return env, nil
282276
}
283277

284-
// goVersion returns the current Go version.
285-
func goVersion() (string, error) {
286-
tags := build.Default.ReleaseTags
287-
version := tags[len(tags)-1]
288-
if !regexp.MustCompile(`^go([1-9][0-9]*)\.(0|[1-9][0-9]*)$`).MatchString(version) {
289-
return "", fmt.Errorf("invalid go version %q", version)
290-
}
291-
return version[2:], nil
292-
}
293-
294278
var extraEnvKeys = []string{
295279
"SYSTEMROOT", // must be preserved on Windows to find DLLs; golang.org/issue/25210
296280
"WINDIR", // must be preserved on Windows to be able to run PowerShell command; golang.org/issue/30711

0 commit comments

Comments
 (0)