From d12fb3213d95425a9c2ea3086878ee8d1a5e7c32 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Tue, 30 Mar 2021 19:32:16 +0700 Subject: [PATCH] fix the lazy stress read test on Windows --- multistream_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/multistream_test.go b/multistream_test.go index 31380e6..dfe03ef 100644 --- a/multistream_test.go +++ b/multistream_test.go @@ -150,7 +150,7 @@ func TestProtocolNegotiationLazy(t *testing.T) { } func TestNegLazyStressRead(t *testing.T) { - const count = 100 + const count = 75 mux := NewMultistreamMuxer() mux.AddHandler("/a", nil) @@ -159,7 +159,9 @@ func TestNegLazyStressRead(t *testing.T) { message := []byte("this is the message") listener := make(chan io.ReadWriteCloser) + done := make(chan struct{}) go func() { + defer close(done) for rwc := range listener { m, selected, _, err := mux.NegotiateLazy(rwc) if err != nil { @@ -185,7 +187,6 @@ func TestNegLazyStressRead(t *testing.T) { rwc.Close() } }() - defer func() { close(listener) }() for i := 0; i < count; i++ { a, b := newPipe(t) @@ -198,8 +199,10 @@ func TestNegLazyStressRead(t *testing.T) { t.Fatal(err) } - b.Close() + defer b.Close() } + close(listener) + <-done } func TestNegLazyStressWrite(t *testing.T) {