]> Cypherpunks repositories - gostls13.git/commitdiff
test/run: always set goos and goarch
authorDavid du Colombier <0intro@gmail.com>
Thu, 24 Jul 2014 21:18:54 +0000 (23:18 +0200)
committerDavid du Colombier <0intro@gmail.com>
Thu, 24 Jul 2014 21:18:54 +0000 (23:18 +0200)
Following CL 68150047, the goos and goarch
variables are not currently set when the GOOS
and GOARCH environment variables are not set.

This made the content of the build tag to be
ignored in this case.

This CL sets goos and goarch to runtime.GOOS
and runtime.GOARCH when the GOOS and GOARCH
environments variables are not set.

LGTM=aram, bradfitz
R=golang-codereviews, aram, gobot, rsc, dave, bradfitz
CC=golang-codereviews, rsc
https://golang.org/cl/112490043

test/run.go

index a8d4baa3ac8d97f546a632ea54b655bcda206f71..a8a6dedb239657160a6b749d9b9157b0f35608bb 100644 (file)
@@ -71,8 +71,9 @@ const maxTests = 5000
 func main() {
        flag.Parse()
 
-       goos = os.Getenv("GOOS")
-       goarch = os.Getenv("GOARCH")
+       goos = getenv("GOOS", runtime.GOOS)
+       goarch = getenv("GOARCH", runtime.GOARCH)
+
        findExecCmd()
 
        // Disable parallelism if printing or if using a simulator.
@@ -972,3 +973,11 @@ func envForDir(dir string) []string {
        env = append(env, "PWD="+dir)
        return env
 }
+
+func getenv(key, def string) string {
+       value := os.Getenv(key)
+       if value != "" {
+               return value
+       }
+       return def
+}