_ "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) {
}
func TestPredicatesInfo(t *testing.T) {
- if skipTest() {
- return
- }
+ skipSpecialPlatforms(t)
var tests = []struct {
src string
}
func TestScopesInfo(t *testing.T) {
- if skipTest() {
- return
- }
+ skipSpecialPlatforms(t)
var tests = []struct {
src string
}
func TestCheck(t *testing.T) {
- if skipTest() {
- return
- }
+ skipSpecialPlatforms(t)
// Declare builtins for testing.
DefPredeclaredTestFuncs()
}
func TestEvalContext(t *testing.T) {
- if skipTest() {
- return
- }
+ skipSpecialPlatforms(t)
src := `
package p
"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
}
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
}
}
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 {
}
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
}
// 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
}
}
func TestResolveIdents(t *testing.T) {
- if skipTest() {
- return
- }
+ skipSpecialPlatforms(t)
// parse package files
fset := token.NewFileSet()
)
func TestStdlib(t *testing.T) {
- if skipTest() {
- return
- }
+ skipSpecialPlatforms(t)
walkDirs(t, filepath.Join(runtime.GOROOT(), "src"))
if testing.Verbose() {
}
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
}
}
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
}
func TestStdKen(t *testing.T) {
- if skipTest() {
- return
- }
+ skipSpecialPlatforms(t)
testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "ken"))
}
}
func TestTypeString(t *testing.T) {
- if skipTest() {
- return
- }
+ skipSpecialPlatforms(t)
var tests []testEntry
tests = append(tests, independentTestTypes...)