]> Cypherpunks repositories - gostls13.git/commitdiff
go/internal/gcimporter,cmd/compile/internal/importer: use testenv.MustHaveGoBuild...
authorBryan C. Mills <bcmills@google.com>
Wed, 19 Oct 2022 18:09:54 +0000 (14:09 -0400)
committerGopher Robot <gobot@golang.org>
Wed, 19 Oct 2022 19:25:56 +0000 (19:25 +0000)
These tests previously had a “skipSpecialPlatforms” function, added in
CL 8611 to skip tests on (apparently) NaCL and iOS. The iOS builders
no longer match the condition (GOOS=ios is its own thing now), and the
NaCL port no longer exists.

The name of the function also isn't very evocative, since it doesn't
say what is “special” about the platforms to cause them to be
skipped.m

Since the check is intending to run the tests only on platforms where
gc export data is available, and to a first approximation
“gc export data is available” on exactly the platforms that can run
“go build” to produce that export data, we can use the testenv function
instead of a one-off.

Updates #38485.

Change-Id: I8f38b9604300d165147f8942e945ab762419fad7
Reviewed-on: https://go-review.googlesource.com/c/go/+/444155
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>

src/cmd/compile/internal/importer/gcimporter_test.go
src/go/internal/gcimporter/gcimporter_test.go

index 988d7daa25ced6b171bf7f87be8f7b66fb52b74c..03562d394fad47069f235342f490c5b85105e1d6 100644 (file)
@@ -26,20 +26,6 @@ func TestMain(m *testing.M) {
        os.Exit(m.Run())
 }
 
-// skipSpecialPlatforms causes the test to be skipped for platforms where
-// builders (build.golang.org) don't have access to compiled packages for
-// import.
-func skipSpecialPlatforms(t *testing.T) {
-       t.Helper()
-       testenv.MustHaveGoBuild(t)
-
-       // TODO(bcmills): Is this still accurate now that ios is its own GOOS?
-       switch platform := runtime.GOOS + "-" + runtime.GOARCH; platform {
-       case "darwin-arm64":
-               t.Skipf("no compiled packages available for import on %s", platform)
-       }
-}
-
 // compile runs the compiler on filename, with dirname as the working directory,
 // and writes the output file to outdirname.
 // compile gives the resulting package a packagepath of testdata/<filebasename>.
@@ -124,7 +110,7 @@ func TestImportTestdata(t *testing.T) {
                t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
        }
 
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        testfiles := map[string][]string{
                "exports.go":  {"go/ast", "go/token"},
@@ -159,7 +145,7 @@ func TestImportTestdata(t *testing.T) {
 }
 
 func TestVersionHandling(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -250,7 +236,7 @@ func TestVersionHandling(t *testing.T) {
 }
 
 func TestImportStdLib(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -290,7 +276,7 @@ var importedObjectTests = []struct {
 }
 
 func TestImportedTypes(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -373,7 +359,7 @@ func verifyInterfaceMethodRecvs(t *testing.T, named *types2.Named, level int) {
 }
 
 func TestIssue5815(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -402,7 +388,7 @@ func TestIssue5815(t *testing.T) {
 
 // Smoke test to ensure that imported methods get the correct package.
 func TestCorrectMethodPackage(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -424,7 +410,7 @@ func TestCorrectMethodPackage(t *testing.T) {
 }
 
 func TestIssue13566(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -463,7 +449,7 @@ func TestIssue13566(t *testing.T) {
 }
 
 func TestIssue13898(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -509,7 +495,7 @@ func TestIssue13898(t *testing.T) {
 }
 
 func TestIssue15517(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -548,7 +534,7 @@ func TestIssue15517(t *testing.T) {
 }
 
 func TestIssue15920(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -565,7 +551,7 @@ func TestIssue15920(t *testing.T) {
 }
 
 func TestIssue20046(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -586,7 +572,7 @@ func TestIssue20046(t *testing.T) {
        }
 }
 func TestIssue25301(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -603,7 +589,7 @@ func TestIssue25301(t *testing.T) {
 }
 
 func TestIssue25596(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
index 7fa698d7c11c7a3b2cc52f1536a560b2b902bd7c..bcbaa558d3b801cec835865ea08272d830afa9a0 100644 (file)
@@ -33,19 +33,6 @@ func TestMain(m *testing.M) {
        os.Exit(m.Run())
 }
 
-// skipSpecialPlatforms causes the test to be skipped for platforms where
-// builders (build.golang.org) don't have access to compiled packages for
-// import.
-func skipSpecialPlatforms(t *testing.T) {
-       t.Helper()
-       testenv.MustHaveGoBuild(t)
-
-       switch platform := runtime.GOOS + "-" + runtime.GOARCH; platform {
-       case "darwin-arm64":
-               t.Skipf("no compiled packages available for import on %s", platform)
-       }
-}
-
 // compile runs the compiler on filename, with dirname as the working directory,
 // and writes the output file to outdirname.
 // compile gives the resulting package a packagepath of testdata/<filebasename>.
@@ -133,7 +120,7 @@ func TestImportTestdata(t *testing.T) {
                t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
        }
 
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        testfiles := map[string][]string{
                "exports.go":  {"go/ast", "go/token"},
@@ -173,7 +160,7 @@ func TestImportTypeparamTests(t *testing.T) {
                t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
        }
 
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        tmpdir := mktmpdir(t)
        defer os.RemoveAll(tmpdir)
@@ -291,7 +278,7 @@ func checkFile(t *testing.T, filename string, src []byte) *types.Package {
 }
 
 func TestVersionHandling(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -384,7 +371,7 @@ func TestVersionHandling(t *testing.T) {
 }
 
 func TestImportStdLib(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -424,7 +411,7 @@ var importedObjectTests = []struct {
 }
 
 func TestImportedTypes(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -500,7 +487,7 @@ func verifyInterfaceMethodRecvs(t *testing.T, named *types.Named, level int) {
 }
 
 func TestIssue5815(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -529,7 +516,7 @@ func TestIssue5815(t *testing.T) {
 
 // Smoke test to ensure that imported methods get the correct package.
 func TestCorrectMethodPackage(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -553,7 +540,7 @@ func TestCorrectMethodPackage(t *testing.T) {
 }
 
 func TestIssue13566(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -592,7 +579,7 @@ func TestIssue13566(t *testing.T) {
 }
 
 func TestTypeNamingOrder(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -616,7 +603,7 @@ func TestTypeNamingOrder(t *testing.T) {
 }
 
 func TestIssue13898(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -663,7 +650,7 @@ func TestIssue13898(t *testing.T) {
 }
 
 func TestIssue15517(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -703,7 +690,7 @@ func TestIssue15517(t *testing.T) {
 }
 
 func TestIssue15920(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -720,7 +707,7 @@ func TestIssue15920(t *testing.T) {
 }
 
 func TestIssue20046(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -741,7 +728,7 @@ func TestIssue20046(t *testing.T) {
        }
 }
 func TestIssue25301(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {
@@ -758,7 +745,7 @@ func TestIssue25301(t *testing.T) {
 }
 
 func TestIssue25596(t *testing.T) {
-       skipSpecialPlatforms(t)
+       testenv.MustHaveGoBuild(t)
 
        // This package only handles gc export data.
        if runtime.Compiler != "gc" {