github.com/markusbkk/elvish@v0.0.0-20231204143114-91dc52438621/pkg/sys/eunix/waitforread_test.go (about) 1 //go:build !windows && !plan9 2 // +build !windows,!plan9 3 4 package eunix 5 6 import ( 7 "io" 8 "testing" 9 10 "github.com/markusbkk/elvish/pkg/testutil" 11 ) 12 13 func TestWaitForRead(t *testing.T) { 14 r0, w0 := testutil.MustPipe() 15 r1, w1 := testutil.MustPipe() 16 defer closeAll(r0, w0, r1, w1) 17 18 w0.WriteString("x") 19 ready, err := WaitForRead(-1, r0, r1) 20 if err != nil { 21 t.Error("WaitForRead errors:", err) 22 } 23 if !ready[0] { 24 t.Error("Want ready[0]") 25 } 26 if ready[1] { 27 t.Error("Don't want ready[1]") 28 } 29 } 30 31 func closeAll(files ...io.Closer) { 32 for _, file := range files { 33 file.Close() 34 } 35 }