Skip to content

Commit

Permalink
cmd/gosh: use an os.Pipe in another interactive test
Browse files Browse the repository at this point in the history
The writer didn't close the pipe, so the runner would sometimes hang
waiting for the writer to be finished. Switch to os.Pipe while here too.
  • Loading branch information
mvdan committed Aug 8, 2024
1 parent bced200 commit b701811
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmd/gosh/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,13 @@ func TestInteractive(t *testing.T) {
}

func TestInteractiveExit(t *testing.T) {
inReader, inWriter := io.Pipe()
inReader, inWriter, err := os.Pipe()
qt.Assert(t, qt.IsNil(err))
defer inReader.Close()
go io.WriteString(inWriter, "exit\n")
go func() {
io.WriteString(inWriter, "exit\n")
inWriter.Close()
}()
w := io.Discard
runner, _ := interp.New(interp.StdIO(inReader, w, w))
if err := runInteractive(runner, inReader, w, w); err != nil {
Expand Down

0 comments on commit b701811

Please sign in to comment.