Skip to content

Commit

Permalink
add swift failing test matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
albertaleksieiev committed Aug 22, 2018
1 parent 8eb05c3 commit eb20b9a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/xcpretty/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ module Matchers
# $3 = time
SWIFT_TEST_CASE_MEASURED_MATCHER = /^[^:]*:[^:]*:\sTest Case\s'(.*)\.(.*)'\smeasured\s\[Time,\sseconds\]\saverage:\s(\d*\.\d{3}),/


# @regex Captured groups
# $1 = file
# $2 = test_suite
# $3 = test_case
# $4 = reason
SWIFT_FAILING_TEST_MATCHER = /^\s*(.+:\d+):\serror:\s(.*)\.(.*)\s:(?:\s'.*'\s\[FAILED\],)?\s(.*)/

PHASE_SUCCESS_MATCHER = /^\*\*\s(.*)\sSUCCEEDED\s\*\*/

# @regex Captured groups
Expand Down Expand Up @@ -384,7 +392,7 @@ def parse(text)
formatter.format_failing_test(@test_suite, @test_case, "Test crashed", "n/a")
when UI_FAILING_TEST_MATCHER
formatter.format_failing_test(@test_suite, @test_case, $2, $1)
when FAILING_TEST_MATCHER
when FAILING_TEST_MATCHER, SWIFT_FAILING_TEST_MATCHER
formatter.format_failing_test($2, $3, $4, $1)
when FATAL_ERROR_MATCHER
formatter.format_error($1)
Expand Down Expand Up @@ -462,7 +470,7 @@ def update_test_state(text)
@test_case = $2
when TESTS_RUN_COMPLETION_MATCHER
@tests_done = true
when FAILING_TEST_MATCHER
when FAILING_TEST_MATCHER, SWIFT_FAILING_TEST_MATCHER
store_failure(file: $1, test_suite: $2, test_case: $3, reason: $4)
when UI_FAILING_TEST_MATCHER
store_failure(file: $1, test_suite: @test_suite, test_case: @test_case, reason: $2)
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
SAMPLE_SWIFT_SLOW_TEST = "Test Case 'RACCommandSpec.enabled_signal_should_send_YES_while_executing_is_YES_and_allowsConcurrentExecution_is_YES' passed (0.101 seconds)."
SAMPLE_SWIFT_PENDING_KIWI_TEST = "Test Case 'TAPIConversationSpec.TAPIConversation_createConversation_SendsAPOSTRequestToTheConversationsEndpointPENDING' passed (0.001 seconds)."
SAMPLE_SWIFT_MEASURING_TEST = "<unknown>:0: Test Case 'SecEncodeTransformTests.SecEncodeTransformTests.test_RFC4648_Decode_UsingBase32' measured [Time, seconds] average: 0.013, relative standard deviation: 26.773%, values: [0.023838, 0.012034, 0.013512, 0.011022, 0.011203, 0.012814, 0.011131, 0.012740, 0.013646, 0.012145], performanceMetricID:com.apple.XCTPerformanceMetric_WallClockTime, baselineName: "", baselineAverage: , maxPercentRegression: 10.000%, maxPercentRelativeStandardDeviation: 10.000%, maxRegression: 0.100, maxStandardDeviation: 0.100"
SAMPLE_SWIFT_FAILING_TEST = "/Users/jenkins/build/workspace/SuperTest.swift:128: error: RACCommandSpec.test100_testMe : failed - error: The operation could not be completed"

SAMPLE_COMPILE = %Q(
CompileC /Users/musalj/Library/Developer/Xcode/DerivedData/ObjectiveSugar-ayzdhqmmwtqgysdpznmovjlupqjy/Build/Intermediates/Pods.build/Debug-iphonesimulator/Pods-ObjectiveSugar.build/Objects-normal/i386/NSMutableArray+ObjectiveSugar.o /Users/musalj/code/OSS/ObjectiveSugar/Classes/NSMutableArray+ObjectiveSugar.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
Expand Down
8 changes: 8 additions & 0 deletions spec/xcpretty/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ module XCPretty
@parser.parse(SAMPLE_SWIFT_OCUNIT_TEST)
end

it "parses passing swift ocunit tests failure" do
@formatter.should receive(:format_failing_test).with("RACCommandSpec",
"test100_testMe",
"failed - error: The operation could not be completed",
"/Users/jenkins/build/workspace/SuperTest.swift:128")
@parser.parse(SAMPLE_SWIFT_FAILING_TEST)
end

it "parses passing specta tests" do
@formatter.should receive(:format_passing_test).with('SKWelcomeActivationViewControllerSpecSpec',
'SKWelcomeActivationViewController_When_a_user_enters_their_details_lets_them_enter_a_valid_manager_code',
Expand Down

0 comments on commit eb20b9a

Please sign in to comment.