Skip to content

feat: prevent test runner from halting on XCTest internal failures#41

Merged
gmegidish merged 1 commit into
mainfrom
feat/wda-pr664-runner-stability
May 3, 2026
Merged

feat: prevent test runner from halting on XCTest internal failures#41
gmegidish merged 1 commit into
mainfrom
feat/wda-pr664-runner-stability

Conversation

@gmegidish
Copy link
Copy Markdown
Member

No description provided.

…DA PR #664)

swizzles XCTIssue.shouldInterruptTest to always return NO so internal
xctest failures during testmanagerd startup don't kill the runner.
also disables shouldHaltWhenReceivesControl to handle slow testmanagerd
connections, and swallows XCTest issues via record(_:) override.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 2, 2026

Walkthrough

This pull request modifies test execution behavior across two files. In the Objective-C category file, a new helper method dk_swizzledShouldInterruptTest is introduced and hooked into XCTIssue's instance method shouldInterruptTest at runtime, forcing it to return NO during test execution. In the Swift test file, the setup logic is extended to conditionally disable shouldHaltWhenReceivesControl via KVC, and a new record(_:) override is added to intercept and log XCTest issues rather than propagating them through the standard failure machinery. A previously unused static flag is removed.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No description was provided by the author, making it impossible to assess whether it relates to the changeset. Add a description explaining the purpose of the changes, the problems being solved, and any relevant context about test runner stability improvements.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: preventing the test runner from halting on XCTest internal failures by swizzling XCTIssue and shouldHaltWhenReceivesControl behavior.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/wda-pr664-runner-stability

Review rate limit: 3/5 reviews remaining, refill in 21 minutes and 29 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
DeviceKitTests/Categories/XCUIApplicationProcess+FBQuiescence.m (1)

170-176: 💤 Low value

Consider adding a log statement for traceability.

The quiescence method swizzle logs a message when the method isn't found (line 198-199). Adding similar logging for the XCTIssue swizzle would aid debugging if this mechanism silently fails on a future iOS version.

📝 Suggested change
     SEL shouldInterruptTest = NSSelectorFromString(@"shouldInterruptTest");
     Method m = class_getInstanceMethod(NSClassFromString(@"XCTIssue"), shouldInterruptTest);
     if (m) {
         method_setImplementation(m, (IMP)dk_swizzledShouldInterruptTest);
+        [FBLogger log:@"Swizzled -[XCTIssue shouldInterruptTest] to return NO"];
+    } else {
+        [FBLogger log:@"Could not find method -[XCTIssue shouldInterruptTest]"];
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@DeviceKitTests/Categories/XCUIApplicationProcess`+FBQuiescence.m around lines
170 - 176, The XCTIssue swizzle block (using SEL shouldInterruptTest,
class_getInstanceMethod(NSClassFromString(@"XCTIssue"), shouldInterruptTest),
method_setImplementation and dk_swizzledShouldInterruptTest) should emit a trace
log like the quiescence swizzle does: add a log when the method is not found and
a log when the swizzle was applied successfully (or when it failed), using the
same logging mechanism used elsewhere in this file (e.g., NSLog or the existing
test logger) so future iOS changes are detectable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@DeviceKitTests/Categories/XCUIApplicationProcess`+FBQuiescence.m:
- Around line 170-176: The XCTIssue swizzle block (using SEL
shouldInterruptTest, class_getInstanceMethod(NSClassFromString(@"XCTIssue"),
shouldInterruptTest), method_setImplementation and
dk_swizzledShouldInterruptTest) should emit a trace log like the quiescence
swizzle does: add a log when the method is not found and a log when the swizzle
was applied successfully (or when it failed), using the same logging mechanism
used elsewhere in this file (e.g., NSLog or the existing test logger) so future
iOS changes are detectable.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dca3460c-aa80-42f7-8ba9-2a0217a38b15

📥 Commits

Reviewing files that changed from the base of the PR and between 88c38aa and 0831194.

📒 Files selected for processing (2)
  • DeviceKitTests/Categories/XCUIApplicationProcess+FBQuiescence.m
  • DeviceKitTests/devicekit_iosUITests.swift

@gmegidish gmegidish merged commit d7cb821 into main May 3, 2026
6 checks passed
@gmegidish gmegidish deleted the feat/wda-pr664-runner-stability branch May 3, 2026 13:08
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.

1 participant