From 75e52f11032651aed206bc5116bf6f2914c46a2a Mon Sep 17 00:00:00 2001 From: Vitaly Potyarkin Date: Fri, 28 Apr 2023 10:23:52 +0000 Subject: [PATCH] Do not fail if SetDeadline is not supported by OS --- io_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/io_test.go b/io_test.go index 57fbd3d..5884665 100644 --- a/io_test.go +++ b/io_test.go @@ -7,7 +7,9 @@ import ( "testing" "context" + "errors" "os" + "runtime" "sync" "time" ) @@ -28,7 +30,11 @@ func TestReadDeadline(t *testing.T) { err := ptmx.SetDeadline(time.Now().Add(timeout / 10)) if err != nil { - t.Fatalf("error: set deadline: %v\n", err) + if errors.Is(err, os.ErrNoDeadline) { + t.Skipf("deadline is not supported on %s/%s", runtime.GOOS, runtime.GOARCH) + } else { + t.Fatalf("error: set deadline: %v\n", err) + } } var buf = make([]byte, 1) @@ -80,6 +86,7 @@ func prepare(t *testing.T) (ptmx *os.File, done func()) { t.Cleanup(func() { _ = pts.Close() }) ctx, done := context.WithCancel(context.Background()) + t.Cleanup(done) go func() { select { case <-ctx.Done():