xcpretty 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +6 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +15 -6
- data/CONTRIBUTING.md +4 -0
- data/README.md +16 -0
- data/Rakefile +1 -1
- data/assets/report.html.erb +1 -1
- data/bin/xcpretty +1 -1
- data/features/fixtures/xcodebuild.log +2989 -2989
- data/features/simple_format.feature +10 -0
- data/features/steps/formatting_steps.rb +27 -2
- data/features/steps/json_steps.rb +4 -5
- data/features/support/env.rb +2 -1
- data/features/test_format.feature +10 -0
- data/lib/xcpretty/formatters/formatter.rb +33 -8
- data/lib/xcpretty/formatters/rspec.rb +5 -0
- data/lib/xcpretty/formatters/simple.rb +22 -0
- data/lib/xcpretty/parser.rb +102 -18
- data/lib/xcpretty/reporters/json_compilation_database.rb +21 -13
- data/lib/xcpretty/snippet.rb +9 -3
- data/lib/xcpretty/syntax.rb +32 -8
- data/lib/xcpretty/version.rb +1 -1
- data/spec/fixtures/NSStringTests.m +1 -1
- data/spec/fixtures/constants.rb +35 -8
- data/spec/xcpretty/formatters/formatter_spec.rb +23 -7
- data/spec/xcpretty/formatters/simple_spec.rb +20 -0
- data/spec/xcpretty/parser_spec.rb +76 -7
- data/spec/xcpretty/snippet_spec.rb +12 -5
- data/spec/xcpretty/syntax_spec.rb +37 -9
- data/vendor/json_pure/parser.rb +1 -1
- data/xcpretty.gemspec +2 -2
- metadata +5 -4
@@ -114,6 +114,11 @@ Feature: Showing build output in simple format
|
|
114
114
|
When I pipe to xcpretty with "--simple"
|
115
115
|
Then I should see the name of a pending test
|
116
116
|
|
117
|
+
Scenario: Showing measuring test output
|
118
|
+
Given I have a measuring test in my suite
|
119
|
+
When I pipe to xcpretty with "--simple"
|
120
|
+
Then I should see the name of a measuring test
|
121
|
+
|
117
122
|
Scenario: Showing failed test output with color
|
118
123
|
Given I have a failing test in my suite
|
119
124
|
And the test suite has finished
|
@@ -170,3 +175,8 @@ Feature: Showing build output in simple format
|
|
170
175
|
Then I should see the undefined symbold message
|
171
176
|
And I should see the symbol and reference that caused failure
|
172
177
|
|
178
|
+
Scenario: There are build warnings
|
179
|
+
Given there were warnings in the code
|
180
|
+
When I pipe to xcpretty with "--simple --color"
|
181
|
+
Then I should see a yellow warning message
|
182
|
+
|
@@ -76,6 +76,10 @@ Given(/^there was a syntax error$/) do
|
|
76
76
|
add_run_input SAMPLE_COMPILE_ERROR
|
77
77
|
end
|
78
78
|
|
79
|
+
Given(/^there were warnings in the code$/) do
|
80
|
+
add_run_input SAMPLE_FORMAT_WARNING
|
81
|
+
end
|
82
|
+
|
79
83
|
Given(/^the linker has failed with undefined symbols$/) do
|
80
84
|
add_run_input SAMPLE_UNDEFINED_SYMBOLS
|
81
85
|
end
|
@@ -84,6 +88,10 @@ Given(/^I have a pending test in my suite$/) do
|
|
84
88
|
add_run_input SAMPLE_PENDING_KIWI_TEST
|
85
89
|
end
|
86
90
|
|
91
|
+
Given(/^I have a measuring test in my suite$/) do
|
92
|
+
add_run_input SAMPLE_MEASURING_TEST
|
93
|
+
end
|
94
|
+
|
87
95
|
Given(/^I have a tiff file to validate$/) do
|
88
96
|
add_run_input SAMPLE_TIFFUTIL
|
89
97
|
end
|
@@ -181,6 +189,14 @@ Then(/^I should see a yellow pending test icon$/) do
|
|
181
189
|
run_output.should start_with(yellow("P"))
|
182
190
|
end
|
183
191
|
|
192
|
+
Then(/^I should see a measuring test icon in ASCII$/) do
|
193
|
+
run_output.should start_with('T')
|
194
|
+
end
|
195
|
+
|
196
|
+
Then(/^I should see a yellow measuring test icon$/) do
|
197
|
+
run_output.should start_with(yellow('T'))
|
198
|
+
end
|
199
|
+
|
184
200
|
Then(/^the final execution message should be (red|green)$/) do |color|
|
185
201
|
last_line = run_output.lines.to_a.last
|
186
202
|
last_line.should be_colored(color.to_sym)
|
@@ -235,7 +251,12 @@ Then(/^I should not see the name of the test group$/) do
|
|
235
251
|
end
|
236
252
|
|
237
253
|
Then(/^I should see a red error message$/) do
|
238
|
-
run_output.should include(red("⌦
|
254
|
+
run_output.should include(red("⌦ " + SAMPLE_PODS_ERROR.gsub('error: ', '')))
|
255
|
+
end
|
256
|
+
|
257
|
+
Then(/^I should see a yellow warning message$/) do
|
258
|
+
run_output.should include("#{yellow('⚠️ ')}/Users/supermarin/code/oss/ObjectiveSugar/Example/ObjectiveSugar/AppDelegate.m:19:31:")
|
259
|
+
run_output.should include(yellow("format specifies type 'id' but the argument has type 'int' [-Wformat]"))
|
239
260
|
end
|
240
261
|
|
241
262
|
Then(/^I should see a red compilation error$/) do
|
@@ -251,7 +272,7 @@ Then(/^I should see a cyan cursor$/) do
|
|
251
272
|
end
|
252
273
|
|
253
274
|
Then(/^I should see the undefined symbold message$/) do
|
254
|
-
run_output.should include(red("⌦
|
275
|
+
run_output.should include(red("⌦ Undefined symbols for architecture x86_64"))
|
255
276
|
end
|
256
277
|
|
257
278
|
Then(/^I should see the symbol and reference that caused failure$/) do
|
@@ -263,6 +284,10 @@ Then(/^I should see the name of a pending test$/) do
|
|
263
284
|
run_output.should =~ PENDING_TEST_NAME_MATCHER
|
264
285
|
end
|
265
286
|
|
287
|
+
Then(/^I should see the name of a measuring test$/) do
|
288
|
+
run_output.should =~ MEASURING_TEST_NAME_MATCHER
|
289
|
+
end
|
290
|
+
|
266
291
|
Then(/^I should see the test time in yellow$/) do
|
267
292
|
run_output.should include("#{yellow("0.026")}")
|
268
293
|
end
|
@@ -18,17 +18,16 @@ end
|
|
18
18
|
|
19
19
|
Then(/^the JSON compilation database should contain an entry with a command$/) do
|
20
20
|
json_db.length.should == 1
|
21
|
-
|
22
|
-
json_db[0][
|
23
|
-
json_db[0]["command"].should end_with(".o")
|
21
|
+
json_db[0]['command'].should start_with('/Applications/Xcode.app/Contents/Developer')
|
22
|
+
json_db[0]['command'].should end_with('.o')
|
24
23
|
end
|
25
24
|
|
26
25
|
Then(/^the JSON compilation database should contain an entry with a file$/) do
|
27
|
-
json_db[0][
|
26
|
+
json_db[0]['file'].should == '/Users/musalj/code/OSS/ObjectiveSugar/Classes/NSMutableArray+ObjectiveSugar.m'
|
28
27
|
end
|
29
28
|
|
30
29
|
Then(/^the JSON compilation database should contain an entry with a directory$/) do
|
31
|
-
json_db[0][
|
30
|
+
json_db[0]['directory'].should == '/'
|
32
31
|
end
|
33
32
|
|
34
33
|
Then(/^the JSON compilation database should be complete$/) do
|
data/features/support/env.rb
CHANGED
@@ -27,6 +27,7 @@ TEST_PATH_MATCHER = %r{[\w/\-\s]+:\d+}
|
|
27
27
|
PASSING_TEST_NAME_MATCHER = %r{\w+\s\(\d+\.\d+\sseconds\)}
|
28
28
|
PENDING_TEST_NAME_MATCHER = %r{\w+\s\[PENDING\]}
|
29
29
|
FAILING_TEST_NAME_MATCHER = %r{\w+, expected:}
|
30
|
+
MEASURING_TEST_NAME_MATCHER = %r{\w+\smeasured\s\(\d+\.\d+\sseconds\)}
|
30
31
|
|
31
32
|
JSON_DB_FIXTURE_COMMAND_COUNT = 557
|
32
33
|
|
@@ -110,6 +111,6 @@ After do
|
|
110
111
|
@json = nil
|
111
112
|
FileUtils.rm_rf(XCPretty::JUnit::FILEPATH)
|
112
113
|
FileUtils.rm_rf(XCPretty::HTML::FILEPATH)
|
113
|
-
FileUtils.rm_rf(XCPretty::JSONCompilationDatabase::
|
114
|
+
FileUtils.rm_rf(XCPretty::JSONCompilationDatabase::FILE_PATH)
|
114
115
|
File.delete(@screenshot_file_path) if @screenshot_file_path
|
115
116
|
end
|
@@ -15,6 +15,11 @@ Feature: Showing RSpec-style test output
|
|
15
15
|
When I pipe to xcpretty with "--test"
|
16
16
|
Then I should see a pending test icon in ASCII
|
17
17
|
|
18
|
+
Scenario: Showing measuring tests
|
19
|
+
Given I have a measuring test in my suite
|
20
|
+
When I pipe to xcpretty with "--test"
|
21
|
+
Then I should see a measuring test icon in ASCII
|
22
|
+
|
18
23
|
Scenario: Showing some tests failed with color
|
19
24
|
Given I have a failing test in my suite
|
20
25
|
And the test suite has finished
|
@@ -33,6 +38,11 @@ Feature: Showing RSpec-style test output
|
|
33
38
|
When I pipe to xcpretty with "--test --color"
|
34
39
|
Then I should see a yellow pending test icon
|
35
40
|
|
41
|
+
Scenario: Showing measuring tests with color
|
42
|
+
Given I have a measuring test in my suite
|
43
|
+
When I pipe to xcpretty with "--test --color"
|
44
|
+
Then I should see a yellow measuring test icon
|
45
|
+
|
36
46
|
Scenario: Showing that all tests passed with color
|
37
47
|
Given all of my tests will pass in my suite
|
38
48
|
When I pipe to xcpretty with "--test --color"
|
@@ -16,8 +16,10 @@ module XCPretty
|
|
16
16
|
def format_clean_target(target, project, configuration); EMPTY; end
|
17
17
|
def format_clean_remove; EMPTY; end
|
18
18
|
def format_compile(file_name, file_path); EMPTY; end
|
19
|
-
def format_compile_command(compiler_command);
|
19
|
+
def format_compile_command(compiler_command, file_path); EMPTY; end
|
20
20
|
def format_compile_xib(file_name, file_path); EMPTY; end
|
21
|
+
def format_copy_header_file(source, target); EMPTY; end
|
22
|
+
def format_copy_plist_file(source, target); EMPTY; end
|
21
23
|
def format_copy_strings_file(file_name); EMPTY; end
|
22
24
|
def format_cpresource(file); EMPTY; end
|
23
25
|
def format_generate_dsym(dsym); EMPTY; end
|
@@ -25,26 +27,37 @@ module XCPretty
|
|
25
27
|
def format_libtool(library); EMPTY; end
|
26
28
|
def format_passing_test(suite, test, time); EMPTY; end
|
27
29
|
def format_pending_test(suite, test); EMPTY; end
|
30
|
+
def format_measuring_test(suite, test, time); EMPTY; end
|
28
31
|
def format_failing_test(suite, test, time, file_path); EMPTY; end
|
29
32
|
def format_process_pch(file); EMPTY; end
|
33
|
+
def format_process_pch_command(file_path); EMPTY; end
|
30
34
|
def format_phase_script_execution(script_name); EMPTY; end
|
31
35
|
def format_process_info_plist(file_name, file_path); EMPTY; end
|
32
36
|
def format_codesign(file); EMPTY; end
|
33
37
|
def format_preprocess(file); EMPTY; end
|
34
38
|
def format_pbxcp(file); EMPTY; end
|
39
|
+
def format_shell_command(command, arguments); EMPTY; end
|
35
40
|
def format_test_run_started(name); EMPTY; end
|
36
41
|
def format_test_run_finished(name, time); EMPTY; end
|
37
42
|
def format_test_suite_started(name); EMPTY; end
|
38
43
|
def format_test_summary(message, failures_per_suite); EMPTY; end
|
39
44
|
def format_touch(file_path, file_name); EMPTY; end
|
40
45
|
def format_tiffutil(file); EMPTY; end
|
46
|
+
def format_write_file(file); EMPTY; end
|
47
|
+
def format_write_auxiliary_files; EMPTY; end
|
41
48
|
|
42
|
-
# COMPILER / LINKER ERRORS
|
49
|
+
# COMPILER / LINKER ERRORS AND WARNINGS
|
43
50
|
def format_compile_error(file_name, file_path, reason,
|
44
51
|
line, cursor); EMPTY; end
|
45
52
|
def format_error(message); EMPTY; end
|
46
53
|
def format_undefined_symbols(message, symbol, reference); EMPTY; end
|
47
54
|
def format_duplicate_symbols(message, file_paths); EMPTY; end
|
55
|
+
def format_warning(message); message; end
|
56
|
+
|
57
|
+
# TODO: see how we can unify format_error and format_compile_error,
|
58
|
+
# the same for warnings
|
59
|
+
def format_compile_warning(file_name, file_path, reason,
|
60
|
+
line, cursor); EMPTY; end
|
48
61
|
end
|
49
62
|
|
50
63
|
class Formatter
|
@@ -83,8 +96,11 @@ module XCPretty
|
|
83
96
|
"\n\n#{text}"
|
84
97
|
end
|
85
98
|
|
86
|
-
ERROR =
|
87
|
-
ASCII_ERROR =
|
99
|
+
ERROR = '⌦ '
|
100
|
+
ASCII_ERROR = '[x]'
|
101
|
+
|
102
|
+
WARNING = '⚠️ '
|
103
|
+
ASCII_WARNING = '[!]'
|
88
104
|
|
89
105
|
def format_error(message)
|
90
106
|
"\n#{red(error_symbol + " " + message)}\n\n"
|
@@ -92,18 +108,23 @@ module XCPretty
|
|
92
108
|
|
93
109
|
def format_compile_error(file, file_path, reason, line, cursor)
|
94
110
|
"\n#{red(error_symbol + " ")}#{file_path}: #{red(reason)}\n\n" +
|
95
|
-
|
111
|
+
"#{line}\n#{cyan(cursor)}\n\n"
|
112
|
+
end
|
113
|
+
|
114
|
+
def format_compile_warning(file, file_path, reason, line, cursor)
|
115
|
+
"\n#{yellow(warning_symbol + ' ')}#{file_path}: #{yellow(reason)}\n\n" +
|
116
|
+
"#{line}\n#{cyan(cursor)}\n\n"
|
96
117
|
end
|
97
118
|
|
98
119
|
def format_undefined_symbols(message, symbol, reference)
|
99
120
|
"\n#{red(error_symbol + " " + message)}\n" +
|
100
|
-
|
101
|
-
|
121
|
+
"> Symbol: #{symbol}\n" +
|
122
|
+
"> Referenced from: #{reference}\n\n"
|
102
123
|
end
|
103
124
|
|
104
125
|
def format_duplicate_symbols(message, file_paths)
|
105
126
|
"\n#{red(error_symbol + " " + message)}\n" +
|
106
|
-
|
127
|
+
"> #{file_paths.map { |path| path.split('/').last }.join("\n> ")}\n"
|
107
128
|
end
|
108
129
|
|
109
130
|
|
@@ -130,5 +151,9 @@ module XCPretty
|
|
130
151
|
use_unicode? ? ERROR : ASCII_ERROR
|
131
152
|
end
|
132
153
|
|
154
|
+
def warning_symbol
|
155
|
+
use_unicode? ? WARNING : ASCII_WARNING
|
156
|
+
end
|
157
|
+
|
133
158
|
end
|
134
159
|
end
|
@@ -5,6 +5,7 @@ module XCPretty
|
|
5
5
|
FAIL = "F"
|
6
6
|
PASS = "."
|
7
7
|
PENDING = "P"
|
8
|
+
MEASURING = 'T'
|
8
9
|
|
9
10
|
def optional_newline
|
10
11
|
''
|
@@ -22,6 +23,10 @@ module XCPretty
|
|
22
23
|
yellow(PENDING)
|
23
24
|
end
|
24
25
|
|
26
|
+
def format_measuring_test(suite, test_case, time)
|
27
|
+
yellow(MEASURING)
|
28
|
+
end
|
29
|
+
|
25
30
|
end
|
26
31
|
|
27
32
|
end
|
@@ -8,12 +8,14 @@ module XCPretty
|
|
8
8
|
PASS = "✓"
|
9
9
|
FAIL = "✗"
|
10
10
|
PENDING = "⧖"
|
11
|
+
MEASURE = '◷'
|
11
12
|
|
12
13
|
ASCII_PASS = "."
|
13
14
|
ASCII_FAIL = "x"
|
14
15
|
COMPLETION = "▸"
|
15
16
|
ASCII_PENDING = "P"
|
16
17
|
ASCII_COMPLETION = ">"
|
18
|
+
ASCII_MEASURE = 'T'
|
17
19
|
|
18
20
|
INDENT = " "
|
19
21
|
|
@@ -37,6 +39,14 @@ module XCPretty
|
|
37
39
|
format("Compiling", file_name)
|
38
40
|
end
|
39
41
|
|
42
|
+
def format_copy_header_file(source, target)
|
43
|
+
format("Copying", File.basename(source))
|
44
|
+
end
|
45
|
+
|
46
|
+
def format_copy_plist_file(source, target)
|
47
|
+
format("Copying", File.basename(source))
|
48
|
+
end
|
49
|
+
|
40
50
|
def format_copy_strings_file(file)
|
41
51
|
format("Copying", file)
|
42
52
|
end
|
@@ -69,6 +79,12 @@ module XCPretty
|
|
69
79
|
INDENT + format_test("#{test_case} [PENDING]", :pending)
|
70
80
|
end
|
71
81
|
|
82
|
+
def format_measuring_test(suite, test_case, time)
|
83
|
+
INDENT + format_test(
|
84
|
+
"#{test_case} measured (#{colored_time(time)} seconds)", :measure
|
85
|
+
)
|
86
|
+
end
|
87
|
+
|
72
88
|
def format_phase_script_execution(script_name)
|
73
89
|
format("Running script", "'#{script_name}'")
|
74
90
|
end
|
@@ -109,6 +125,10 @@ module XCPretty
|
|
109
125
|
format("Validating", file_name)
|
110
126
|
end
|
111
127
|
|
128
|
+
def format_warning(message)
|
129
|
+
INDENT + yellow(message)
|
130
|
+
end
|
131
|
+
|
112
132
|
private
|
113
133
|
|
114
134
|
def heading(prefix, text, description)
|
@@ -135,6 +155,8 @@ module XCPretty
|
|
135
155
|
red(use_unicode? ? ERROR : ASCII_ERROR)
|
136
156
|
when :completion
|
137
157
|
yellow(use_unicode? ? COMPLETION : ASCII_COMPLETION)
|
158
|
+
when :measure
|
159
|
+
yellow(use_unicode? ? MEASURE : ASCII_MEASURE)
|
138
160
|
else
|
139
161
|
""
|
140
162
|
end
|
data/lib/xcpretty/parser.rb
CHANGED
@@ -16,6 +16,11 @@ module XCPretty
|
|
16
16
|
# @regex Nothing returned here for now
|
17
17
|
CHECK_DEPENDENCIES_MATCHER = /^Check dependencies/
|
18
18
|
|
19
|
+
# @regex Captured groups
|
20
|
+
# $1 command path
|
21
|
+
# $2 arguments
|
22
|
+
SHELL_COMMAND_MATCHER = /^\s{4}(cd|setenv|(?:[\w\/:\\\s\-.]+?\/)?[\w\-]+)\s(.*)$/
|
23
|
+
|
19
24
|
# @regex Nothing returned here for now
|
20
25
|
CLEAN_REMOVE_MATCHER = /^Clean.Remove/
|
21
26
|
|
@@ -36,11 +41,12 @@ module XCPretty
|
|
36
41
|
# @regex Captured groups
|
37
42
|
# $1 file_path
|
38
43
|
# $2 file_name (e.g. KWNull.m)
|
39
|
-
COMPILE_MATCHER = /^CompileC\s
|
44
|
+
COMPILE_MATCHER = /^CompileC\s.+?\s((?:\\.|[^ ])+\/((?:\\.|[^ ])+\.(?:m|mm|c|cc|cpp|cxx)))\s.*/
|
40
45
|
|
41
46
|
# @regex Captured groups
|
42
47
|
# $1 compiler_command
|
43
|
-
|
48
|
+
# $2 file_path
|
49
|
+
COMPILE_COMMAND_MATCHER = /^\s*(.*\/usr\/bin\/clang\s.*\s\-c\s(.*\.(?:m|mm|c|cc|cpp|cxx))\s.*\.o)$/
|
44
50
|
|
45
51
|
# @regex Captured groups
|
46
52
|
# $1 file_path
|
@@ -48,6 +54,15 @@ module XCPretty
|
|
48
54
|
COMPILE_XIB_MATCHER = /^CompileXIB\s(.*\/(.*\.xib))/
|
49
55
|
|
50
56
|
# @regex Captured groups
|
57
|
+
# $1 source file
|
58
|
+
# $2 target file
|
59
|
+
COPY_HEADER_MATCHER = /^CpHeader\s(.*\.h)\s(.*\.h)/
|
60
|
+
|
61
|
+
# @regex Captured groups
|
62
|
+
# $1 source file
|
63
|
+
# $2 target file
|
64
|
+
COPY_PLIST_MATCHER = /^CopyPlistFile\s(.*\.plist)\s(.*\.plist)/
|
65
|
+
|
51
66
|
# $1 file
|
52
67
|
COPY_STRINGS_MATCHER = /^CopyStringsFile.*\/(.*.strings)/
|
53
68
|
|
@@ -91,6 +106,12 @@ module XCPretty
|
|
91
106
|
# $2 = test_case
|
92
107
|
PENDING_TEST_MATCHER = /^Test Case\s'-\[(.*)\s(.*)PENDING\]'\spassed/
|
93
108
|
|
109
|
+
# @regex Captured groups
|
110
|
+
# $1 = suite
|
111
|
+
# $2 = test_case
|
112
|
+
# $3 = time
|
113
|
+
MEASURING_TEST_MATCHER = /^[^:]*:[^:]*:\sTest Case\s'-\[(.*)\s(.*)\]'\smeasured\s\[Time,\sseconds\]\saverage:\s(\d*\.\d{3}),/
|
114
|
+
|
94
115
|
# @regex Captured groups
|
95
116
|
# $1 = script_name
|
96
117
|
PHASE_SCRIPT_EXECUTION_MATCHER = /^PhaseScriptExecution\s(.*)\s\//
|
@@ -99,6 +120,10 @@ module XCPretty
|
|
99
120
|
# $1 = file
|
100
121
|
PROCESS_PCH_MATCHER = /^ProcessPCH\s.*\s(.*.pch)/
|
101
122
|
|
123
|
+
# @regex Captured groups
|
124
|
+
# $1 file_path
|
125
|
+
PROCESS_PCH_COMMAND_MATCHER = /^\s*.*\/usr\/bin\/clang\s.*\s\-c\s(.*)\s\-o\s.*/
|
126
|
+
|
102
127
|
# @regex Captured groups
|
103
128
|
# $1 = file
|
104
129
|
PREPROCESS_MATCHER = /^Preprocess\s(?:(?:\\ |[^ ])*)\s((?:\\ |[^ ])*)$/
|
@@ -134,6 +159,24 @@ module XCPretty
|
|
134
159
|
# $2 file_name
|
135
160
|
TOUCH_MATCHER = /^Touch\s(.*\/([\w+\.]+))/
|
136
161
|
|
162
|
+
# @regex Captured groups
|
163
|
+
# $1 file_path
|
164
|
+
WRITE_FILE_MATCHER = /^write-file\s(.*)/
|
165
|
+
|
166
|
+
# @regex Captured groups
|
167
|
+
WRITE_AUXILIARY_FILES = /^Write auxiliary files/
|
168
|
+
|
169
|
+
module Warnings
|
170
|
+
# $1 = file_path
|
171
|
+
# $2 = file_name
|
172
|
+
# $3 = reason
|
173
|
+
COMPILE_WARNING_MATCHER = /^(\/.+\/(.*):.*:.*):\swarning:\s(.*)$/
|
174
|
+
|
175
|
+
# @regex Captured groups
|
176
|
+
# $1 = whole warning
|
177
|
+
GENERIC_WARNING_MATCHER = /^warning:\s(.*)$/
|
178
|
+
end
|
179
|
+
|
137
180
|
module Errors
|
138
181
|
# @regex Captured groups
|
139
182
|
# $1 = whole error
|
@@ -147,7 +190,7 @@ module XCPretty
|
|
147
190
|
# $1 = file_path
|
148
191
|
# $2 = file_name
|
149
192
|
# $3 = reason
|
150
|
-
COMPILE_ERROR_MATCHER = /^(\/.+\/(.*):.*:.*)
|
193
|
+
COMPILE_ERROR_MATCHER = /^(\/.+\/(.*):.*:.*):\s(?:fatal\s)?error:\s(.*)$/
|
151
194
|
|
152
195
|
# @regex Captured groups
|
153
196
|
# $1 cursor (with whitespaces and tildes)
|
@@ -158,7 +201,6 @@ module XCPretty
|
|
158
201
|
# it varies a lot, not sure if it makes sense to catch everything separately
|
159
202
|
FATAL_ERROR_MATCHER = /^(fatal error:.*)$/
|
160
203
|
|
161
|
-
# @regex Captured groups
|
162
204
|
# $1 = whole error
|
163
205
|
LD_ERROR_MATCHER = /^(ld:.*not found for.*)/
|
164
206
|
|
@@ -191,6 +233,7 @@ module XCPretty
|
|
191
233
|
|
192
234
|
include Matchers
|
193
235
|
include Matchers::Errors
|
236
|
+
include Matchers::Warnings
|
194
237
|
|
195
238
|
attr_reader :formatter
|
196
239
|
|
@@ -204,6 +247,7 @@ module XCPretty
|
|
204
247
|
update_linker_failure_state(text)
|
205
248
|
|
206
249
|
return format_compile_error if should_format_error?
|
250
|
+
return format_compile_warning if should_format_warning?
|
207
251
|
return format_undefined_symbols if should_format_undefined_symbols?
|
208
252
|
return format_duplicate_symbols if should_format_duplicate_symbols?
|
209
253
|
|
@@ -231,9 +275,13 @@ module XCPretty
|
|
231
275
|
when COMPILE_MATCHER
|
232
276
|
formatter.format_compile($2, $1)
|
233
277
|
when COMPILE_COMMAND_MATCHER
|
234
|
-
formatter.format_compile_command($1)
|
278
|
+
formatter.format_compile_command($1, $2)
|
235
279
|
when COMPILE_XIB_MATCHER
|
236
280
|
formatter.format_compile_xib($2, $1)
|
281
|
+
when COPY_HEADER_MATCHER
|
282
|
+
formatter.format_copy_header_file($1, $2)
|
283
|
+
when COPY_PLIST_MATCHER
|
284
|
+
formatter.format_copy_plist_file($1, $2)
|
237
285
|
when CPRESOURCE_MATCHER
|
238
286
|
formatter.format_cpresource($1)
|
239
287
|
when EXECUTED_MATCHER
|
@@ -250,6 +298,8 @@ module XCPretty
|
|
250
298
|
formatter.format_libtool($1)
|
251
299
|
when LINKING_MATCHER
|
252
300
|
formatter.format_linking($1, $2, $3)
|
301
|
+
when MEASURING_TEST_MATCHER
|
302
|
+
formatter.format_measuring_test($1, $2, $3)
|
253
303
|
when PENDING_TEST_MATCHER
|
254
304
|
formatter.format_pending_test($1, $2)
|
255
305
|
when PASSING_TEST_MATCHER
|
@@ -262,6 +312,8 @@ module XCPretty
|
|
262
312
|
formatter.format_phase_script_execution(*unescaped($1))
|
263
313
|
when PROCESS_PCH_MATCHER
|
264
314
|
formatter.format_process_pch($1)
|
315
|
+
when PROCESS_PCH_COMMAND_MATCHER
|
316
|
+
formatter.format_process_pch_command($1)
|
265
317
|
when PREPROCESS_MATCHER
|
266
318
|
formatter.format_preprocess($1)
|
267
319
|
when PBXCP_MATCHER
|
@@ -276,6 +328,14 @@ module XCPretty
|
|
276
328
|
formatter.format_tiffutil($1)
|
277
329
|
when TOUCH_MATCHER
|
278
330
|
formatter.format_touch($1, $2)
|
331
|
+
when WRITE_FILE_MATCHER
|
332
|
+
formatter.format_write_file($1)
|
333
|
+
when WRITE_AUXILIARY_FILES
|
334
|
+
formatter.format_write_auxiliary_files
|
335
|
+
when SHELL_COMMAND_MATCHER
|
336
|
+
formatter.format_shell_command($1, $2)
|
337
|
+
when GENERIC_WARNING_MATCHER
|
338
|
+
formatter.format_warning($1)
|
279
339
|
else
|
280
340
|
""
|
281
341
|
end
|
@@ -298,16 +358,21 @@ module XCPretty
|
|
298
358
|
|
299
359
|
# @ return Hash { :file_name, :file_path, :reason, :line }
|
300
360
|
def update_error_state(text)
|
361
|
+
update_error = lambda {
|
362
|
+
current_issue[:reason] = $3
|
363
|
+
current_issue[:file_path] = $1
|
364
|
+
current_issue[:file_name] = $2
|
365
|
+
}
|
301
366
|
if text =~ COMPILE_ERROR_MATCHER
|
302
367
|
@formatting_error = true
|
303
|
-
|
304
|
-
|
305
|
-
|
368
|
+
update_error.call
|
369
|
+
elsif text =~ COMPILE_WARNING_MATCHER
|
370
|
+
@formatting_warning = true
|
371
|
+
update_error.call
|
306
372
|
elsif text =~ CURSOR_MATCHER
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
current_error[:line] = text.chomp
|
373
|
+
current_issue[:cursor] = $1.chomp
|
374
|
+
elsif @formatting_error || @formatting_warning
|
375
|
+
current_issue[:line] = text.chomp
|
311
376
|
end
|
312
377
|
end
|
313
378
|
|
@@ -332,7 +397,15 @@ module XCPretty
|
|
332
397
|
|
333
398
|
# TODO: clean up the mess around all this
|
334
399
|
def should_format_error?
|
335
|
-
|
400
|
+
@formatting_error && error_or_warning_is_present
|
401
|
+
end
|
402
|
+
|
403
|
+
def should_format_warning?
|
404
|
+
@formatting_warning && error_or_warning_is_present
|
405
|
+
end
|
406
|
+
|
407
|
+
def error_or_warning_is_present
|
408
|
+
current_issue[:reason] && current_issue[:cursor] && current_issue[:line]
|
336
409
|
end
|
337
410
|
|
338
411
|
def should_format_undefined_symbols?
|
@@ -346,8 +419,8 @@ module XCPretty
|
|
346
419
|
current_linker_failure[:files].count > 1
|
347
420
|
end
|
348
421
|
|
349
|
-
def
|
350
|
-
@
|
422
|
+
def current_issue
|
423
|
+
@current_issue ||= {}
|
351
424
|
end
|
352
425
|
|
353
426
|
def current_linker_failure
|
@@ -355,8 +428,9 @@ module XCPretty
|
|
355
428
|
end
|
356
429
|
|
357
430
|
def format_compile_error
|
358
|
-
error =
|
359
|
-
@
|
431
|
+
error = current_issue.dup
|
432
|
+
@current_issue = {}
|
433
|
+
@formatting_error = false
|
360
434
|
formatter.format_compile_error(error[:file_name],
|
361
435
|
error[:file_path],
|
362
436
|
error[:reason],
|
@@ -364,6 +438,17 @@ module XCPretty
|
|
364
438
|
error[:cursor])
|
365
439
|
end
|
366
440
|
|
441
|
+
def format_compile_warning
|
442
|
+
warning = current_issue.dup
|
443
|
+
@current_issue = {}
|
444
|
+
@formatting_warning = false
|
445
|
+
formatter.format_compile_warning(warning[:file_name],
|
446
|
+
warning[:file_path],
|
447
|
+
warning[:reason],
|
448
|
+
warning[:line],
|
449
|
+
warning[:cursor])
|
450
|
+
end
|
451
|
+
|
367
452
|
def format_undefined_symbols
|
368
453
|
result = formatter.format_undefined_symbols(
|
369
454
|
current_linker_failure[:message],
|
@@ -418,4 +503,3 @@ module XCPretty
|
|
418
503
|
|
419
504
|
end
|
420
505
|
end
|
421
|
-
|