Skip to content

Commit

Permalink
Clean out env passed to wasmbrowsertest in TestWasm
Browse files Browse the repository at this point in the history
  • Loading branch information
mafredri committed Aug 15, 2024
1 parent 418f92e commit 30b8480
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,26 @@ func TestWasm(t *testing.T) {
defer cancel()

cmd := exec.CommandContext(ctx, "go", "test", "-exec=wasmbrowsertest", ".", "-v")
cmd.Env = append(os.Environ(), "GOOS=js", "GOARCH=wasm", fmt.Sprintf("WS_ECHO_SERVER_URL=%v", s.URL))
cmd.Env = append(cleanEnv(os.Environ()), "GOOS=js", "GOARCH=wasm", fmt.Sprintf("WS_ECHO_SERVER_URL=%v", s.URL))

b, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("wasm test binary failed: %v:\n%s", err, b)
}
}

func cleanEnv(env []string) (out []string) {
for _, e := range env {
// Filter out anything with token in it, especially GITHUB_TOKEN
// in CI as it breaks TestWasm.
if strings.Contains(e, "TOKEN") {
continue
}
out = append(out, e)
}
return out
}

func assertCloseStatus(exp websocket.StatusCode, err error) error {
if websocket.CloseStatus(err) == -1 {
return fmt.Errorf("expected websocket.CloseError: %T %v", err, err)
Expand Down

0 comments on commit 30b8480

Please sign in to comment.