Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 75e52f1

Browse files
committed
Do not fail if SetDeadline is not supported by OS
1 parent 418593d commit 75e52f1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

io_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import (
77
"testing"
88

99
"context"
10+
"errors"
1011
"os"
12+
"runtime"
1113
"sync"
1214
"time"
1315
)
@@ -28,7 +30,11 @@ func TestReadDeadline(t *testing.T) {
2830

2931
err := ptmx.SetDeadline(time.Now().Add(timeout / 10))
3032
if err != nil {
31-
t.Fatalf("error: set deadline: %v\n", err)
33+
if errors.Is(err, os.ErrNoDeadline) {
34+
t.Skipf("deadline is not supported on %s/%s", runtime.GOOS, runtime.GOARCH)
35+
} else {
36+
t.Fatalf("error: set deadline: %v\n", err)
37+
}
3238
}
3339

3440
var buf = make([]byte, 1)
@@ -80,6 +86,7 @@ func prepare(t *testing.T) (ptmx *os.File, done func()) {
8086
t.Cleanup(func() { _ = pts.Close() })
8187

8288
ctx, done := context.WithCancel(context.Background())
89+
t.Cleanup(done)
8390
go func() {
8491
select {
8592
case <-ctx.Done():

0 commit comments

Comments
 (0)