Skip to content

Commit

Permalink
Do not fail if SetDeadline is not supported by OS
Browse files Browse the repository at this point in the history
  • Loading branch information
sio committed Apr 28, 2023
1 parent 418593d commit 75e52f1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion io_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"testing"

"context"
"errors"
"os"
"runtime"
"sync"
"time"
)
Expand All @@ -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)
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 75e52f1

Please sign in to comment.