xcpretty-security-patched 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.hound.yml +2 -0
  4. data/.kick +17 -0
  5. data/.rubocop.yml +239 -0
  6. data/.travis.yml +12 -0
  7. data/CHANGELOG.md +269 -0
  8. data/CONTRIBUTING.md +64 -0
  9. data/Gemfile +9 -0
  10. data/LICENSE.txt +61 -0
  11. data/README.md +95 -0
  12. data/Rakefile +18 -0
  13. data/assets/report.html.erb +173 -0
  14. data/bin/xcpretty +90 -0
  15. data/features/assets/RACCommandSpec_enabled_signal_should_send_YES_while_executing_is_YES.png +0 -0
  16. data/features/assets/apple_raw.png +0 -0
  17. data/features/custom_formatter.feature +15 -0
  18. data/features/custom_reporter.feature +29 -0
  19. data/features/fixtures/xcodebuild.log +5963 -0
  20. data/features/html_report.feature +54 -0
  21. data/features/json_compilation_database_report.feature +33 -0
  22. data/features/junit_report.feature +49 -0
  23. data/features/knock_format.feature +11 -0
  24. data/features/simple_format.feature +238 -0
  25. data/features/steps/custom_reporter_steps.rb +16 -0
  26. data/features/steps/formatting_steps.rb +386 -0
  27. data/features/steps/html_steps.rb +32 -0
  28. data/features/steps/json_steps.rb +45 -0
  29. data/features/steps/junit_steps.rb +39 -0
  30. data/features/steps/report_steps.rb +27 -0
  31. data/features/steps/xcpretty_steps.rb +31 -0
  32. data/features/support/env.rb +123 -0
  33. data/features/tap_format.feature +31 -0
  34. data/features/test_format.feature +49 -0
  35. data/features/xcpretty.feature +14 -0
  36. data/lib/xcpretty/ansi.rb +72 -0
  37. data/lib/xcpretty/formatters/formatter.rb +200 -0
  38. data/lib/xcpretty/formatters/knock.rb +35 -0
  39. data/lib/xcpretty/formatters/rspec.rb +33 -0
  40. data/lib/xcpretty/formatters/simple.rb +200 -0
  41. data/lib/xcpretty/formatters/tap.rb +40 -0
  42. data/lib/xcpretty/parser.rb +596 -0
  43. data/lib/xcpretty/printer.rb +28 -0
  44. data/lib/xcpretty/reporters/html.rb +93 -0
  45. data/lib/xcpretty/reporters/json_compilation_database.rb +51 -0
  46. data/lib/xcpretty/reporters/junit.rb +102 -0
  47. data/lib/xcpretty/reporters/reporter.rb +62 -0
  48. data/lib/xcpretty/snippet.rb +38 -0
  49. data/lib/xcpretty/syntax.rb +58 -0
  50. data/lib/xcpretty/term.rb +14 -0
  51. data/lib/xcpretty/version.rb +4 -0
  52. data/lib/xcpretty.rb +38 -0
  53. data/spec/fixtures/NSStringTests.m +64 -0
  54. data/spec/fixtures/constants.rb +707 -0
  55. data/spec/fixtures/custom_formatter.rb +18 -0
  56. data/spec/fixtures/custom_reporter.rb +30 -0
  57. data/spec/fixtures/oneliner.m +1 -0
  58. data/spec/fixtures/raw_kiwi_compilation_fail.txt +24 -0
  59. data/spec/fixtures/raw_kiwi_fail.txt +1896 -0
  60. data/spec/fixtures/raw_specta_fail.txt +3110 -0
  61. data/spec/spec_helper.rb +7 -0
  62. data/spec/support/matchers/colors.rb +21 -0
  63. data/spec/xcpretty/ansi_spec.rb +47 -0
  64. data/spec/xcpretty/formatters/formatter_spec.rb +151 -0
  65. data/spec/xcpretty/formatters/rspec_spec.rb +56 -0
  66. data/spec/xcpretty/formatters/simple_spec.rb +178 -0
  67. data/spec/xcpretty/parser_spec.rb +636 -0
  68. data/spec/xcpretty/printer_spec.rb +55 -0
  69. data/spec/xcpretty/reporters/junit_spec.rb +20 -0
  70. data/spec/xcpretty/reporters/reporter_spec.rb +40 -0
  71. data/spec/xcpretty/snippet_spec.rb +46 -0
  72. data/spec/xcpretty/syntax_spec.rb +39 -0
  73. data/spec/xcpretty/term_spec.rb +26 -0
  74. data/xcpretty.gemspec +37 -0
  75. metadata +250 -0
