From aeec3c86c9bfbe12ffc1de461c8aa42db28a15cf Mon Sep 17 00:00:00 2001 From: Shizuo Fujita Date: Wed, 21 Oct 2026 13:52:46 +0900 Subject: [PATCH] Fix flaky check_pipe native spec on Windows The spec ran EVRUN_ONCE once and expected the 0.1 second polling tick to retry the notification setup. On Windows, select can return just before the timer is due, so the retry had not happened yet and the spec reported that the prepared pipe was not reused. Run the loop until the setup is retried, for up to 5 seconds, and report a missing retry separately. Co-Authored-By: Claude Opus 5.5 --- spec/fixtures/windows_stat_native.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/spec/fixtures/windows_stat_native.c b/spec/fixtures/windows_stat_native.c index e47c08b..f8b8a3d 100644 --- a/spec/fixtures/windows_stat_native.c +++ b/spec/fixtures/windows_stat_native.c @@ -145,6 +145,7 @@ check_pipe (VALUE self, VALUE path) ev_stat watcher; ev_timer timeout; ev_async async; + ev_tstamp deadline; WSADATA data; FILE *file; const char *error = 0; @@ -183,10 +184,20 @@ check_pipe (VALUE self, VALUE path) fail_socket = 0; socket_calls = 0; - ev_run (loop, EVRUN_ONCE); /* The next polling tick retries notification setup. */ + deadline = ev_time () + 5; + while (!loop->win32_fs && ev_time () < deadline) + { + ev_run (loop, EVRUN_ONCE); /* The next polling tick retries notification setup. */ + } /* One listener plus one client socket; ev_async_start must reuse this pair. */ - if (!loop->win32_fs || !ev_is_active (&loop->pipe_w) || socket_calls != 2) - error = "notification recovery did not reuse the prepared pipe"; + if (!loop->win32_fs) + { + error = "polling did not retry notification setup"; + } + else if (!ev_is_active (&loop->pipe_w) || socket_calls != 2) + { + error = "notification recovery did not reuse the prepared pipe"; + } cleanup: ev_stat_stop (loop, &watcher); ev_loop_destroy (loop);