Skip to content
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

Obtaining a Backtrace after swift_test failure #1211

Open
ed-irl opened this issue May 30, 2024 · 2 comments
Open

Obtaining a Backtrace after swift_test failure #1211

ed-irl opened this issue May 30, 2024 · 2 comments

Comments

@ed-irl
Copy link

ed-irl commented May 30, 2024

Hello, I was wondering if it is possible to obtain a backtrace (see https://github.com/apple/swift/blob/main/docs/Backtracing.rst) in the failure report of Xcode tests run via Bazel? Merely setting env = {"SWIFT_BACKTRACE":"enable=yes"} doesn't seem to help on MacOS.

@keith
Copy link
Member

keith commented May 30, 2024

https://github.com/apple/swift/blob/main/docs/Backtracing.rst#macos I think the second part of the instructions would be required too, worth a try

@ed-irl
Copy link
Author

ed-irl commented May 30, 2024

I played around with this today and may come back to it.

You can indeed codesign the bundle (or binary within the bundle) by using codesign --force --sign - --entitlements get-task-allow.plist path/to/bundle.xctest or codesign --force --sign - --entitlements get-task-allow.plist path/to/bundle.xctest/path/to/binary. Having done so, you can cd into the sandbox and run the test with SWIFT_BACKTRACE=enable=yes xcrun xctest libs/swift/DockerTestContainers/DockerTestContainersTests.xctest. Unfortunately, this did not produce a stack trace in the output. Its unclear to me why this was the case; I am in the process of debugging a race condition and I suspect the signing or backtrace instrumentation may prevent the test failure in my code from happening, or it might just not work.

I think the following might be needed to make this work on MacOS:

  1. possibly disabling bundling
  2. adding an option to swift_test to add the required signature and entitlement

I assume it probably already works for swift linux users based on the docs, and the fact that the test is just a plain binary in linux.

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

No branches or pull requests

2 participants