Skip to content

fix: Rewrite ptytest to buffer stdout #3170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 25, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: Ensure goroutine cleanup
  • Loading branch information
mafredri committed Jul 25, 2022
commit 372f60cb09c0e6e743df59fe6c1523d78f3a3162
3 changes: 3 additions & 0 deletions pty/ptytest/ptytest.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ func (p *PTY) ExpectMatch(str string) string {
p.t.Logf("%s: matched %q = %q", time.Now(), str, buffer.String())
return buffer.String()
case <-timeout.Done():
// Ensure goroutine is cleaned up before test exit.
_ = p.out.closeErr(p.Close())
<-match

p.t.Fatalf("%s: match exceeded deadline: wanted %q; got %q", time.Now(), str, buffer.String())
return ""
}
Expand Down