rules_xcodeproj
rules_xcodeproj copied to clipboard
Bug: XCTest traces are missing in failure context
Description
In Xcode 12+ a test case which calls into a function that then calls something like XCTFail/XCTAssert* has proper traces back up the stack to the originating caller. This helps diagnose where the test case failure is called. This happens automatically in a new Xcode 12+ project, for example:
The same code in a BwB rules_xcodeproj project only shows the trace for the XCTAssert:
Reproduction steps
Write a test which calls into some other function that then fails. Or see the attached zip with a vanilla Xcode and rules_xcodeproj example to reproduce the issue.
Expected behavior
The test failures look like they do in vanilla Xcode
rules_xcodeproj version
2.4.0
Xcode version
15.4
Bazel version
7.2.0
rules_apple version
3.5.1
rules_swift version
1.18.0
Additional information
No response
This bug is extremely annoying, as it drastically complicates daily work with XCTest. Could it be prioritized ?
I expect this is yet another "relative paths break Xcode" issue (e.g. #1119, #1284, #1336). Try launching Xcode from the Bazel execution root (I believe described in one or more of those issues) to see if that fixes it.
This might be fixable the same way that we fixed test issues to begin with, by swizzling something: https://github.com/bazelbuild/apple_support/pull/128.
Same issue with Swift Testing, we only see test failures inline at the top-level test function level, not at the actual point of failure in the test sources. Would really love to see this issue fixed as-well 🙏
I tried the opening project in execution root work around but that didn't seem to work for this case.
This seems to effect other error message tracing as well, like a swift macro compiling with an error does not trace back to the call site
Some more testing here:
In the first image (Vanilla Xcode) the failure has the context where as second image (Bazel) the information seems to be lost.
Some more debugging:
Looks like XCTSourceCodeFrame contains the address and symbol info, when i print the XCTSourceCodeFrame.symbolicationError instance variable I see:
Symbolication Error: Error Domain=XCTSymbolicationServiceErrorDomain Code=6 "Unable to get source info for address 4382236627 in image 'NonEmpty-Unit-UnitTests'" UserInfo={NSLocalizedDescription=Unable to get source info for address 4382236627 in image 'NonEmpty-Unit-UnitTests'}