Skip to content

Conversation

@AnupamKumar-1
Copy link

@AnupamKumar-1 AnupamKumar-1 commented Jun 12, 2025

Refactor testSwiftRunSIGINT to use XCTestExpectation instead of DispatchGroup timeout

Motivation:

The existing testSwiftRunSIGINT() relied on a 60 s DispatchGroup.wait(timeout:), which led to flaky CI failures and unnecessarily long test runs. We want the test to react immediately to the process’s “sleeping” output and its subsequent exit, rather than guessing at a timeout duration.

Modifications:

  • Removed DispatchGroup and its 60 s timeout from testSwiftRunSIGINT().
  • Introduced an XCTestExpectation (startedExp) that’s fulfilled when the child process prints “sleeping.”
  • Inlined the stdout handler closures in the AsyncProcess initialization to detect the “sleeping” line and fulfill startedExp.
  • Replaced the manual wait with wait(for: [startedExp], timeout: 10.0) to pause until the process is ready.
  • Sent SIGINT immediately after that expectation and then called process.waitUntilExit().
  • Removed the XCTSkipIf…CI guards now that the test is deterministic and reliably passes.

Result:

  • testSwiftRunSIGINT() now completes in seconds instead of minutes and no longer fails intermittently on CI.
  • The test suite runs faster and more reliably, with no arbitrary timeouts.

Fixes: #8770

@AnupamKumar-1 AnupamKumar-1 changed the title Tests: Remove .seconds-based timeouts in ConcurrencyHelpers and swift… Tests: Remove .seconds-based timeouts in ConcurrencyHelpers and swift… #8770 Jun 12, 2025
@bkhouri bkhouri changed the title Tests: Remove .seconds-based timeouts in ConcurrencyHelpers and swift… #8770 Tests: Remove .seconds-based timeouts in some Suites Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests: Improve tests to not rely on a .seconds(...)

1 participant