Skip to content

Commit 54fbc44

Browse files
committed
Clean out env passed to wasmbrowsertest in TestWasm
1 parent 418f92e commit 54fbc44

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

conn_test.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,25 @@ func TestWasm(t *testing.T) {
364364
defer cancel()
365365

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

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

375+
func cleanEnv(env []string) (out []string) {
376+
for _, e := range env {
377+
// Filter out anything with token in it, especially GITHUB_TOKEN
378+
// in CI as it breaks TestWasm.
379+
if strings.Contains(e, "TOKEN") {
380+
continue
381+
}
382+
out = append(out, e)
383+
}
384+
return out
385+
375386
func assertCloseStatus(exp websocket.StatusCode, err error) error {
376387
if websocket.CloseStatus(err) == -1 {
377388
return fmt.Errorf("expected websocket.CloseError: %T %v", err, err)

0 commit comments

Comments
 (0)