From c3925858fbe112cc5d870ee6f832e4177bf4fc79 Mon Sep 17 00:00:00 2001 From: Levi Neuwirth Date: Fri, 12 Jun 2026 09:49:53 -0400 Subject: [PATCH] test: deflake stress_10k on loaded runners MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drop may discard queued work after setting shutdown, so on a slow CI runner (observed: macos-latest) it can win the race before any worker completes a single job, failing the count > 0 assert. Wait (bounded, 10s) for one completion before initiating shutdown — the no-hang property under test is unchanged. Co-Authored-By: Claude Fable 5 --- src/worker.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/worker.rs b/src/worker.rs index 405c7f9..03a41a4 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -494,6 +494,18 @@ mod tests { } handles.push(h); } + // Drop may discard still-queued work after setting shutdown, + // so on a loaded CI runner it can win the race before any + // worker finishes even one job, flaking the `count > 0` + // assert below (observed on the macOS runner). ~2/3 of the + // queue is non-cancelled, so one completion must land unless + // workers are wedged — wait for it, bounded. + let wait_start = std::time::Instant::now(); + while completed.load(Ordering::Relaxed) == 0 + && wait_start.elapsed() < std::time::Duration::from_secs(10) + { + std::thread::yield_now(); + } // Drain shutdown synchronously via Drop: this returns only // after every queued, non-cancelled job has run (or every // cancelled job has either run-then-noop or been silently