From b701811cd94bd389d1f01cb947e2891e46dd0e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 8 Aug 2024 12:26:27 +0100 Subject: [PATCH] cmd/gosh: use an os.Pipe in another interactive test 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. --- cmd/gosh/main_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/gosh/main_test.go b/cmd/gosh/main_test.go index 397b8282..da7b1a0e 100644 --- a/cmd/gosh/main_test.go +++ b/cmd/gosh/main_test.go @@ -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 {