2
0
mirror of https://github.com/soheilhy/cmux.git synced 2024-11-10 03:31:52 +08:00

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.
This commit is contained in:
Soheil Hassas Yeganeh 2017-12-04 12:18:06 -05:00 committed by Soheil Hassas Yeganeh
parent bb79a83465
commit b9e684ba4e

View File

@ -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)
}
}