Commit 8fa1a69f authored by Robert Griesemer's avatar Robert Griesemer

go/types: use testenv.MustHaveGoBuild to exclude some builds

Replace custom solution with new (internal) library call.

Change-Id: I53b26a1caf0684b9f5d8d749b10d9f3ba18a3001
Reviewed-on: https://go-review.googlesource.com/11193Reviewed-by: 's avatarDamien Neil <dneil@google.com>
parent bc7a3a62
...@@ -11,27 +11,13 @@ import ( ...@@ -11,27 +11,13 @@ import (
"go/importer" "go/importer"
"go/parser" "go/parser"
"go/token" "go/token"
"runtime" "internal/testenv"
"strings" "strings"
"testing" "testing"
. "go/types" . "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",
"nacl-arm",
"darwin-arm",
"darwin-arm64":
t.Skipf("no compiled packages available for import on %s", platform)
}
}
func pkgFor(path, source string, info *Info) (*Package, error) { func pkgFor(path, source string, info *Info) (*Package, error) {
fset := token.NewFileSet() fset := token.NewFileSet()
f, err := parser.ParseFile(fset, path, source, 0) f, err := parser.ParseFile(fset, path, source, 0)
...@@ -299,7 +285,7 @@ func predString(tv TypeAndValue) string { ...@@ -299,7 +285,7 @@ func predString(tv TypeAndValue) string {
} }
func TestPredicatesInfo(t *testing.T) { func TestPredicatesInfo(t *testing.T) {
skipSpecialPlatforms(t) testenv.MustHaveGoBuild(t)
var tests = []struct { var tests = []struct {
src string src string
...@@ -385,7 +371,7 @@ func TestPredicatesInfo(t *testing.T) { ...@@ -385,7 +371,7 @@ func TestPredicatesInfo(t *testing.T) {
} }
func TestScopesInfo(t *testing.T) { func TestScopesInfo(t *testing.T) {
skipSpecialPlatforms(t) testenv.MustHaveGoBuild(t)
var tests = []struct { var tests = []struct {
src string src string
......
...@@ -32,6 +32,7 @@ import ( ...@@ -32,6 +32,7 @@ import (
"go/parser" "go/parser"
"go/scanner" "go/scanner"
"go/token" "go/token"
"internal/testenv"
"io/ioutil" "io/ioutil"
"regexp" "regexp"
"strings" "strings"
...@@ -279,7 +280,7 @@ func checkFiles(t *testing.T, testfiles []string) { ...@@ -279,7 +280,7 @@ func checkFiles(t *testing.T, testfiles []string) {
} }
func TestCheck(t *testing.T) { func TestCheck(t *testing.T) {
skipSpecialPlatforms(t) testenv.MustHaveGoBuild(t)
// Declare builtins for testing. // Declare builtins for testing.
DefPredeclaredTestFuncs() DefPredeclaredTestFuncs()
......
...@@ -11,6 +11,7 @@ import ( ...@@ -11,6 +11,7 @@ import (
"go/importer" "go/importer"
"go/parser" "go/parser"
"go/token" "go/token"
"internal/testenv"
"strings" "strings"
"testing" "testing"
...@@ -86,7 +87,7 @@ func TestEvalArith(t *testing.T) { ...@@ -86,7 +87,7 @@ func TestEvalArith(t *testing.T) {
} }
func TestEvalPos(t *testing.T) { func TestEvalPos(t *testing.T) {
skipSpecialPlatforms(t) testenv.MustHaveGoBuild(t)
// The contents of /*-style comments are of the form // The contents of /*-style comments are of the form
// expr => value, type // expr => value, type
......
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
"go/importer" "go/importer"
"go/parser" "go/parser"
"go/token" "go/token"
"internal/testenv"
"sort" "sort"
"testing" "testing"
...@@ -35,7 +36,7 @@ func (imp *resolveTestImporter) Import(path string) (*Package, error) { ...@@ -35,7 +36,7 @@ func (imp *resolveTestImporter) Import(path string) (*Package, error) {
} }
func TestResolveIdents(t *testing.T) { func TestResolveIdents(t *testing.T) {
skipSpecialPlatforms(t) testenv.MustHaveGoBuild(t)
sources := []string{ sources := []string{
` `
......
...@@ -15,6 +15,7 @@ import ( ...@@ -15,6 +15,7 @@ import (
"go/parser" "go/parser"
"go/scanner" "go/scanner"
"go/token" "go/token"
"internal/testenv"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
...@@ -36,7 +37,7 @@ var ( ...@@ -36,7 +37,7 @@ var (
) )
func TestStdlib(t *testing.T) { func TestStdlib(t *testing.T) {
skipSpecialPlatforms(t) testenv.MustHaveGoBuild(t)
start = time.Now() start = time.Now()
walkDirs(t, filepath.Join(runtime.GOROOT(), "src")) walkDirs(t, filepath.Join(runtime.GOROOT(), "src"))
...@@ -124,7 +125,7 @@ func testTestDir(t *testing.T, path string, ignore ...string) { ...@@ -124,7 +125,7 @@ func testTestDir(t *testing.T, path string, ignore ...string) {
} }
func TestStdTest(t *testing.T) { func TestStdTest(t *testing.T) {
skipSpecialPlatforms(t) testenv.MustHaveGoBuild(t)
// test/recover4.go is only built for Linux and Darwin. // test/recover4.go is only built for Linux and Darwin.
// TODO(gri) Remove once tests consider +build tags (issue 10370). // TODO(gri) Remove once tests consider +build tags (issue 10370).
...@@ -139,7 +140,7 @@ func TestStdTest(t *testing.T) { ...@@ -139,7 +140,7 @@ func TestStdTest(t *testing.T) {
} }
func TestStdFixed(t *testing.T) { func TestStdFixed(t *testing.T) {
skipSpecialPlatforms(t) testenv.MustHaveGoBuild(t)
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
...@@ -151,7 +152,7 @@ func TestStdFixed(t *testing.T) { ...@@ -151,7 +152,7 @@ func TestStdFixed(t *testing.T) {
} }
func TestStdKen(t *testing.T) { func TestStdKen(t *testing.T) {
skipSpecialPlatforms(t) testenv.MustHaveGoBuild(t)
testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "ken")) testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "ken"))
} }
......
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"go/importer" "go/importer"
"go/parser" "go/parser"
"go/token" "go/token"
"internal/testenv"
"testing" "testing"
. "go/types" . "go/types"
...@@ -117,7 +118,7 @@ var dependentTestTypes = []testEntry{ ...@@ -117,7 +118,7 @@ var dependentTestTypes = []testEntry{
} }
func TestTypeString(t *testing.T) { func TestTypeString(t *testing.T) {
skipSpecialPlatforms(t) testenv.MustHaveGoBuild(t)
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