]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/amd64: more robust detection of GOAMD64=v1
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 10 Aug 2022 15:13:23 +0000 (22:13 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Thu, 11 Aug 2022 16:21:41 +0000 (16:21 +0000)
Using build tool tags instead of relying on GOAMD64 env, which can be
overriden at make.bash time.

Change-Id: I96bb4b7416ea0bd1ab552feec9ede45b89a584c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/422614
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/amd64/versions_test.go

index b6411a1cb0d2fe8f853d35608fdd300f30cfcad4..647bcdc2f0728030d2d72f87528187123a8bc69c 100644 (file)
@@ -14,6 +14,7 @@ import (
        "debug/macho"
        "errors"
        "fmt"
+       "go/build"
        "internal/testenv"
        "io"
        "math"
@@ -36,10 +37,10 @@ func TestGoAMD64v1(t *testing.T) {
        if runtime.GOOS != "linux" && runtime.GOOS != "darwin" {
                t.Skip("test only works on elf or macho platforms")
        }
-       if v := os.Getenv("GOAMD64"); v != "" && v != "v1" {
-               // Test runs only on v1 (which is the default).
-               // TODO: use build tags from #45454 instead.
-               t.Skip("GOAMD64 already set")
+       for _, tag := range build.Default.ToolTags {
+               if tag == "amd64.v2" {
+                       t.Skip("compiling for GOAMD64=v2 or higher")
+               }
        }
        if os.Getenv("TESTGOAMD64V1") != "" {
                t.Skip("recursive call")