]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: more selective disabling of tests
authorRobert Griesemer <gri@golang.org>
Wed, 8 Apr 2015 04:46:58 +0000 (21:46 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 8 Apr 2015 17:54:17 +0000 (17:54 +0000)
Disable importer-dependent tests on platforms for which the
respective builders don't have access to importable packages.

Fixes #10368.

Change-Id: I8072c59d2bbbc24a43d771fd04fd0b1a678d765a
Reviewed-on: https://go-review.googlesource.com/8611
Reviewed-by: Minux Ma <minux@golang.org>
src/go/types/api_test.go
src/go/types/check_test.go
src/go/types/eval_test.go
src/go/types/internal/gcimporter/gcimporter_test.go
src/go/types/resolver_test.go
src/go/types/stdlib_test.go
src/go/types/typestring_test.go

index 1b5281b187265f7297909b8f41a88c23987011ce..983ac950bfc0f609528fa6e658e4ea9c0bb38342 100644 (file)
@@ -18,18 +18,17 @@ import (
        _ "go/types/internal/gcimporter"
 )
 
-// skipTest returns true for platforms on which the current gcimporter doesn't work.
-// TODO(gri) eliminate this ASAP.
-func skipTest() bool {
-       switch runtime.GOOS + "-" + runtime.GOARCH {
+// 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) {
+       switch platform := runtime.GOOS + "-" + runtime.GOARCH; platform {
        case "nacl-amd64p32",
-               "windows-amd64",
                "nacl-386",
-               "windows-386",
-               "plan9-386":
-               return true
+               "darwin-arm",
+               "darwin-arm64":
+               t.Skipf("no compiled packages available for import on %s", platform)
        }
-       return false
 }
 
 func pkgFor(path, source string, info *Info) (*Package, error) {
@@ -299,9 +298,7 @@ func predString(tv TypeAndValue) string {
 }
 
 func TestPredicatesInfo(t *testing.T) {
-       if skipTest() {
-               return
-       }
+       skipSpecialPlatforms(t)
 
        var tests = []struct {
                src  string
@@ -387,9 +384,7 @@ func TestPredicatesInfo(t *testing.T) {
 }
 
 func TestScopesInfo(t *testing.T) {
-       if skipTest() {
-               return
-       }
+       skipSpecialPlatforms(t)
 
        var tests = []struct {
                src    string
index dc4284c4eb776b024b3fc6e185b0c77c3b03e7a1..6d2b5e957b0743be423bf4a4bbeba47ca8c6d4c8 100644 (file)
@@ -278,9 +278,7 @@ func checkFiles(t *testing.T, testfiles []string) {
 }
 
 func TestCheck(t *testing.T) {
-       if skipTest() {
-               return
-       }
+       skipSpecialPlatforms(t)
 
        // Declare builtins for testing.
        DefPredeclaredTestFuncs()
index 84c1c1b51a72a5af96a23d8770d8b191e9f9c90a..8fc15034d0363e2eabf46f6ec9f20a43dc532b00 100644 (file)
@@ -83,9 +83,7 @@ func TestEvalArith(t *testing.T) {
 }
 
 func TestEvalContext(t *testing.T) {
-       if skipTest() {
-               return
-       }
+       skipSpecialPlatforms(t)
 
        src := `
 package p
index 590b225affe719a26a941c76666732615af2735c..31bfc4830e5f8f7dc4c29d9d523ed24d67f7427a 100644 (file)
@@ -18,18 +18,17 @@ import (
        "go/types"
 )
 
-// skipTest returns true for platforms on which the current gcimporter doesn't work.
-// TODO(gri) eliminate this ASAP.
-func skipTest() bool {
-       switch runtime.GOOS + "-" + runtime.GOARCH {
+// 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) {
+       switch platform := runtime.GOOS + "-" + runtime.GOARCH; platform {
        case "nacl-amd64p32",
-               "windows-amd64",
                "nacl-386",
-               "windows-386",
-               "plan9-386":
-               return true
+               "darwin-arm",
+               "darwin-arm64":
+               t.Skipf("no compiled packages available for import on %s", platform)
        }
-       return false
 }
 
 var gcPath string // Go compiler path
@@ -111,8 +110,9 @@ func testDir(t *testing.T, dir string, endTime time.Time) (nimports int) {
 }
 
 func TestImport(t *testing.T) {
-       // This package does not handle gccgo export data.
-       if runtime.Compiler == "gccgo" {
+       // This package only handles gc export data.
+       if runtime.Compiler != "gc" {
+               t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
                return
        }
 
@@ -147,14 +147,14 @@ var importedObjectTests = []struct {
 }
 
 func TestImportedTypes(t *testing.T) {
-       if skipTest() {
-               return
-       }
+       skipSpecialPlatforms(t)
 
-       // This package does not handle gccgo export data.
-       if runtime.Compiler == "gccgo" {
+       // This package only handles gc export data.
+       if runtime.Compiler != "gc" {
+               t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
                return
        }
+
        for _, test := range importedObjectTests {
                s := strings.Split(test.name, ".")
                if len(s) != 2 {
@@ -183,12 +183,11 @@ func TestImportedTypes(t *testing.T) {
 }
 
 func TestIssue5815(t *testing.T) {
-       if skipTest() {
-               return
-       }
+       skipSpecialPlatforms(t)
 
-       // This package does not handle gccgo export data.
-       if runtime.Compiler == "gccgo" {
+       // This package only handles gc export data.
+       if runtime.Compiler != "gc" {
+               t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
                return
        }
 
@@ -217,12 +216,11 @@ func TestIssue5815(t *testing.T) {
 
 // Smoke test to ensure that imported methods get the correct package.
 func TestCorrectMethodPackage(t *testing.T) {
-       if skipTest() {
-               return
-       }
+       skipSpecialPlatforms(t)
 
-       // This package does not handle gccgo export data.
-       if runtime.Compiler == "gccgo" {
+       // This package only handles gc export data.
+       if runtime.Compiler != "gc" {
+               t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
                return
        }
 
index 90858549759e3015dfcaa878342a25816650d177..cfd04dad1e30b081872246d8ab44819188c196c7 100644 (file)
@@ -89,9 +89,7 @@ var pkgnames = []string{
 }
 
 func TestResolveIdents(t *testing.T) {
-       if skipTest() {
-               return
-       }
+       skipSpecialPlatforms(t)
 
        // parse package files
        fset := token.NewFileSet()
index 515bbcdc58baef05fe8ca7c61c78dae3ca88f842..4b66944989812ee1f7c58c000a494375b69a6433 100644 (file)
@@ -32,9 +32,7 @@ var (
 )
 
 func TestStdlib(t *testing.T) {
-       if skipTest() {
-               return
-       }
+       skipSpecialPlatforms(t)
 
        walkDirs(t, filepath.Join(runtime.GOROOT(), "src"))
        if testing.Verbose() {
@@ -120,7 +118,11 @@ func testTestDir(t *testing.T, path string, ignore ...string) {
 }
 
 func TestStdTest(t *testing.T) {
-       if skipTest() {
+       skipSpecialPlatforms(t)
+
+       // test/recover4.go is only built for Linux and Darwin.
+       // TODO(gri) Remove once tests consider +build tags (issue 10370).
+       if runtime.GOOS != "linux" || runtime.GOOS != "darwin" {
                return
        }
 
@@ -131,9 +133,7 @@ func TestStdTest(t *testing.T) {
 }
 
 func TestStdFixed(t *testing.T) {
-       if skipTest() {
-               return
-       }
+       skipSpecialPlatforms(t)
 
        testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "fixedbugs"),
                "bug248.go", "bug302.go", "bug369.go", // complex test instructions - ignore
@@ -144,9 +144,7 @@ func TestStdFixed(t *testing.T) {
 }
 
 func TestStdKen(t *testing.T) {
-       if skipTest() {
-               return
-       }
+       skipSpecialPlatforms(t)
 
        testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "ken"))
 }
index c068157cd84b4455f99eb6b3433b7637bc4052da..b01fe991c4723b0c10de32146fddf759c5c3d27b 100644 (file)
@@ -116,9 +116,7 @@ var dependentTestTypes = []testEntry{
 }
 
 func TestTypeString(t *testing.T) {
-       if skipTest() {
-               return
-       }
+       skipSpecialPlatforms(t)
 
        var tests []testEntry
        tests = append(tests, independentTestTypes...)