From bb5f79cd0d3766d07833b8f0fbe53d5235f0c566 Mon Sep 17 00:00:00 2001 From: Weidi Deng Date: Sat, 9 Dec 2023 09:18:31 +0800 Subject: [PATCH 1/3] re-enable non-blocking tests --- io_test.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/io_test.go b/io_test.go index 4f3d8a8..2d88a50 100644 --- a/io_test.go +++ b/io_test.go @@ -9,6 +9,7 @@ import ( "os" "runtime" "sync" + "syscall" "testing" "time" ) @@ -28,9 +29,10 @@ var glTestFdLock sync.Mutex // //nolint:paralleltest // Potential in (*os.File).Fd(). func TestReadDeadline(t *testing.T) { - t.Skip("Disabling while investigating race.") - ptmx, success := prepare(t) + if err := syscall.SetNonblock(int(ptmx.Fd()), true); err != nil { + t.Fatalf("Error: set non block: %s", err) + } if err := ptmx.SetDeadline(time.Now().Add(timeout / 10)); err != nil { if errors.Is(err, os.ErrNoDeadline) { @@ -59,9 +61,10 @@ func TestReadDeadline(t *testing.T) { // //nolint:paralleltest // Potential in (*os.File).Fd(). func TestReadClose(t *testing.T) { - t.Skip("Disabling while investigating race.") - ptmx, success := prepare(t) + if err := syscall.SetNonblock(int(ptmx.Fd()), true); err != nil { + t.Fatalf("Error: set non block: %s", err) + } go func() { time.Sleep(timeout / 10) From 2711aac0dbfa4a4bb89f069e6ad570c8025f0e73 Mon Sep 17 00:00:00 2001 From: Weidi Deng Date: Sat, 9 Dec 2023 09:19:11 +0800 Subject: [PATCH 2/3] using a larger timeout in test --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5a0ff1e..2a5e51d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -57,4 +57,4 @@ jobs: # Run the tests again 100 times without verbose. - if: ${{ matrix.go_version != '1.6.x' }} name: Many Tests - run: go test -count=100 -timeout=10s + run: go test -count=100 -timeout=30s From f3f519ed1212ffa359249a36a223e9837e558495 Mon Sep 17 00:00:00 2001 From: Weidi Deng Date: Sat, 9 Dec 2023 09:34:16 +0800 Subject: [PATCH 3/3] add notes to README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a4fe767..b6a1cf5 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ go get github.com/creack/pty ## Examples -Note that those examples are for demonstration purpose only, to showcase how to use the library. They are not meant to be used in any kind of production environment. +Note that those examples are for demonstration purpose only, to showcase how to use the library. They are not meant to be used in any kind of production environment. If you want to **set deadlines to work** and `Close()` **interrupting** `Read()` on the returned `*os.File`, you will need to call `syscall.SetNonblock` manually. ### Command