lib/xcpretty/parser.rb in xcpretty-0.0.7 vs lib/xcpretty/parser.rb in xcpretty-0.0.8

- old
+ new

@@ -40,11 +40,11 @@ # @regex Captured groups # $1 = file_path # $2 = file_name # $3 = reason - COMPILE_ERROR_MATCHER = /^(.+\/(.*\.[h,m,c]).*):\serror:\s(.*)$/ + COMPILE_ERROR_MATCHER = /^(.+\/(.*\.[h,m,c]).*):(?:\sfatal)?\serror:\s(.*)$/ # @regex Captured groups # $1 file_path # $2 file_name (e.g. MainMenu.xib) COMPILE_XIB_MATCHER = /^CompileXIB\s(.*\/(.*\.xib))/ @@ -79,10 +79,14 @@ # @regex Captured groups # $1 = library LIBTOOL_MATCHER = /^Libtool.*\/(.*\.a)/ # @regex Captured groups + # $1 reason + LINKER_FAILURE_MATCHER = /^(Undefined symbols for architecture .*):$/ + + # @regex Captured groups # $1 = target # $2 = build_variants (normal, profile, debug) # $3 = architecture LINKING_MATCHER = /^Ld \/.*\/(.*) (.*) (.*)$/ @@ -112,11 +116,16 @@ PBXCP_MATCHER = /^PBXCp\s((?:\\ |[^ ])*)/ # @regex Captured groups # $1 = file PROCESS_INFO_PLIST_MATCHER = /^ProcessInfoPlistFile\s.*\.plist\s(.*\/+(.*\.plist))/ + # @regex Captured groups + # $1 = reference + SYMBOL_REFERENCED_FROM_MATCHER = /\s*"(.*)", referenced from:$/ + + # @regex Captured groups # $1 = suite # $2 = time TESTS_RUN_COMPLETION_MATCHER = /Test Suite '(?:.*\/)?(.*[ox]ctest.*)' finished at (.*)/ # @regex Captured groups @@ -139,12 +148,14 @@ end def parse(text) update_test_state(text) update_error_state(text) + update_linker_failure_state(text) return format_error if should_format_error? + return format_linker_failure if should_format_linker_failure? case text when ANALYZE_MATCHER formatter.format_analyze($2, $1) when BUILD_TARGET_MATCHER @@ -225,31 +236,61 @@ current_error[:file_path] = $1 current_error[:file_name] = $2 elsif text =~ CURSOR_MATCHER @formatting_error = false current_error[:cursor] = $1.chomp - else - current_error[:line] = text.chomp if @formatting_error + elsif @formatting_error + current_error[:line] = text.chomp end end + def update_linker_failure_state(text) + if text =~ LINKER_FAILURE_MATCHER + @formatting_linker_error = true + current_linker_failure[:message] = $1 + elsif text =~ SYMBOL_REFERENCED_FROM_MATCHER + current_linker_failure[:symbol] = $1 + elsif @formatting_linker_error + current_linker_failure[:reference] = text.strip + @formatting_linker_error = false + end + end + # TODO: clean up the mess around all this def should_format_error? current_error[:reason] && current_error[:cursor] && current_error[:line] end + def should_format_linker_failure? + current_linker_failure[:message] && + current_linker_failure[:symbol] && + current_linker_failure[:reference] + end + def current_error @current_error ||= {} end + def current_linker_failure + @linker_failure ||= {} + end + def format_error error = current_error.dup @current_error = {} formatter.format_compile_error(error[:file_name], error[:file_path], error[:reason], error[:line], error[:cursor]) + end + + def format_linker_failure + failure = current_linker_failure.dup + @linker_failure = {} + formatter.format_linker_failure(failure[:message], + failure[:symbol], + failure[:reference]) end def store_failure(file, test_suite, test_case, reason) failures_per_suite[test_suite] ||= [] failures_per_suite[test_suite] << {