From ac00452023d5dbc090c7513072cfad9958f2e3a9 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Mon, 4 Dec 2017 12:18:06 -0500 Subject: [PATCH] Fix TestClose for Go10. Depending on the Go version used, reading from a closed pipe can return net.OpError or io.ErrClosedPipe. Simply check the string content of the error. --- cmux_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmux_test.go b/cmux_test.go index 266fe6f..55e297f 100644 --- a/cmux_test.go +++ b/cmux_test.go @@ -659,7 +659,9 @@ func TestClose(t *testing.T) { if err != ErrListenerClosed { t.Fatal(err) } - if _, err := c2.Read([]byte{}); err != io.ErrClosedPipe { + // The error is either io.ErrClosedPipe or net.OpError wrapping + // a net.pipeError depending on the go version. + if _, err := c2.Read([]byte{}); !strings.Contains(err.Error(), "closed") { t.Fatalf("connection is not closed and is leaked: %v", err) } }