@@ -0,0 +1,636 @@
1
+ # encoding: utf-8
2
+
3
+ require 'xcpretty'
4
+ require 'xcpretty/parser'
5
+ require 'fixtures/constants'
6
+
7
+ module XCPretty
8
+
9
+ describe Parser do
10
+
11
+ before(:each) do
12
+ @formatter = Formatter.new(false, false)
13
+ @parser = Parser.new(@formatter)
14
+ end
15
+
16
+ it "parses analyze" do
17
+ @formatter.should receive(:format_analyze).with("CCChip8DisplayView.m", "CocoaChip/CCChip8DisplayView.m")
18
+ @parser.parse(SAMPLE_ANALYZE)
19
+ end
20
+
21
+ it "parses analyze shallow" do
22
+ @formatter.should receive(:format_analyze).with("CCChip8DisplayView.m", "CocoaChip/CCChip8DisplayView.m")
23
+ @parser.parse(SAMPLE_ANALYZE_SHALLOW)
24
+ end
25
+
26
+ it "parses analyze for a C++ target" do
27
+ @formatter.should receive(:format_analyze).with("CCChip8DisplayView.cpp", "CocoaChip/CCChip8DisplayView.cpp")
28
+ @parser.parse(SAMPLE_ANALYZE_CPP)
29
+ end
30
+
31
+ it "parses build target" do
32
+ @formatter.should receive(:format_build_target).with("The Spacer", "Pods", "Debug")
33
+ @parser.parse(SAMPLE_BUILD)
34
+ end
35
+
36
+ it "parses aggregate target" do
37
+ @formatter.should receive(:format_aggregate_target).with("Be Aggro", "AggregateExample", "Debug")
38
+ @parser.parse(SAMPLE_AGGREGATE_TARGET)
39
+ end
40
+
41
+ it "parses analyze target" do
42
+ @formatter.should receive(:format_analyze_target).with("The Spacer", "Pods", "Debug")
43
+ @parser.parse(SAMPLE_ANALYZE_TARGET)
44
+ end
45
+
46
+ it "parses clean remove" do
47
+ @formatter.should receive(:format_clean_remove)
48
+ @parser.parse(SAMPLE_CLEAN_REMOVE)
49
+ end
50
+
51
+ it "parses clean target" do
52
+ @formatter.should receive(:format_clean_target).with("Pods-ObjectiveSugar", "Pods", "Debug")
53
+ @parser.parse(SAMPLE_CLEAN)
54
+ end
55
+
56
+ it "parses clean target withut dash in target name" do
57
+ @formatter.should receive(:format_clean_target).with("Pods", "Pods", "Debug")
58
+ @parser.parse(SAMPLE_ANOTHER_CLEAN)
59
+ end
60
+
61
+ it "parses check dependencies" do
62
+ @formatter.should receive(:format_check_dependencies)
63
+ @parser.parse("Check dependencies")
64
+ end
65
+
66
+ it "parses code signing" do
67
+ @formatter.should receive(:format_codesign).with("build/Release/CocoaChip.app")
68
+ @parser.parse(SAMPLE_CODESIGN)
69
+ end
70
+
71
+ it "parses code signing a framework" do
72
+ @formatter.should receive(:format_codesign).with("build/Release/CocoaChipCore.framework")
73
+ @parser.parse(SAMPLE_CODESIGN_FRAMEWORK)
74
+ end
75
+
76
+ it 'parses compiler_space_in_path' do
77
+ @formatter.should receive(:format_compile).with('SASellableItem.m', "SACore/App/Models/Core\\ Data/human/SASellableItem.m")
78
+ @parser.parse(SAMPLE_COMPILE_SPACE_IN_PATH)
79
+ end
80
+
81
+ it "parses compiler commands" do
82
+ compile_statement = SAMPLE_ANOTHER_COMPILE.lines.to_a.last
83
+ @formatter.should receive(:format_compile_command).with(compile_statement.strip, "/Users/musalj/code/OSS/Kiwi/Classes/Core/KWNull.m")
84
+ @parser.parse(compile_statement)
85
+ end
86
+
87
+ it "parses compiling categories" do
88
+ @formatter.should receive(:format_compile).with("NSMutableArray+ObjectiveSugar.m", "/Users/musalj/code/OSS/ObjectiveSugar/Classes/NSMutableArray+ObjectiveSugar.m")
89
+ @parser.parse(SAMPLE_COMPILE)
90
+ end
91
+
92
+ it "parses compiling classes" do
93
+ @formatter.should receive(:format_compile).with("KWNull.m", "Classes/Core/KWNull.m")
94
+ @parser.parse(SAMPLE_ANOTHER_COMPILE)
95
+ end
96
+
97
+ it "parses compiling Objective-C++ classes" do
98
+ @formatter.should receive(:format_compile).with("KWNull.mm", "Classes/Core/KWNull.mm")
99
+ @parser.parse(SAMPLE_ANOTHER_COMPILE.sub('.m', '.mm'))
100
+ end
101
+
102
+ it 'parses compiling Swift source files' do
103
+ @formatter.should receive(:format_compile).with("Resource.swift", "/Users/paul/foo/bar/siesta/Source/Resource.swift")
104
+ @parser.parse(SAMPLE_SWIFT_COMPILE)
105
+ end
106
+
107
+ it "parses compiling C and C++ files" do
108
+ ['.c', '.cc', '.cpp', '.cxx'].each do |file_extension|
109
+ @formatter.should receive(:format_compile).with("KWNull" + file_extension, "Classes/Core/KWNull" + file_extension)
110
+ @parser.parse(SAMPLE_ANOTHER_COMPILE.sub('.m', file_extension))
111
+ end
112
+ end
113
+
114
+ it "parses compiling XIBs" do
115
+ @formatter.should receive(:format_compile_xib).with("MainMenu.xib", "CocoaChip/en.lproj/MainMenu.xib")
116
+ @parser.parse(SAMPLE_COMPILE_XIB)
117
+ end
118
+
119
+ it "parses compiling storyboards" do
120
+ @formatter.should receive(:format_compile_storyboard).with("Main.storyboard", "sample/Main.storyboard")
121
+ @parser.parse(SAMPLE_COMPILE_STORYBOARD)
122
+ end
123
+
124
+ it 'parses CopyPlistFile' do
125
+ @formatter.should receive(:format_copy_plist_file).with(
126
+ '/path/to/Some.plist', '/some other/File.plist')
127
+ @parser.parse('CopyPlistFile /path/to/Some.plist /some other/File.plist')
128
+ end
129
+
130
+ it "parses CopyStringsFile" do
131
+ @formatter.should receive(:format_copy_strings_file).with('InfoPlist.strings')
132
+ @parser.parse(SAMPLE_COPYSTRINGS)
133
+ end
134
+
135
+ it "parses CpHeader" do
136
+ @formatter.should receive(:format_copy_header_file).with(
137
+ '/path/to/Header.h', '/some other/path/Header.h')
138
+ @parser.parse('CpHeader /path/to/Header.h /some other/path/Header.h')
139
+ end
140
+
141
+ it "parses CpResource" do
142
+ @formatter.should receive(:format_cpresource).with('ObjectiveSugar/Default-568h@2x.png')
143
+ @parser.parse(SAMPLE_CPRESOURCE)
144
+ end
145
+
146
+ it "parses GenerateDSYMFile" do
147
+ @formatter.should receive(:format_generate_dsym).with('ObjectiveSugarTests.octest.dSYM')
148
+ @parser.parse(SAMPLE_DSYM)
149
+ end
150
+
151
+ it "parses info.plist processing" do
152
+ @formatter.should receive(:format_process_info_plist).with('The Spacer-Info.plist', 'The Spacer/The Spacer-Info.plist')
153
+ @parser.parse(SAMPLE_PROCESS_INFOPLIST)
154
+ end
155
+
156
+ it "parses Ld" do
157
+ @formatter.should receive(:format_linking).with('ObjectiveSugar', 'normal', 'i386')
158
+ @parser.parse(SAMPLE_LD)
159
+ end
160
+
161
+ it "parses Ld with relative path" do
162
+ @formatter.should receive(:format_linking).with('ObjectiveSugar', 'normal', 'i386')
163
+ @parser.parse(SAMPLE_LD_RELATIVE)
164
+ end
165
+
166
+ it "parses Libtool" do
167
+ @formatter.should receive(:format_libtool).with('libPods-ObjectiveSugarTests-Kiwi.a')
168
+ @parser.parse(SAMPLE_LIBTOOL)
169
+ end
170
+
171
+ it "parses uitest failing tests" do
172
+ @formatter.should receive(:format_failing_test).with(
173
+ "viewUITests.vmtAboutWindow",
174
+ "testConnectToDesktop",
175
+ "UI Testing Failure - Unable to find hit point for element Button 0x608001165880: {{74.0, -54.0}, {44.0, 38.0}}, label: 'Disconnect'",
176
+ "<unknown>:0"
177
+ )
178
+ @parser.parse(SAMPLE_UITEST_CASE_WITH_FAILURE)
179
+ end
180
+
181
+ it "parses specta failing tests" do
182
+ @formatter.should receive(:format_failing_test).with("SKWelcomeViewControllerSpecSpec",
183
+ "SKWelcomeViewController_When_a_user_opens_the_app_from_a_clean_installation_displays_the_welcome_screen",
184
+ "The step timed out after 2.00 seconds: Failed to find accessibility element with the label \"The asimplest way to make smarter business decisions\"",
185
+ "/Users/vickeryj/Code/ipad-register/KIFTests/Specs/SKWelcomeViewControllerSpec.m:11")
186
+ @parser.parse(SAMPLE_SPECTA_FAILURE)
187
+ end
188
+
189
+ it "parses old specta failing tests" do
190
+ @formatter.should receive(:format_failing_test).with("RACCommandSpec",
191
+ "enabled_signal_should_send_YES_while_executing_is_YES_and_allowsConcurrentExecution_is_YES",
192
+ "expected: 1, got: 0",
193
+ "/Users/musalj/code/OSS/ReactiveCocoa/ReactiveCocoaFramework/ReactiveCocoaTests/RACCommandSpec.m:458")
194
+ @parser.parse(SAMPLE_OLD_SPECTA_FAILURE)
195
+ end
196
+
197
+ it "parses ld bitcode errors" do
198
+ @formatter.should receive(:format_error).with(SAMPLE_BITCODE_LD.strip)
199
+ @parser.parse(SAMPLE_BITCODE_LD)
200
+ end
201
+
202
+ it "parses passing ocunit tests" do
203
+ @formatter.should receive(:format_passing_test).with('RACCommandSpec',
204
+ 'enabled_signal_should_send_YES_while_executing_is_YES',
205
+ '0.001')
206
+ @parser.parse(SAMPLE_OCUNIT_TEST)
207
+ end
208
+
209
+ it "parses passing specta tests" do
210
+ @formatter.should receive(:format_passing_test).with('SKWelcomeActivationViewControllerSpecSpec',
211
+ 'SKWelcomeActivationViewController_When_a_user_enters_their_details_lets_them_enter_a_valid_manager_code',
212
+ '0.725')
213
+ @parser.parse(SAMPLE_SPECTA_TEST)
214
+ end
215
+
216
+ it "parses pending tests" do
217
+ @formatter.should receive(:format_pending_test).with('TAPIConversationSpec',
218
+ 'TAPIConversation_createConversation_SendsAPOSTRequestToTheConversationsEndpoint')
219
+ @parser.parse(SAMPLE_PENDING_KIWI_TEST)
220
+ end
221
+
222
+ it 'parses measuring tests' do
223
+ @formatter.should receive(:format_measuring_test).with(
224
+ 'SecEncodeTransformTests.SecEncodeTransformTests',
225
+ 'test_RFC4648_Decode_UsingBase32',
226
+ '0.013'
227
+ )
228
+ @parser.parse(SAMPLE_MEASURING_TEST)
229
+ end
230
+
231
+ it "parses build success indicator" do
232
+ @formatter.should receive(:format_phase_success).with('BUILD')
233
+ @parser.parse(SAMPLE_BUILD_SUCCEEDED)
234
+ end
235
+
236
+ it "parses clean success indicator" do
237
+ @formatter.should receive(:format_phase_success).with('CLEAN')
238
+ @parser.parse(SAMPLE_CLEAN_SUCCEEDED)
239
+ end
240
+
241
+ it "parses PhaseScriptExecution" do
242
+ @formatter.should receive(:format_phase_script_execution).with('Check Pods Manifest.lock')
243
+ @parser.parse(SAMPLE_RUN_SCRIPT)
244
+ end
245
+
246
+ it "parses process PCH" do
247
+ @formatter.should receive(:format_process_pch).with("Pods-CocoaLumberjack-prefix.pch")
248
+ @parser.parse(SAMPLE_PRECOMPILE)
249
+ end
250
+
251
+ it 'parses process PCH command' do
252
+ compile_statement = SAMPLE_PRECOMPILE.lines.to_a.last
253
+ @formatter.should receive(:format_process_pch_command).with("/Users/musalj/code/OSS/ObjectiveRecord/Pods/Pods-CocoaLumberjack-prefix.pch")
254
+ @parser.parse(compile_statement)
255
+ end
256
+
257
+ it "parses preprocessing" do
258
+ @formatter.should receive(:format_preprocess).with("CocoaChip/CocoaChip-Info.plist")
259
+ @parser.parse(SAMPLE_PREPROCESS)
260
+ end
261
+
262
+ it "parses PBXCp" do
263
+ @formatter.should receive(:format_pbxcp).with("build/Release/CocoaChipCore.framework")
264
+ @parser.parse(SAMPLE_PBXCP)
265
+ end
266
+
267
+ it 'parses changing directories' do
268
+ @formatter.should receive(:format_shell_command).with('cd',
269
+ '/some/place/out\ there')
270
+ @parser.parse(' cd /some/place/out\ there')
271
+ end
272
+
273
+ it 'parses any indented command' do
274
+ @formatter.should receive(:format_shell_command).with(
275
+ '/bin/rm', '-rf /bin /usr /Users')
276
+ @parser.parse(' /bin/rm -rf /bin /usr /Users')
277
+ end
278
+
279
+ it "parses Touch" do
280
+ @formatter.should receive(:format_touch).with(
281
+ '/Users/musalj/Library/Developer/Xcode/DerivedData/Alcatraz-aobuxcinaqyzjugrnxjjhfzgwaou/Build/Products/Debug/Alcatraz Tests.octest',
282
+ 'Alcatraz Tests.octest')
283
+ @parser.parse(SAMPLE_TOUCH)
284
+ end
285
+
286
+ it "parses write file" do
287
+ @formatter.should receive(:format_write_file).with(
288
+ '/Users/me/myproject/Build/Intermediates/Pods.build/Debug-iphonesimulator/Pods-AFNetworking.build/Objects-normal/x86_64/Pods-AFNetworking.LinkFileList')
289
+ @parser.parse(SAMPLE_WRITE_FILE)
290
+ end
291
+
292
+ it "parses write auxiliary files" do
293
+ @formatter.should receive(:format_write_auxiliary_files)
294
+ @parser.parse(SAMPLE_WRITE_AUXILIARY_FILES)
295
+ end
296
+
297
+ it "parses TiffUtil" do
298
+ @formatter.should receive(:format_tiffutil).with('eye_icon.tiff')
299
+ @parser.parse(SAMPLE_TIFFUTIL)
300
+ end
301
+
302
+ it "parses undefined symbols" do
303
+ @formatter.should receive(:format_undefined_symbols).with("Undefined symbols for architecture x86_64",
304
+ '_OBJC_CLASS_$_CABasicAnimation',
305
+ 'objc-class-ref in ATZRadialProgressControl.o')
306
+ SAMPLE_UNDEFINED_SYMBOLS.each_line do |line|
307
+ @parser.parse(line)
308
+ end
309
+ end
310
+
311
+ it "parses duplicate symbols" do
312
+ @formatter.should receive(:format_duplicate_symbols).with(
313
+ "duplicate symbol _OBJC_IVAR_$ClassName._ivarName in",
314
+ [
315
+ '/Users/username/Library/Developer/Xcode/DerivedData/App-arcyyktezaigixbocjwfhsjllojz/Build/Intermediates/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/ClassName.o',
316
+ '/Users/username/Library/Developer/Xcode/DerivedData/App-arcyyktezaigixbocjwfhsjllojz/Build/Products/Debug-iphonesimulator/libPods.a(DuplicateClassName.o)'
317
+ ]
318
+ )
319
+ SAMPLE_DUPLICATE_SYMBOLS.each_line do |line|
320
+ @parser.parse(line)
321
+ end
322
+ end
323
+
324
+ it "parses ocunit test run finished" do
325
+ @formatter.should receive(:format_test_run_finished).with('ReactiveCocoaTests.octest(Tests)', '2013-12-10 07:03:03 +0000.')
326
+ @parser.parse(SAMPLE_OCUNIT_TEST_RUN_COMPLETION)
327
+ end
328
+
329
+ it "parses ocunit test run passed" do
330
+ @formatter.should receive(:format_test_run_finished).with('Hazelnuts.xctest', '2014-09-24 23:09:20 +0000.')
331
+ @parser.parse(SAMPLE_OCUNIT_PASSED_TEST_RUN_COMPLETION)
332
+ end
333
+
334
+ it "parses ocunit test run failed" do
335
+ @formatter.should receive(:format_test_run_finished).with('Macadamia.octest', '2014-09-24 23:09:20 +0000.')
336
+ @parser.parse(SAMPLE_OCUNIT_FAILED_TEST_RUN_COMPLETION)
337
+ end
338
+
339
+ it "parses specta test run finished" do
340
+ @formatter.should receive(:format_test_run_finished).with('KIFTests.xctest', '2014-02-28 15:44:32 +0000.')
341
+ @parser.parse(SAMPLE_SPECTA_TEST_RUN_COMPLETION)
342
+ end
343
+
344
+ it "parses ocunit test run started" do
345
+ @formatter.should receive(:format_test_run_started).with('ReactiveCocoaTests.octest(Tests)')
346
+ @parser.parse(SAMPLE_OCUNIT_TEST_RUN_BEGINNING)
347
+ end
348
+
349
+ it "parses specta test run started" do
350
+ @formatter.should receive(:format_test_run_started).with('KIFTests.xctest')
351
+ @parser.parse(SAMPLE_SPECTA_TEST_RUN_BEGINNING)
352
+ end
353
+
354
+ it "parses ocunit test suite started" do
355
+ @formatter.should receive(:format_test_suite_started).with('RACKVOWrapperSpec')
356
+ @parser.parse(SAMPLE_OCUNIT_SUITE_BEGINNING)
357
+ end
358
+
359
+ it "parses specta test suite started" do
360
+ @formatter.should receive(:format_test_suite_started).with('All tests')
361
+ @parser.parse(SAMPLE_SPECTA_SUITE_BEGINNING)
362
+ end
363
+
364
+ it "parses unknown strings" do
365
+ @formatter.should receive(:format_other).with(
366
+ SAMPLE_FORMAT_OTHER_UNRECOGNIZED_STRING
367
+ )
368
+ @parser.parse(SAMPLE_FORMAT_OTHER_UNRECOGNIZED_STRING)
369
+ end
370
+
371
+ context "errors" do
372
+ it "parses clang errors" do
373
+ @formatter.should receive(:format_error).with(SAMPLE_CLANG_ERROR)
374
+ @parser.parse(SAMPLE_CLANG_ERROR)
375
+ end
376
+
377
+ it "parses cocoapods errors" do
378
+ @formatter.should receive(:format_error).with("error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.")
379
+ @parser.parse(SAMPLE_PODS_ERROR)
380
+ end
381
+
382
+ it "parses compiling errors" do
383
+ @formatter.should receive(:format_compile_error).with(
384
+ "SampleTest.m",
385
+ "/Users/musalj/code/OSS/SampleApp/SampleTest.m:12:59",
386
+ "expected identifier",
387
+ " [[thread.lastMessage should] equal:thread.];",
388
+ " ^")
389
+ SAMPLE_COMPILE_ERROR.each_line do |line|
390
+ @parser.parse(line)
391
+ end
392
+ end
393
+
394
+ it 'parses fatal compiling errors' do
395
+ @formatter.should receive(:format_compile_error).with(
396
+ 'SomeRandomClass.h',
397
+ '/Users/musalj/code/OSS/SampleApp/Pods/Headers/LessCoolPod/SomeRandomClass.h:31:9',
398
+ "'SomeRandomHeader.h' file not found",
399
+ '#import "SomeRandomHeader.h"',
400
+ ' ^'
401
+ # For now, it's probably not worth to provide the import stack
402
+ # It'd require more state, and not sure if it'd be any useful
403
+ # %Q(In file included from /Users/musalj/code/OSS/SampleApp/Pods/SuperCoolPod/SuperAwesomeClass.m:12:
404
+ # In file included from /Users/musalj/code/OSS/SampleApp/Pods/../LessCoolPod/LessCoolClass.h:9:
405
+ # In file included from /Users/musalj/code/OSS/SampleApp/Pods/../LessCoolPod/EvenLessCoolClass.h:10:)
406
+ )
407
+ SAMPLE_FATAL_COMPILE_ERROR.each_line do |line|
408
+ @parser.parse(line)
409
+ end
410
+ end
411
+
412
+ it 'parses file missing errors' do
413
+ @formatter.should receive(:format_file_missing_error).with(
414
+ 'error: no such file or directory:',
415
+ '/Users/travis/build/supermarin/project/Classes/Class + Category/Two Words/MissingViewController.swift'
416
+ )
417
+ @parser.parse(SAMPLE_FILE_MISSING_ERROR)
418
+ end
419
+
420
+ it 'parses fatal error: on the beginning of the line for corrupted AST files' do
421
+ @formatter.should receive(:format_error).with(
422
+ "fatal error: malformed or corrupted AST file: 'could not find file '/Users/mpv/dev/project/Crashlytics.framework/Headers/Crashlytics.h' referenced by AST file' note: after modifying system headers, please delete the module cache at '/Users/mpv/Library/Developer/Xcode/DerivedData/ModuleCache/M5WJ0FYE7N06'"
423
+ )
424
+ @parser.parse(SAMPLE_FATAL_HEADER_ERROR)
425
+ end
426
+
427
+ it 'parses fatal error: on the beginning of the line for cached PCH' do
428
+ @formatter.should receive(:format_error).with(
429
+ "fatal error: file '/path/to/myproject/Pods/Pods-environment.h' has been modified since the precompiled header '/Users/hiroshi/Library/Developer/Xcode/DerivedData/MyProject-gfmuvpipjscewkdnqacgumhfarrd/Build/Intermediates/PrecompiledHeaders/MyProject-Prefix-dwjpvcnrlaydzmegejmcvrtcfkpf/MyProject-Prefix.pch.pch' was built"
430
+ )
431
+ @parser.parse(SAMPLE_FATAL_COMPILE_PCH_ERROR)
432
+ end
433
+
434
+
435
+
436
+ it "parses compiling errors with tildes" do
437
+ @formatter.should receive(:format_compile_error).with(
438
+ 'NSSetTests.m',
439
+ '/Users/musalj/code/OSS/ObjectiveSugar/Example/ObjectiveSugarTests/NSSetTests.m:93:16',
440
+ "no visible @interface for 'NSArray' declares the selector 'shoulds'",
441
+ ' }] shoulds] equal:@[ @"F458 Italia", @"Testarossa" ]];',
442
+ ' ~~ ^~~~~~~')
443
+ SAMPLE_COMPILE_ERROR_WITH_TILDES.each_line do |line|
444
+ @parser.parse(line)
445
+ end
446
+ end
447
+
448
+ it "parses code sign error:" do
449
+ @formatter.should receive(:format_error).with(
450
+ 'Code Sign error: No code signing identites found: No valid signing identities (i.e. certificate and private key pair) matching the team ID “CAT6HF57NJ” were found.'
451
+ )
452
+ @parser.parse(SAMPLE_CODESIGN_ERROR)
453
+ end
454
+
455
+ it "parses CodeSign error: (no spaces)" do
456
+ @formatter.should receive(:format_error).with(
457
+ "CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 7.0'"
458
+ )
459
+ @parser.parse(SAMPLE_CODESIGN_ERROR_NO_SPACES)
460
+ end
461
+
462
+ it "parses No profile matching error:" do
463
+ @formatter.should receive(:format_error).with(
464
+ "No profile matching 'TargetName' found: Xcode couldn't find a profile matching 'TargetName'. Install the profile (by dragging and dropping it onto Xcode's dock item) or select a different one in the General tab of the target editor."
465
+ )
466
+ @parser.parse(SAMPLE_NO_PROFILE_MATCHING_ERROR)
467
+ end
468
+
469
+ it "parses requires provision error:" do
470
+ @formatter.should receive(:format_error).with(
471
+ 'PROJECT_NAME requires a provisioning profile. Select a provisioning profile for the "Debug" build configuration in the project editor.'
472
+ )
473
+ @parser.parse(SAMPLE_REQUIRES_PROVISION)
474
+ end
475
+
476
+ it "parses no certificate error:" do
477
+ @formatter.should receive(:format_error).with(
478
+ "No certificate matching 'iPhone Distribution: Name (B89SBB0AV9)' for team 'B89SBB0AV9': Select a different signing certificate for CODE_SIGN_IDENTITY, a team that matches your selected certificate, or switch to automatic provisioning."
479
+ )
480
+ @parser.parse(SAMPLE_NO_CERTIFICATE)
481
+ end
482
+
483
+ it "parses swift unavailable error:" do
484
+ @formatter.should receive(:format_error).with(
485
+ SAMPLE_SWIFT_UNAVAILABLE
486
+ )
487
+ @parser.parse(SAMPLE_SWIFT_UNAVAILABLE)
488
+ end
489
+
490
+ it "parses use legacy swift error:" do
491
+ @formatter.should receive(:format_error).with(
492
+ SAMPLE_USE_LEGACY_SWIFT
493
+ )
494
+ @parser.parse(SAMPLE_USE_LEGACY_SWIFT)
495
+ end
496
+
497
+ it "parses ld library errors" do
498
+ @formatter.should receive(:format_error).with(
499
+ SAMPLE_LD_LIBRARY_ERROR
500
+ )
501
+ @parser.parse(SAMPLE_LD_LIBRARY_ERROR)
502
+ end
503
+
504
+ it 'parses ld symbols errors' do
505
+ @formatter.should receive(:format_error).with(
506
+ SAMPLE_LD_SYMBOLS_ERROR
507
+ )
508
+ @parser.parse(SAMPLE_LD_SYMBOLS_ERROR)
509
+ end
510
+
511
+ it "doesn't print the same error over and over" do
512
+ SAMPLE_COMPILE_ERROR.each_line do |line|
513
+ @parser.parse(line)
514
+ end
515
+ @formatter.should_not receive(:format_compile_error)
516
+ @parser.parse("hohohoooo")
517
+ end
518
+
519
+ it "parses provisioning profile doesn't support capability error" do
520
+ @formatter.should receive(:format_error)
521
+ @parser.parse(SAMPLE_PROFILE_DOESNT_SUPPORT_CAPABILITY_ERROR)
522
+ end
523
+
524
+ it "parses provisioning profile doesn't include entitlement error" do
525
+ @formatter.should receive(:format_error)
526
+ @parser.parse(SAMPLE_PROFILE_DOESNT_INCLUDE_ENTITLEMENT_ERROR)
527
+ end
528
+
529
+ it "parses code signing is required error" do
530
+ @formatter.should receive(:format_error)
531
+ @parser.parse(SAMPLE_CODE_SIGNING_IS_REQUIRED_ERROR)
532
+ end
533
+
534
+ it "parses module includes error" do
535
+ @formatter.should receive(:format_error).with(
536
+ "error: umbrella header for module 'ModuleName' does not include header 'Header.h'"
537
+ )
538
+ @parser.parse(SAMPLE_MODULE_INCLUDES_ERROR)
539
+ end
540
+ end
541
+
542
+ context "warnings" do
543
+ it 'parses compiler warnings' do
544
+ @formatter.should receive(:format_warning).with("TEST 123")
545
+ @parser.parse("warning: TEST 123")
546
+ end
547
+
548
+ it "parses compiling warnings" do
549
+ @formatter.should receive(:format_compile_warning).with(
550
+ "AppDelegate.m",
551
+ "/Users/supermarin/code/oss/ObjectiveSugar/Example/ObjectiveSugar/AppDelegate.m:19:31",
552
+ "format specifies type 'id' but the argument has type 'int' [-Wformat]",
553
+ " NSLog(@\"I HAZ %@ CATS\", 1);",
554
+ " ~~ ^")
555
+ SAMPLE_FORMAT_WARNING.each_line do |line|
556
+ @parser.parse(line)
557
+ end
558
+ end
559
+
560
+ it "parses ld warnings" do
561
+ @formatter.should receive(:format_ld_warning).with("ld: embedded dylibs/frameworks only run on iOS 8 or later")
562
+ @parser.parse("ld: warning: embedded dylibs/frameworks only run on iOS 8 or later")
563
+ end
564
+
565
+ it "parses will not be code signed warnings" do
566
+ @formatter.should receive(:format_will_not_be_code_signed).with(SAMPLE_WILL_NOT_BE_CODE_SIGNED)
567
+ @parser.parse(SAMPLE_WILL_NOT_BE_CODE_SIGNED)
568
+ end
569
+ end
570
+
571
+ context "summary" do
572
+ def given_tests_have_started(reporter = SAMPLE_OCUNIT_TEST_RUN_BEGINNING)
573
+ @parser.parse(reporter)
574
+ end
575
+
576
+ def given_tests_are_done(reporter = SAMPLE_OCUNIT_TEST_RUN_COMPLETION)
577
+ @parser.parse(reporter)
578
+ end
579
+
580
+ def given_kiwi_tests_are_done
581
+ @parser.parse(SAMPLE_KIWI_TEST_RUN_COMPLETION)
582
+ @parser.parse(SAMPLE_EXECUTED_TESTS)
583
+ @parser.parse(SAMPLE_KIWI_SUITE_COMPLETION)
584
+ end
585
+
586
+ it "returns empty string if the suite is not done" do
587
+ @parser.parse(SAMPLE_EXECUTED_TESTS).should == ""
588
+ end
589
+
590
+ it "knows when the test suite is done for OCunit" do
591
+ given_tests_are_done
592
+ @formatter.should receive(:format_test_summary)
593
+ @parser.parse(SAMPLE_EXECUTED_TESTS)
594
+ end
595
+
596
+ it "knows when the test suite is done for Specta" do
597
+ given_tests_are_done
598
+ @formatter.should receive(:format_test_summary)
599
+ @parser.parse(SAMPLE_SPECTA_EXECUTED_TESTS)
600
+ end
601
+
602
+ it "doesn't print executed message twice for Kiwi tests" do
603
+ @formatter.should_receive(:format_test_summary).once
604
+ given_tests_have_started(SAMPLE_KIWI_TEST_RUN_BEGINNING)
605
+ given_kiwi_tests_are_done
606
+ end
607
+
608
+ it "knows when the test suite is done for XCtest" do
609
+ @formatter.should_receive(:format_test_summary).once
610
+ 2.times {
611
+ given_tests_are_done(SAMPLE_KIWI_TEST_RUN_COMPLETION)
612
+ @parser.parse(SAMPLE_EXECUTED_TESTS)
613
+ }
614
+ end
615
+
616
+ it "prints OCunit / XCTest summary twice if tests executed twice" do
617
+ @formatter.should_receive(:format_test_summary).twice
618
+ 2.times {
619
+ given_tests_have_started
620
+ given_tests_are_done
621
+ @parser.parse(SAMPLE_EXECUTED_TESTS)
622
+ }
623
+ end
624
+
625
+ it "prints Kiwi summary twice if tests executed twice" do
626
+ @formatter.should_receive(:format_test_summary).twice
627
+ 2.times {
628
+ given_tests_have_started(SAMPLE_KIWI_TEST_RUN_BEGINNING)
629
+ given_kiwi_tests_are_done
630
+ }
631
+ end
632
+ end
633
+
634
+ end
635
+ end
636
+
@@ -0,0 +1,55 @@
1
+ require "xcpretty/printer"
2
+ require 'xcpretty/formatters/formatter'
3
+ require 'xcpretty/formatters/simple'
4
+
5
+ module XCPretty
6
+ describe Printer do
7
+
8
+ before(:each) do
9
+ STDOUT.stub(:print) { |text| text }
10
+ @printer = Printer.new(colorize: true, unicode: true, formatter: DummyFormatter)
11
+ end
12
+
13
+ it "prints to stdout" do
14
+ STDOUT.should receive(:print).with("hey ho let's go\n")
15
+ @printer.pretty_print("hey ho let's go")
16
+ end
17
+
18
+ it "doesn't print empty lines" do
19
+ STDOUT.should_not receive(:print)
20
+ @printer.pretty_print("")
21
+ end
22
+
23
+ it "prints with newlines only when needed" do
24
+ @printer.formatter.stub(:optional_newline).and_return("")
25
+
26
+ STDOUT.should receive(:print).with("hey ho let's go")
27
+ @printer.pretty_print("hey ho let's go")
28
+ end
29
+
30
+ it "makes a formatter with unicode and colorized flags" do
31
+ @printer.formatter.colorize?.should == true
32
+ @printer.formatter.use_unicode?.should == true
33
+ end
34
+
35
+ end
36
+ end
37
+
38
+ module XCPretty
39
+ class DummyFormatter < Formatter
40
+
41
+ def initialize(unicode, colorize)
42
+ @use_unicode = unicode
43
+ @colorize = colorize
44
+ end
45
+
46
+ def pretty_format(text)
47
+ text
48
+ end
49
+
50
+ def optional_newline
51
+ "\n"
52
+ end
53
+ end
54
+ end
55
+