Skip to content

Commit

Permalink
tests: Use demangled value in assertion
Browse files Browse the repository at this point in the history
Mangled swift is unstable and differs a lot between versions
  • Loading branch information
kattrali committed Jun 12, 2019
1 parent 92c2d43 commit 51de3fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion features/handled_errors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Scenario: Override errorClass and message from a notifyError() callback and disc
And the exception "errorClass" equals "Bar"
And the exception "message" equals "Foo"
And the event "device.time" is within 30 seconds of the current timestamp
And the "method" of stack frame 0 equals "$S10iOSTestApp28HandledErrorOverrideScenarioC3runyyF"
And the "method" of stack frame 0 demangles to "iOSTestApp.HandledErrorOverrideScenario.run() -> ()"
And the stack trace is an array with 15 stack frames

Scenario: Reporting an NSError
Expand Down
6 changes: 6 additions & 0 deletions features/steps/ios_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@
assert_not_nil(match, "No crumb matches the provided message")
end

Then("the {string} of stack frame {int} demangles to {string}") do |field, frame_index, expected_value|
value = read_key_path(find_request(0)[:body], "events.0.exceptions.0.stacktrace.#{frame_index}.#{field}")
demangled_value = `xcrun swift-demangle -compact '#{value}'`.chomp
assert_equal(expected_value, demangled_value)
end

Then("the stack trace is an array with {int} stack frames") do |expected_length|
stack_trace = read_key_path(find_request(0)[:body], "events.0.exceptions.0.stacktrace")
assert_equal(expected_length, stack_trace.length)
Expand Down

0 comments on commit 51de3fc

Please sign in to comment.