"bytes"
"context"
"fmt"
+ "go/build"
"internal/testenv"
"io/ioutil"
"os"
"GOROOT=" + testGOROOT,
tempEnvName() + "=" + filepath.Join(ts.workdir, "tmp"),
"devnull=" + os.DevNull,
+ "goversion=" + goVersion(ts),
":=" + string(os.PathListSeparator),
}
}
}
+// 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.
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.