From c55297914e26ce3085b73ca88c521ef99136f6ad Mon Sep 17 00:00:00 2001 From: "Kohei Ota (inductor)" Date: Thu, 1 Oct 2026 19:39:56 +0900 Subject: [PATCH] Fix flaky testRun_whenServiceThrows_andShutdownGracefully (#260) ## Motivation [`testRun_whenServiceThrows_andShutdownGracefully`](https://github.com/swift-server/swift-service-lifecycle/blob/5e3b0e9/Tests/ServiceLifecycleTests/ServiceGroupTests.swift#L433-L441) is flaky. It failed on the Swift 6.3 Linux job: https://github.com/swift-server/swift-service-lifecycle/actions/runs/35197849503/job/105125249343 After service3 exits, the test pings service1 and expects `.runPing` before `.shutdownGracefully`. But the service group sends the graceful shutdown to service1 as soon as service3 exits, so the two events can arrive in either order. ## Modifications Wait for `.shutdownGracefully` on service1 before pinging it, like `testRun_whenServiceThrows_andShutdownGracefully_andOtherServiceThrows` already does. ## Result The test no longer depends on the order of the two events. `ServiceGroupTests` pass locally with Swift 6.3, and `swift format lint --strict` passes. --- Tests/ServiceLifecycleTests/ServiceGroupTests.swift | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Tests/ServiceLifecycleTests/ServiceGroupTests.swift b/Tests/ServiceLifecycleTests/ServiceGroupTests.swift index b8232f0..1e97035 100644 --- a/Tests/ServiceLifecycleTests/ServiceGroupTests.swift +++ b/Tests/ServiceLifecycleTests/ServiceGroupTests.swift @@ -433,10 +433,6 @@ final class ServiceGroupTests: XCTestCase { // Let's exit from the last service await service3.resumeRunContinuation(with: .success(())) - // Waiting to see that the remaining is still running - service1.sendPing() - await XCTAsyncAssertEqual(await eventIterator1.next(), .runPing) - // The first service should now receive the signal await XCTAsyncAssertEqual(await eventIterator1.next(), .shutdownGracefully)