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

Handle xcresulttool failures #390

Merged
merged 2 commits into from
Jan 10, 2024

Conversation

priitlatt
Copy link
Contributor

It is possible that xcresult files that contain Xcode test results are corrupted (either by erroneous user interaction or Xcode generated them as such). For example if Info.plist is missing from the xcresult bundle, then applying any xcrun xcresulttool command to this bundle will fail and exits with error code 1.

For example:

$ xcrun xcresulttool get --format json --path /Users/priit/Library/Developer/Xcode/DerivedData/App-eyutjqzsoxkgpcbycmzihsrczspl/Logs/Test/Test-App-2024.01.10_09-07-42-+0000.xcresult
error: Info.plist at /Users/priit/Library/Developer/Xcode/DerivedData/App-eyutjqzsoxkgpcbycmzihsrczspl/Logs/Test/Test-App-2024.01.10_09-07-42-+0000.xcresult does not exist, the result bundle might be corrupted or the provided path is not a result bundle

As it is now, xcode-project actions which use xcresulttool under the hood do not handle such errors in any way and as a result the action invocation can fail unexpectedly.

Example error log of xcode-project run-tests
Running tests on simulators:
- iOS 17.0 iPhone 15 (E473C396-11F5-426D-8A60-FCAD55546926)

Run tests for App.xcworkspace

Execute "xcodebuild -workspace App.xcworkspace -scheme App -sdk iphonesimulator -enableCodeCoverage YES -destination id=E473C396-11F5-426D-8A60-FCAD55546926 test"


Test run failed

Found test results at
- /Users/priit/Library/Developer/Xcode/DerivedData/App-eyutjqzsoxkgpcbycmzihsrczspl/Logs/Test/Test-App-2024.01.10_09-07-42-+0000.xcresult

Executing "xcode-project run-tests" failed unexpectedly. Detailed logs are available at "/var/folders/w2/rrf5p87d1bbfyphxc7jdnyvh0000gn/T/codemagic-10-01-24.log". To see more details about the error, add "--verbose" command line option.
No valid test result files matching "build/ios/test/*." were found. Test results are not displayed.

Build failed :|
Step 2 script `iOS test` exited with status code 9

Capture the errors that happen during xcresulttool runs, log out the error reason and fail the action gracefully with descriptive message in case the main goal of the action could not be completed.

Updated actions:

  • xcode-project run-tests
  • xcode-project test-summary
  • xcode-project junit-test-results

@priitlatt priitlatt added the bug Something isn't working label Jan 10, 2024
@priitlatt priitlatt marked this pull request as ready for review January 10, 2024 12:25
@priitlatt priitlatt merged commit 1786101 into master Jan 10, 2024
7 checks passed
@priitlatt priitlatt deleted the bugfix/xcode-corrupt-test-results-parsing branch January 10, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants