Fix trainer failure result handling with objective C tests #21990
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist
bundle exec rspec
from the root directory to see all new and existing tests passbundle exec rubocop -a
to ensure the code style is validci/circleci
builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)Motivation and Context
When trainer is parsing an xcresult bundle which contains test failures, it has an
ActionTestMetadata
object that is identified one way (by "identifier") and it's trying to find the correspondingTestFailureIssueSummary
object that's identified another way (bytestCaseName
). These values are not the same, so in order to locate the correctTestFailureIssueSummary
object it needs to transform thetestCaseName
in the same way that Xcode does when generating theActionTestMetadata
identifier. Exactly how to do this is undocumented, so folks have attempted to figure it out empirically.Most recently, dda4007 ([trainer] fix issues where number of failures would always be zero (#21432), 2024-01-10) changed this transformation code in a way that fixed test names that contain spaces, but broke Objective-C test names.
Description
This commit fixes the regression caused by dda4007 with ObjC tests as follows:
It reverts the transformation behavior to how the code worked previously. Instead of "sanitizing" both the identifier and the test case name, it now keeps the identifier as is and "normalizes" the test case name. The test case name normalization has been moved into its own method which passes unit tests for ObjC, Swift, and tests with spaces.
It adds an ObjC xcresult bundle and unit test to prevent regressing parsing ObjC test names.
It refactors summaries_to_data so that if the corresponding test failure message cannot be located (but hopefully that won't happen anymore), we at least properly report that the test failed, but use the generic "unknown failure message" as the failure message.
See discussion on:
Testing Steps
I ran rubocop and rspec on the trainer code. It passes the existing tests as well as a new test I added to identify this issue and prevent regressions.