From 3a1271dad7617a9766d21987b2c3cc0e683d2010 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Wed, 8 Mar 2017 22:54:52 +0100 Subject: [PATCH] go/internal/srcimporter: skip tests on iOS The iOS test harness only includes the current test directory in its app bundles, but the tests need access to all source code. Change-Id: I8a902b183bc2745b4fbfffef867002d573abb1f5 Reviewed-on: https://go-review.googlesource.com/37961 Run-TryBot: Elias Naur TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/go/internal/srcimporter/srcimporter_test.go | 6 +++--- src/internal/testenv/testenv.go | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/go/internal/srcimporter/srcimporter_test.go b/src/go/internal/srcimporter/srcimporter_test.go index f289bfb44b..79921b5e78 100644 --- a/src/go/internal/srcimporter/srcimporter_test.go +++ b/src/go/internal/srcimporter/srcimporter_test.go @@ -76,7 +76,7 @@ func walkDir(t *testing.T, path string, endTime time.Time) (int, bool) { } func TestImportStdLib(t *testing.T) { - if runtime.GOOS == "nacl" { + if !testenv.HasSrc() { t.Skip("no source code available") } @@ -102,7 +102,7 @@ var importedObjectTests = []struct { } func TestImportedTypes(t *testing.T) { - if runtime.GOOS == "nacl" { + if !testenv.HasSrc() { t.Skip("no source code available") } @@ -134,7 +134,7 @@ func TestImportedTypes(t *testing.T) { } func TestReimport(t *testing.T) { - if runtime.GOOS == "nacl" { + if !testenv.HasSrc() { t.Skip("no source code available") } diff --git a/src/internal/testenv/testenv.go b/src/internal/testenv/testenv.go index 10384b6206..4cd8a2b541 100644 --- a/src/internal/testenv/testenv.go +++ b/src/internal/testenv/testenv.go @@ -114,6 +114,19 @@ func HasExec() bool { return true } +// HasSrc reports whether the entire source tree is available under GOROOT. +func HasSrc() bool { + switch runtime.GOOS { + case "nacl": + return false + case "darwin": + if strings.HasPrefix(runtime.GOARCH, "arm") { + return false + } + } + return true +} + // MustHaveExec checks that the current system can start new processes // using os.StartProcess or (more commonly) exec.Command. // If not, MustHaveExec calls t.Skip with an explanation.