diff --git a/go/gcimporter/gcimporter.go b/go/gcimporter/gcimporter.go index 5df01a73..0d25e8cc 100644 --- a/go/gcimporter/gcimporter.go +++ b/go/gcimporter/gcimporter.go @@ -30,7 +30,7 @@ func init() { types.DefaultImport = Import } -var pkgExts = [...]string{".a", ".5", ".6", ".8"} +var pkgExts = [...]string{".a", ".5", ".6", ".7", ".8", ".9"} // FindPkg returns the filename and unique package id for an import // path based on package information provided by build.Import (using diff --git a/go/gcimporter/gcimporter_test.go b/go/gcimporter/gcimporter_test.go index a20853ac..31d07feb 100644 --- a/go/gcimporter/gcimporter_test.go +++ b/go/gcimporter/gcimporter_test.go @@ -18,23 +18,27 @@ import ( "golang.org/x/tools/go/types" ) +// 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", + "nacl-386", + "darwin-arm", + "darwin-arm64": + t.Skipf("no compiled packages available for import on %s", platform) + } +} + var gcPath string // Go compiler path func init() { - // determine compiler - var gc string - switch runtime.GOARCH { - case "386": - gc = "8g" - case "amd64": - gc = "6g" - case "arm": - gc = "5g" - default: - gcPath = "unknown-GOARCH-compiler" + if char, err := build.ArchChar(runtime.GOARCH); err == nil { + gcPath = filepath.Join(build.ToolDir, char+"g") return } - gcPath = filepath.Join(build.ToolDir, gc) + gcPath = "unknown-GOARCH-compiler" } func compile(t *testing.T, dirname, filename string) string { @@ -97,8 +101,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 } @@ -133,10 +138,14 @@ var importedObjectTests = []struct { } func TestImportedTypes(t *testing.T) { - // This package does not handle gccgo export data. - if runtime.Compiler == "gccgo" { + skipSpecialPlatforms(t) + + // 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 { @@ -165,8 +174,11 @@ func TestImportedTypes(t *testing.T) { } func TestIssue5815(t *testing.T) { - // This package does not handle gccgo export data. - if runtime.Compiler == "gccgo" { + skipSpecialPlatforms(t) + + // This package only handles gc export data. + if runtime.Compiler != "gc" { + t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) return } @@ -195,8 +207,11 @@ func TestIssue5815(t *testing.T) { // Smoke test to ensure that imported methods get the correct package. func TestCorrectMethodPackage(t *testing.T) { - // This package does not handle gccgo export data. - if runtime.Compiler == "gccgo" { + skipSpecialPlatforms(t) + + // This package only handles gc export data. + if runtime.Compiler != "gc" { + t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) return } diff --git a/go/types/api_test.go b/go/types/api_test.go index 57f7edc7..02487bf2 100644 --- a/go/types/api_test.go +++ b/go/types/api_test.go @@ -10,6 +10,7 @@ import ( "go/ast" "go/parser" "go/token" + "runtime" "strings" "testing" @@ -17,6 +18,19 @@ import ( . "golang.org/x/tools/go/types" ) +// 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", + "nacl-386", + "darwin-arm", + "darwin-arm64": + t.Skipf("no compiled packages available for import on %s", platform) + } +} + func pkgFor(path, source string, info *Info) (*Package, error) { fset := token.NewFileSet() f, err := parser.ParseFile(fset, path, source, 0) @@ -284,6 +298,8 @@ func predString(tv TypeAndValue) string { } func TestPredicatesInfo(t *testing.T) { + skipSpecialPlatforms(t) + var tests = []struct { src string expr string @@ -368,6 +384,8 @@ func TestPredicatesInfo(t *testing.T) { } func TestScopesInfo(t *testing.T) { + skipSpecialPlatforms(t) + var tests = []struct { src string scopes []string // list of scope descriptors of the form kind:varlist diff --git a/go/types/check_test.go b/go/types/check_test.go index aefaa5a6..b6caccb3 100644 --- a/go/types/check_test.go +++ b/go/types/check_test.go @@ -278,6 +278,8 @@ func checkFiles(t *testing.T, testfiles []string) { } func TestCheck(t *testing.T) { + skipSpecialPlatforms(t) + // Declare builtins for testing. DefPredeclaredTestFuncs() diff --git a/go/types/eval_test.go b/go/types/eval_test.go index 40d70ac8..6e17b952 100644 --- a/go/types/eval_test.go +++ b/go/types/eval_test.go @@ -83,6 +83,8 @@ func TestEvalArith(t *testing.T) { } func TestEvalContext(t *testing.T) { + skipSpecialPlatforms(t) + src := ` package p import "fmt" diff --git a/go/types/resolver_test.go b/go/types/resolver_test.go index d8af7a01..6ad1c34d 100644 --- a/go/types/resolver_test.go +++ b/go/types/resolver_test.go @@ -89,6 +89,8 @@ var pkgnames = []string{ } func TestResolveIdents(t *testing.T) { + skipSpecialPlatforms(t) + // parse package files fset := token.NewFileSet() var files []*ast.File diff --git a/go/types/stdlib_test.go b/go/types/stdlib_test.go index 2e83a435..363bb6fb 100644 --- a/go/types/stdlib_test.go +++ b/go/types/stdlib_test.go @@ -32,6 +32,8 @@ var ( ) func TestStdlib(t *testing.T) { + skipSpecialPlatforms(t) + walkDirs(t, filepath.Join(runtime.GOROOT(), "src")) if testing.Verbose() { fmt.Println(pkgCount, "packages typechecked in", time.Since(start)) @@ -116,6 +118,14 @@ func testTestDir(t *testing.T, path string, ignore ...string) { } func TestStdTest(t *testing.T) { + 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 + } + testTestDir(t, filepath.Join(runtime.GOROOT(), "test"), "cmplxdivide.go", // also needs file cmplxdivide1.go - ignore "sigchld.go", // don't work on Windows; testTestDir should consult build tags @@ -123,6 +133,8 @@ func TestStdTest(t *testing.T) { } func TestStdFixed(t *testing.T) { + skipSpecialPlatforms(t) + testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "fixedbugs"), "bug248.go", "bug302.go", "bug369.go", // complex test instructions - ignore "bug459.go", // possibly incorrect test - see issue 6703 (pending spec clarification) @@ -132,6 +144,8 @@ func TestStdFixed(t *testing.T) { } func TestStdKen(t *testing.T) { + skipSpecialPlatforms(t) + testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "ken")) } diff --git a/go/types/typestring_test.go b/go/types/typestring_test.go index 9aacf855..8693687c 100644 --- a/go/types/typestring_test.go +++ b/go/types/typestring_test.go @@ -116,6 +116,8 @@ var dependentTestTypes = []testEntry{ } func TestTypeString(t *testing.T) { + skipSpecialPlatforms(t) + var tests []testEntry tests = append(tests, independentTestTypes...) tests = append(tests, dependentTestTypes...)