Skip to content

Commit dee24ac

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

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

conn_test.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,26 @@ 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 GITHUB envs and anything with token in it,
378+
// especially GITHUB_TOKEN in CI as it breaks TestWasm.
379+
if strings.HasPrefix(e, "GITHUB") || strings.Contains(e, "TOKEN") {
380+
continue
381+
}
382+
out = append(out, e)
383+
}
384+
return out
385+
}
386+
375387
func assertCloseStatus(exp websocket.StatusCode, err error) error {
376388
if websocket.CloseStatus(err) == -1 {
377389
return fmt.Errorf("expected websocket.CloseError: %T %v", err, err)

0 commit comments

Comments
 (0)