From 563fad803450f64bb076f539483ec58565987cba Mon Sep 17 00:00:00 2001 From: Joshua Blum Date: Wed, 7 Jan 2026 15:17:59 -0500 Subject: [PATCH] Wait for in-flight goroutines to complete in tests --- pipeliner_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pipeliner_test.go b/pipeliner_test.go index 35c25e8..96e88f6 100644 --- a/pipeliner_test.go +++ b/pipeliner_test.go @@ -76,10 +76,15 @@ func testPipeliner(doError bool, doCancel bool) ([]int, error) { for i := range v { err := pipeliner.WaitForRoom(ctx) if err != nil { + // Ensure any in-flight goroutines are complete before returning. Note that Flush does not actually wait if there is an error. + for pipeliner.hasOutstanding() { + <-pipeliner.ch + } return v, err } go func(i int) { pipeliner.CompleteOne(f(ctx, i)) }(i) } + err := pipeliner.Flush(ctx) return v, err }