all: skip tests that can't run on wasm platforms
Some because the network support isn't enough for httpreplay, and some
because we need the Go command.
For golang/go#61209
Change-Id: I02c6b7d10553d931c746723ce9608f39834c131c
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/524797
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
kokoro-CI: kokoro <noreply+kokoro@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/cmd/pkgsite/main_test.go b/cmd/pkgsite/main_test.go
index deac800..704a425 100644
--- a/cmd/pkgsite/main_test.go
+++ b/cmd/pkgsite/main_test.go
@@ -17,6 +17,7 @@
"github.com/google/go-cmp/cmp"
"golang.org/x/net/html"
"golang.org/x/pkgsite/internal/proxy/proxytest"
+ "golang.org/x/pkgsite/internal/testenv"
"golang.org/x/pkgsite/internal/testing/htmlcheck"
"golang.org/x/pkgsite/internal/testing/testhelper"
)
@@ -33,6 +34,8 @@
)
func TestServer(t *testing.T) {
+ testenv.MustHaveExecPath(t, "go") // for local modules
+
repoPath := func(fn string) string { return filepath.Join("..", "..", fn) }
abs := func(dir string) string {
diff --git a/internal/fetch/getters_test.go b/internal/fetch/getters_test.go
index 77fe56b..366bda3 100644
--- a/internal/fetch/getters_test.go
+++ b/internal/fetch/getters_test.go
@@ -17,6 +17,7 @@
"github.com/google/go-cmp/cmp"
"golang.org/x/pkgsite/internal/derrors"
"golang.org/x/pkgsite/internal/proxy"
+ "golang.org/x/pkgsite/internal/testenv"
"golang.org/x/pkgsite/internal/testing/testhelper"
"golang.org/x/pkgsite/internal/version"
)
@@ -64,6 +65,8 @@
`
func TestGoPackagesModuleGetter(t *testing.T) {
+ testenv.MustHaveExecPath(t, "go")
+
modulePaths := map[string]string{ // dir -> module path
"foo": "foo.com/foo",
"bar": "bar.com/bar",
@@ -156,6 +159,8 @@
}
func TestGoPackagesModuleGetter_Invalidation(t *testing.T) {
+ testenv.MustHaveExecPath(t, "go")
+
ctx := context.Background()
tempDir, _ := testhelper.WriteTxtarToTempDir(t, multiModule)
diff --git a/internal/fetchdatasource/fetchdatasource_test.go b/internal/fetchdatasource/fetchdatasource_test.go
index d913ad7..ae14bf6 100644
--- a/internal/fetchdatasource/fetchdatasource_test.go
+++ b/internal/fetchdatasource/fetchdatasource_test.go
@@ -32,15 +32,11 @@
var (
defaultTestModules []*proxytest.Module
- localGetters []fetch.ModuleGetter
)
func TestMain(m *testing.M) {
dochtml.LoadTemplates(template.TrustedFSFromTrustedSource(template.TrustedSourceFromConstant("../../static")))
defaultTestModules = proxytest.LoadTestModules("../proxy/testdata")
- var cleanup func()
- localGetters, cleanup = buildLocalGetters()
- defer cleanup()
licenses.OmitExceptions = true
os.Exit(m.Run())
}
@@ -117,6 +113,7 @@
func setup(t *testing.T, testModules []*proxytest.Module, bypassLicenseCheck bool) (context.Context, *FetchDataSource, func()) {
t.Helper()
+ testenv.MustHaveExecPath(t, "go") // for the go packages module getter.
ctx, cancel := context.WithCancel(context.Background())
var client *proxy.Client
@@ -125,7 +122,7 @@
client, teardownProxy = proxytest.SetupTestClient(t, testModules)
}
- getters := localGetters
+ getters, cleanup := buildLocalGetters()
if testModules != nil {
getters = append(getters, fetch.NewProxyModuleGetter(client, source.NewClientForTesting()))
}
@@ -135,6 +132,7 @@
ProxyClientForLatest: client,
BypassLicenseCheck: bypassLicenseCheck,
}.New(), func() {
+ cleanup()
teardownProxy()
cancel()
}
diff --git a/internal/source/source_test.go b/internal/source/source_test.go
index 5343ae8..d9276fc 100644
--- a/internal/source/source_test.go
+++ b/internal/source/source_test.go
@@ -13,6 +13,7 @@
"net/http"
"os"
"path/filepath"
+ "runtime"
"strings"
"testing"
@@ -489,6 +490,9 @@
}
func newReplayClient(t *testing.T, record bool) (*http.Client, func()) {
+ if runtime.GOOS == "js" || runtime.GOOS == "wasip1" {
+ t.Skipf("skipping test: see issue #59718: listen on localhost fails on %s", runtime.GOOS)
+ }
replayFilePath := filepath.Join("testdata", t.Name()+".replay")
if record {
httpreplay.DebugHeaders()