Commit ad266b96 authored by Robert Griesemer's avatar Robert Griesemer

go/types: more selective disabling of tests

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/8611Reviewed-by: default avatarMinux Ma <minux@golang.org>
parent 7ac67b55
...@@ -18,18 +18,17 @@ import ( ...@@ -18,18 +18,17 @@ import (
_ "go/types/internal/gcimporter" _ "go/types/internal/gcimporter"
) )
// skipTest returns true for platforms on which the current gcimporter doesn't work. // skipSpecialPlatforms causes the test to be skipped for platforms where
// TODO(gri) eliminate this ASAP. // builders (build.golang.org) don't have access to compiled packages for
func skipTest() bool { // import.
switch runtime.GOOS + "-" + runtime.GOARCH { func skipSpecialPlatforms(t *testing.T) {
switch platform := runtime.GOOS + "-" + runtime.GOARCH; platform {
case "nacl-amd64p32", case "nacl-amd64p32",
"windows-amd64",
"nacl-386", "nacl-386",
"windows-386", "darwin-arm",
"plan9-386": "darwin-arm64":
return true t.Skipf("no compiled packages available for import on %s", platform)
} }
return false
} }
func pkgFor(path, source string, info *Info) (*Package, error) { func pkgFor(path, source string, info *Info) (*Package, error) {
...@@ -299,9 +298,7 @@ func predString(tv TypeAndValue) string { ...@@ -299,9 +298,7 @@ func predString(tv TypeAndValue) string {
} }
func TestPredicatesInfo(t *testing.T) { func TestPredicatesInfo(t *testing.T) {
if skipTest() { skipSpecialPlatforms(t)
return
}
var tests = []struct { var tests = []struct {
src string src string
...@@ -387,9 +384,7 @@ func TestPredicatesInfo(t *testing.T) { ...@@ -387,9 +384,7 @@ func TestPredicatesInfo(t *testing.T) {
} }
func TestScopesInfo(t *testing.T) { func TestScopesInfo(t *testing.T) {
if skipTest() { skipSpecialPlatforms(t)
return
}
var tests = []struct { var tests = []struct {
src string src string
......
...@@ -278,9 +278,7 @@ func checkFiles(t *testing.T, testfiles []string) { ...@@ -278,9 +278,7 @@ func checkFiles(t *testing.T, testfiles []string) {
} }
func TestCheck(t *testing.T) { func TestCheck(t *testing.T) {
if skipTest() { skipSpecialPlatforms(t)
return
}
// Declare builtins for testing. // Declare builtins for testing.
DefPredeclaredTestFuncs() DefPredeclaredTestFuncs()
......
...@@ -83,9 +83,7 @@ func TestEvalArith(t *testing.T) { ...@@ -83,9 +83,7 @@ func TestEvalArith(t *testing.T) {
} }
func TestEvalContext(t *testing.T) { func TestEvalContext(t *testing.T) {
if skipTest() { skipSpecialPlatforms(t)
return
}
src := ` src := `
package p package p
......
...@@ -18,18 +18,17 @@ import ( ...@@ -18,18 +18,17 @@ import (
"go/types" "go/types"
) )
// skipTest returns true for platforms on which the current gcimporter doesn't work. // skipSpecialPlatforms causes the test to be skipped for platforms where
// TODO(gri) eliminate this ASAP. // builders (build.golang.org) don't have access to compiled packages for
func skipTest() bool { // import.
switch runtime.GOOS + "-" + runtime.GOARCH { func skipSpecialPlatforms(t *testing.T) {
switch platform := runtime.GOOS + "-" + runtime.GOARCH; platform {
case "nacl-amd64p32", case "nacl-amd64p32",
"windows-amd64",
"nacl-386", "nacl-386",
"windows-386", "darwin-arm",
"plan9-386": "darwin-arm64":
return true t.Skipf("no compiled packages available for import on %s", platform)
} }
return false
} }
var gcPath string // Go compiler path var gcPath string // Go compiler path
...@@ -111,8 +110,9 @@ func testDir(t *testing.T, dir string, endTime time.Time) (nimports int) { ...@@ -111,8 +110,9 @@ func testDir(t *testing.T, dir string, endTime time.Time) (nimports int) {
} }
func TestImport(t *testing.T) { func TestImport(t *testing.T) {
// This package does not handle gccgo export data. // This package only handles gc export data.
if runtime.Compiler == "gccgo" { if runtime.Compiler != "gc" {
t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
return return
} }
...@@ -147,14 +147,14 @@ var importedObjectTests = []struct { ...@@ -147,14 +147,14 @@ var importedObjectTests = []struct {
} }
func TestImportedTypes(t *testing.T) { func TestImportedTypes(t *testing.T) {
if skipTest() { skipSpecialPlatforms(t)
return
}
// This package does not handle gccgo export data. // This package only handles gc export data.
if runtime.Compiler == "gccgo" { if runtime.Compiler != "gc" {
t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
return return
} }
for _, test := range importedObjectTests { for _, test := range importedObjectTests {
s := strings.Split(test.name, ".") s := strings.Split(test.name, ".")
if len(s) != 2 { if len(s) != 2 {
...@@ -183,12 +183,11 @@ func TestImportedTypes(t *testing.T) { ...@@ -183,12 +183,11 @@ func TestImportedTypes(t *testing.T) {
} }
func TestIssue5815(t *testing.T) { func TestIssue5815(t *testing.T) {
if skipTest() { skipSpecialPlatforms(t)
return
}
// This package does not handle gccgo export data. // This package only handles gc export data.
if runtime.Compiler == "gccgo" { if runtime.Compiler != "gc" {
t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
return return
} }
...@@ -217,12 +216,11 @@ func TestIssue5815(t *testing.T) { ...@@ -217,12 +216,11 @@ func TestIssue5815(t *testing.T) {
// Smoke test to ensure that imported methods get the correct package. // Smoke test to ensure that imported methods get the correct package.
func TestCorrectMethodPackage(t *testing.T) { func TestCorrectMethodPackage(t *testing.T) {
if skipTest() { skipSpecialPlatforms(t)
return
}
// This package does not handle gccgo export data. // This package only handles gc export data.
if runtime.Compiler == "gccgo" { if runtime.Compiler != "gc" {
t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
return return
} }
......
...@@ -89,9 +89,7 @@ var pkgnames = []string{ ...@@ -89,9 +89,7 @@ var pkgnames = []string{
} }
func TestResolveIdents(t *testing.T) { func TestResolveIdents(t *testing.T) {
if skipTest() { skipSpecialPlatforms(t)
return
}
// parse package files // parse package files
fset := token.NewFileSet() fset := token.NewFileSet()
......
...@@ -32,9 +32,7 @@ var ( ...@@ -32,9 +32,7 @@ var (
) )
func TestStdlib(t *testing.T) { func TestStdlib(t *testing.T) {
if skipTest() { skipSpecialPlatforms(t)
return
}
walkDirs(t, filepath.Join(runtime.GOROOT(), "src")) walkDirs(t, filepath.Join(runtime.GOROOT(), "src"))
if testing.Verbose() { if testing.Verbose() {
...@@ -120,7 +118,11 @@ func testTestDir(t *testing.T, path string, ignore ...string) { ...@@ -120,7 +118,11 @@ func testTestDir(t *testing.T, path string, ignore ...string) {
} }
func TestStdTest(t *testing.T) { 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 return
} }
...@@ -131,9 +133,7 @@ func TestStdTest(t *testing.T) { ...@@ -131,9 +133,7 @@ func TestStdTest(t *testing.T) {
} }
func TestStdFixed(t *testing.T) { func TestStdFixed(t *testing.T) {
if skipTest() { skipSpecialPlatforms(t)
return
}
testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "fixedbugs"), testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "fixedbugs"),
"bug248.go", "bug302.go", "bug369.go", // complex test instructions - ignore "bug248.go", "bug302.go", "bug369.go", // complex test instructions - ignore
...@@ -144,9 +144,7 @@ func TestStdFixed(t *testing.T) { ...@@ -144,9 +144,7 @@ func TestStdFixed(t *testing.T) {
} }
func TestStdKen(t *testing.T) { func TestStdKen(t *testing.T) {
if skipTest() { skipSpecialPlatforms(t)
return
}
testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "ken")) testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "ken"))
} }
......
...@@ -116,9 +116,7 @@ var dependentTestTypes = []testEntry{ ...@@ -116,9 +116,7 @@ var dependentTestTypes = []testEntry{
} }
func TestTypeString(t *testing.T) { func TestTypeString(t *testing.T) {
if skipTest() { skipSpecialPlatforms(t)
return
}
var tests []testEntry var tests []testEntry
tests = append(tests, independentTestTypes...) tests = append(tests, independentTestTypes...)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment