File tree 2 files changed +13
-0
lines changed 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import (
11
11
"bytes"
12
12
"context"
13
13
"fmt"
14
+ "go/build"
14
15
"internal/testenv"
15
16
"io/ioutil"
16
17
"os"
@@ -104,6 +105,7 @@ func (ts *testScript) setup() {
104
105
"GOROOT=" + testGOROOT ,
105
106
tempEnvName () + "=" + filepath .Join (ts .workdir , "tmp" ),
106
107
"devnull=" + os .DevNull ,
108
+ "goversion=" + goVersion (ts ),
107
109
":=" + string (os .PathListSeparator ),
108
110
}
109
111
@@ -130,6 +132,16 @@ func (ts *testScript) setup() {
130
132
}
131
133
}
132
134
135
+ // goVersion returns the current Go version.
136
+ func goVersion (ts * testScript ) string {
137
+ tags := build .Default .ReleaseTags
138
+ version := tags [len (tags )- 1 ]
139
+ if ! regexp .MustCompile (`^go([1-9][0-9]*)\.(0|[1-9][0-9]*)$` ).MatchString (version ) {
140
+ ts .fatalf ("invalid go version %q" , version )
141
+ }
142
+ return version [2 :]
143
+ }
144
+
133
145
var execCache par.Cache
134
146
135
147
// run runs the test script.
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ Scripts also have access to these other environment variables:
36
36
PATH=<actual PATH>
37
37
TMPDIR=$WORK/tmp
38
38
devnull=<value of os.DevNull>
39
+ goversion=<current Go version; for example, 1.12>
39
40
40
41
The environment variable $exe (lowercase) is an empty string on most systems, ".exe" on Windows.
41
42
You can’t perform that action at this time.
0 commit comments