Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f8c1853

Browse files
Merge pull request #469 from coder/mafredri/fix-coverage4
Clean out env passed to wasmbrowsertest in TestWasm
2 parents 418f92e + dee24ac commit f8c1853

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

‎conn_test.go

Lines changed: 13 additions & 1 deletion
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)

AltStyle によって変換されたページ (->オリジナル) /