diff --git a/.vscode/settings.json b/.vscode/settings.json index 4a0ab16e558ed..292ee5cd7c4ad 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -107,6 +107,7 @@ "slogtest", "sourcemapped", "Srcs", + "stdbuf", "stretchr", "STTY", "stuntest", diff --git a/pty/ptytest/ptytest.go b/pty/ptytest/ptytest.go index 635176a155a67..bc26585f2962a 100644 --- a/pty/ptytest/ptytest.go +++ b/pty/ptytest/ptytest.go @@ -72,8 +72,13 @@ func create(t *testing.T, ptty pty.PTY, name string) *PTY { ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort) defer cancel() - _ = out.Close() - _ = ptty.Close() + // Close pty only so that the copy goroutine can consume the + // remainder of it's buffer and then exit. + err := ptty.Close() + // Pty may already be closed, so don't fail the test, but log + // the error in case it's significant. + logf(t, name, "closed pty: %v", err) + select { case <-ctx.Done(): fatalf(t, name, "cleanup", "copy did not close in time")