Skip to content

Commit

Permalink
all: skip tests that can't run on wasm platforms
Browse files Browse the repository at this point in the history
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 <[email protected]>
Run-TryBot: Michael Matloob <[email protected]>
kokoro-CI: kokoro <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
  • Loading branch information
matloob committed Aug 31, 2023
1 parent 06e1679 commit 67eeede
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions cmd/pkgsite/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions internal/fetch/getters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 3 additions & 5 deletions internal/fetchdatasource/fetchdatasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down Expand Up @@ -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
Expand All @@ -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()))
}
Expand All @@ -135,6 +132,7 @@ func setup(t *testing.T, testModules []*proxytest.Module, bypassLicenseCheck boo
ProxyClientForLatest: client,
BypassLicenseCheck: bypassLicenseCheck,
}.New(), func() {
cleanup()
teardownProxy()
cancel()
}
Expand Down
4 changes: 4 additions & 0 deletions internal/source/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"net/http"
"os"
"path/filepath"
"runtime"
"strings"
"testing"

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 67eeede

Please sign in to comment.