Skip to content

Commit d85d44f

Browse files
committed
Remove separate script for wasm tests
1 parent bc4fce0 commit d85d44f

File tree

4 files changed

+37
-80
lines changed

4 files changed

+37
-80
lines changed

ci/test.mk

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
test: gotest gotest-wasm
1+
test: gotest
22

33
gotest: _gotest htmlcov
44
ifdef CI
@@ -12,15 +12,8 @@ codecov: _gotest
1212
curl -s https://codecov.io/bash | bash -s -- -Z -f ci/out/coverage.prof
1313

1414
_gotest:
15-
echo "--- gotest" && go test -parallel=32 -coverprofile=ci/out/coverage.prof -coverpkg=./... $$TESTFLAGS ./...
15+
go test -parallel=32 -coverprofile=ci/out/coverage.prof -coverpkg=./... $$TESTFLAGS ./...
1616
sed -i '/_stringer\.go/d' ci/out/coverage.prof
17-
sed -i '/wsjstest\/main\.go/d' ci/out/coverage.prof
1817
sed -i '/wsecho\.go/d' ci/out/coverage.prof
1918
sed -i '/assert\.go/d' ci/out/coverage.prof
2019
sed -i '/wsgrace\.go/d' ci/out/coverage.prof
21-
22-
gotest-wasm: wsjstest
23-
echo "--- wsjstest" && ./ci/wasmtest.sh
24-
25-
wsjstest:
26-
go install ./internal/wsjstest

ci/wasmtest.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

conn_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,3 +2337,38 @@ func checkWSTestIndex(t *testing.T, path string) {
23372337
}
23382338
}
23392339
}
2340+
2341+
func TestWASM(t *testing.T) {
2342+
t.Parallel()
2343+
2344+
s, closeFn := testServer(t, func(w http.ResponseWriter, r *http.Request) error {
2345+
c, err := websocket.Accept(w, r, &websocket.AcceptOptions{
2346+
Subprotocols: []string{"echo"},
2347+
InsecureSkipVerify: true,
2348+
})
2349+
if err != nil {
2350+
return err
2351+
}
2352+
defer c.Close(websocket.StatusInternalError, "")
2353+
2354+
err = wsecho.Loop(r.Context(), c)
2355+
if websocket.CloseStatus(err) != websocket.StatusNormalClosure {
2356+
return err
2357+
}
2358+
return nil
2359+
}, false)
2360+
defer closeFn()
2361+
2362+
wsURL := strings.Replace(s.URL, "http", "ws", 1)
2363+
2364+
ctx, cancel := context.WithTimeout(context.Background(), time.Second*20)
2365+
defer cancel()
2366+
2367+
cmd := exec.CommandContext(ctx, "go", "test", "-exec=wasmbrowsertest", "./...")
2368+
cmd.Env = append(os.Environ(), "GOOS=js", "GOARCH=wasm", fmt.Sprintf("WS_ECHO_SERVER_URL=%v", wsURL))
2369+
2370+
b, err := cmd.CombinedOutput()
2371+
if err != nil {
2372+
t.Fatalf("wasm test binary failed: %v:\n%s", err, b)
2373+
}
2374+
}

internal/wsjstest/main.go

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)