Skip to content

Tests: Remove .seconds-based timeouts in some Suites #8810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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