diff --git a/cmd/pkgsite/main_test.go b/cmd/pkgsite/main_test.go index deac8004e..704a425e5 100644 --- a/cmd/pkgsite/main_test.go +++ b/cmd/pkgsite/main_test.go @@ -17,6 +17,7 @@ import ( "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 @@ var ( ) 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 77fe56ba0..366bda3da 100644 --- a/internal/fetch/getters_test.go +++ b/internal/fetch/getters_test.go @@ -17,6 +17,7 @@ import ( "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 @@ const Log = 1 ` 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(t *testing.T) { } 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 d913ad781..ae14bf60c 100644 --- a/internal/fetchdatasource/fetchdatasource_test.go +++ b/internal/fetchdatasource/fetchdatasource_test.go @@ -32,15 +32,11 @@ import ( 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 buildLocalGetters() ([]fetch.ModuleGetter, func()) { 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 @@ func setup(t *testing.T, testModules []*proxytest.Module, bypassLicenseCheck boo 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 @@ func setup(t *testing.T, testModules []*proxytest.Module, bypassLicenseCheck boo ProxyClientForLatest: client, BypassLicenseCheck: bypassLicenseCheck, }.New(), func() { + cleanup() teardownProxy() cancel() } diff --git a/internal/source/source_test.go b/internal/source/source_test.go index 5343ae836..d9276fcfe 100644 --- a/internal/source/source_test.go +++ b/internal/source/source_test.go @@ -13,6 +13,7 @@ import ( "net/http" "os" "path/filepath" + "runtime" "strings" "testing" @@ -489,6 +490,9 @@ func TestNewStdlibInfo(t *testing.T) { } 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()