Skip to content

Commit

Permalink
[trainer] check specifically for file url in failure_message, fixing …
Browse files Browse the repository at this point in the history
…crash in Xcode 15 when running in Apple Silicon (#21493)

* Since url is the property we're trying to append to failure message, check for it speficially

* Add test to verify we still get useful test failure data without document location data

* We don't like the dig here, message received

* ping

* clean up mock

* ping for ci
  • Loading branch information
TheMetalCode committed Oct 9, 2023
1 parent fccf94b commit 1732b60
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion trainer/lib/trainer/xcresult.rb
Expand Up @@ -391,7 +391,7 @@ def initialize(data)

def failure_message
new_message = self.message
if self.document_location_in_creating_workspace
if self.document_location_in_creating_workspace&.url
file_path = self.document_location_in_creating_workspace.url.gsub("file://", "")
new_message += " (#{file_path})"
end
Expand Down
9 changes: 9 additions & 0 deletions trainer/spec/test_parser_spec.rb
Expand Up @@ -198,6 +198,15 @@
}
])
end

it "still produces a test failure message when file url is missing", requires_xcode: true do
allow_any_instance_of(Trainer::XCResult::TestFailureIssueSummary).to receive(:document_location_in_creating_workspace).and_return(nil)
tp = Trainer::TestParser.new("./trainer/spec/fixtures/Test.test_result.xcresult")
test_failures = tp.data.last[:tests].select { |t| t[:failures] }
failure_messages = test_failures.map { |tf| tf[:failures].first[:failure_message] }
expect(failure_messages).to eq(["XCTAssertTrue failed", "XCTAssertTrue failed"])
RSpec::Mocks.space.proxy_for(Trainer::XCResult::TestFailureIssueSummary).reset
end
end
end
end

0 comments on commit 1732b60

Please sign in to comment.