Commit 5d6e8f31 authored by Ian Lance Taylor's avatar Ian Lance Taylor

cmd/go: add goversion environment variable to testing script language

Updates #28221

Change-Id: I8a1e352cd9122bce200d45c6b19955cb50308d71
Reviewed-on: https://go-review.googlesource.com/c/147280
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBryan C. Mills <bcmills@google.com>
parent 67018e9b
......@@ -11,6 +11,7 @@ import (
"bytes"
"context"
"fmt"
"go/build"
"internal/testenv"
"io/ioutil"
"os"
......@@ -104,6 +105,7 @@ func (ts *testScript) setup() {
"GOROOT=" + testGOROOT,
tempEnvName() + "=" + filepath.Join(ts.workdir, "tmp"),
"devnull=" + os.DevNull,
"goversion=" + goVersion(ts),
":=" + string(os.PathListSeparator),
}
......@@ -130,6 +132,16 @@ func (ts *testScript) setup() {
}
}
// goVersion returns the current Go version.
func goVersion(ts *testScript) string {
tags := build.Default.ReleaseTags
version := tags[len(tags)-1]
if !regexp.MustCompile(`^go([1-9][0-9]*)\.(0|[1-9][0-9]*)$`).MatchString(version) {
ts.fatalf("invalid go version %q", version)
}
return version[2:]
}
var execCache par.Cache
// run runs the test script.
......
......@@ -36,6 +36,7 @@ Scripts also have access to these other environment variables:
PATH=<actual PATH>
TMPDIR=$WORK/tmp
devnull=<value of os.DevNull>
goversion=<current Go version; for example, 1.12>
The environment variable $exe (lowercase) is an empty string on most systems, ".exe" on Windows.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment