From: Bryan C. Mills Date: Wed, 19 Oct 2022 18:09:54 +0000 (-0400) Subject: go/internal/gcimporter,cmd/compile/internal/importer: use testenv.MustHaveGoBuild... X-Git-Tag: go1.20rc1~592 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=4a164a44de3c67da878403504d948dfbd4fc6f7d;p=gostls13.git go/internal/gcimporter,cmd/compile/internal/importer: use testenv.MustHaveGoBuild directly 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 TryBot-Result: Gopher Robot Reviewed-by: David Chase Run-TryBot: Bryan Mills --- diff --git a/src/cmd/compile/internal/importer/gcimporter_test.go b/src/cmd/compile/internal/importer/gcimporter_test.go index 988d7daa25..03562d394f 100644 --- a/src/cmd/compile/internal/importer/gcimporter_test.go +++ b/src/cmd/compile/internal/importer/gcimporter_test.go @@ -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/. @@ -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" { diff --git a/src/go/internal/gcimporter/gcimporter_test.go b/src/go/internal/gcimporter/gcimporter_test.go index 7fa698d7c1..bcbaa558d3 100644 --- a/src/go/internal/gcimporter/gcimporter_test.go +++ b/src/go/internal/gcimporter/gcimporter_test.go @@ -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/. @@ -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" {