xcpretty-bb 0.1.12.bb1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) 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 +11 -0
  7. data/CHANGELOG.md +200 -0
  8. data/CONTRIBUTING.md +64 -0
  9. data/Gemfile +9 -0
  10. data/LICENSE.txt +61 -0
  11. data/README.md +93 -0
  12. data/Rakefile +26 -0
  13. data/assets/report.html.erb +172 -0
  14. data/bin/xcpretty +85 -0
  15. data/features/assets/RACCommandSpec, line 80, hello xcpretty.png +0 -0
  16. data/features/assets/apple_raw.png +0 -0
  17. data/features/custom_formatter.feature +15 -0
  18. data/features/fixtures/xcodebuild.log +5963 -0
  19. data/features/html_report.feature +54 -0
  20. data/features/json_compilation_database_report.feature +21 -0
  21. data/features/junit_report.feature +44 -0
  22. data/features/knock_format.feature +11 -0
  23. data/features/simple_format.feature +204 -0
  24. data/features/steps/formatting_steps.rb +330 -0
  25. data/features/steps/html_steps.rb +32 -0
  26. data/features/steps/json_steps.rb +37 -0
  27. data/features/steps/junit_steps.rb +39 -0
  28. data/features/steps/report_steps.rb +22 -0
  29. data/features/steps/xcpretty_steps.rb +31 -0
  30. data/features/support/env.rb +117 -0
  31. data/features/tap_format.feature +31 -0
  32. data/features/test_format.feature +49 -0
  33. data/features/xcpretty.feature +14 -0
  34. data/lib/xcpretty/ansi.rb +72 -0
  35. data/lib/xcpretty/formatters/formatter.rb +177 -0
  36. data/lib/xcpretty/formatters/knock.rb +35 -0
  37. data/lib/xcpretty/formatters/rspec.rb +33 -0
  38. data/lib/xcpretty/formatters/simple.rb +200 -0
  39. data/lib/xcpretty/formatters/tap.rb +40 -0
  40. data/lib/xcpretty/parser.rb +591 -0
  41. data/lib/xcpretty/printer.rb +24 -0
  42. data/lib/xcpretty/reporters/html.rb +98 -0
  43. data/lib/xcpretty/reporters/json_compilation_database.rb +62 -0
  44. data/lib/xcpretty/reporters/junit.rb +102 -0
  45. data/lib/xcpretty/snippet.rb +38 -0
  46. data/lib/xcpretty/syntax.rb +51 -0
  47. data/lib/xcpretty/term.rb +14 -0
  48. data/lib/xcpretty/version.rb +4 -0
  49. data/lib/xcpretty.rb +37 -0
  50. data/spec/fixtures/NSStringTests.m +64 -0
  51. data/spec/fixtures/constants.rb +600 -0
  52. data/spec/fixtures/custom_formatter.rb +18 -0
  53. data/spec/fixtures/oneliner.m +1 -0
  54. data/spec/fixtures/raw_kiwi_compilation_fail.txt +24 -0
  55. data/spec/fixtures/raw_kiwi_fail.txt +1896 -0
  56. data/spec/fixtures/raw_specta_fail.txt +3110 -0
  57. data/spec/spec_helper.rb +7 -0
  58. data/spec/support/matchers/colors.rb +21 -0
  59. data/spec/xcpretty/ansi_spec.rb +47 -0
  60. data/spec/xcpretty/formatters/formatter_spec.rb +140 -0
  61. data/spec/xcpretty/formatters/rspec_spec.rb +56 -0
  62. data/spec/xcpretty/formatters/simple_spec.rb +173 -0
  63. data/spec/xcpretty/parser_spec.rb +542 -0
  64. data/spec/xcpretty/printer_spec.rb +55 -0
  65. data/spec/xcpretty/snippet_spec.rb +46 -0
  66. data/spec/xcpretty/syntax_spec.rb +39 -0
  67. data/spec/xcpretty/term_spec.rb +26 -0
  68. data/xcpretty.gemspec +37 -0
  69. metadata +237 -0
@@ -0,0 +1,542 @@
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 build target" do
27
+ @formatter.should receive(:format_build_target).with("The Spacer", "Pods", "Debug")
28
+ @parser.parse(SAMPLE_BUILD)
29
+ end
30
+
31
+ it "parses analyze target" do
32
+ @formatter.should receive(:format_analyze_target).with("The Spacer", "Pods", "Debug")
33
+ @parser.parse(SAMPLE_ANALYZE_TARGET)
34
+ end
35
+
36
+ it "parses clean remove" do
37
+ @formatter.should receive(:format_clean_remove)
38
+ @parser.parse(SAMPLE_CLEAN_REMOVE)
39
+ end
40
+
41
+ it "parses clean target" do
42
+ @formatter.should receive(:format_clean_target).with("Pods-ObjectiveSugar", "Pods", "Debug")
43
+ @parser.parse(SAMPLE_CLEAN)
44
+ end
45
+
46
+ it "parses clean target withut dash in target name" do
47
+ @formatter.should receive(:format_clean_target).with("Pods", "Pods", "Debug")
48
+ @parser.parse(SAMPLE_ANOTHER_CLEAN)
49
+ end
50
+
51
+ it "parses check dependencies" do
52
+ @formatter.should receive(:format_check_dependencies)
53
+ @parser.parse("Check dependencies")
54
+ end
55
+
56
+ it "parses code signing" do
57
+ @formatter.should receive(:format_codesign).with("build/Release/CocoaChip.app")
58
+ @parser.parse(SAMPLE_CODESIGN)
59
+ end
60
+
61
+ it "parses code signing a framework" do
62
+ @formatter.should receive(:format_codesign).with("build/Release/CocoaChipCore.framework")
63
+ @parser.parse(SAMPLE_CODESIGN_FRAMEWORK)
64
+ end
65
+
66
+ it 'parses compiler_space_in_path' do
67
+ @formatter.should receive(:format_compile).with('SASellableItem.m', "SACore/App/Models/Core\\ Data/human/SASellableItem.m")
68
+ @parser.parse(SAMPLE_COMPILE_SPACE_IN_PATH)
69
+ end
70
+
71
+ it "parses compiler commands" do
72
+ compile_statement = SAMPLE_ANOTHER_COMPILE.lines.to_a.last
73
+ @formatter.should receive(:format_compile_command).with(compile_statement.strip, "/Users/musalj/code/OSS/Kiwi/Classes/Core/KWNull.m")
74
+ @parser.parse(compile_statement)
75
+ end
76
+
77
+ it "parses compiling categories" do
78
+ @formatter.should receive(:format_compile).with("NSMutableArray+ObjectiveSugar.m", "/Users/musalj/code/OSS/ObjectiveSugar/Classes/NSMutableArray+ObjectiveSugar.m")
79
+ @parser.parse(SAMPLE_COMPILE)
80
+ end
81
+
82
+ it "parses compiling classes" do
83
+ @formatter.should receive(:format_compile).with("KWNull.m", "Classes/Core/KWNull.m")
84
+ @parser.parse(SAMPLE_ANOTHER_COMPILE)
85
+ end
86
+
87
+ it "parses compiling Objective-C++ classes" do
88
+ @formatter.should receive(:format_compile).with("KWNull.mm", "Classes/Core/KWNull.mm")
89
+ @parser.parse(SAMPLE_ANOTHER_COMPILE.sub('.m', '.mm'))
90
+ end
91
+
92
+ it 'parses compiling Swift source files' do
93
+ @formatter.should receive(:format_compile).with("Resource.swift", "/Users/paul/foo/bar/siesta/Source/Resource.swift")
94
+ @parser.parse(SAMPLE_SWIFT_COMPILE)
95
+ end
96
+
97
+ it "parses compiling C and C++ files" do
98
+ ['.c', '.cc', '.cpp', '.cxx'].each do |file_extension|
99
+ @formatter.should receive(:format_compile).with("KWNull" + file_extension, "Classes/Core/KWNull" + file_extension)
100
+ @parser.parse(SAMPLE_ANOTHER_COMPILE.sub('.m', file_extension))
101
+ end
102
+ end
103
+
104
+ it "parses compiling XIBs" do
105
+ @formatter.should receive(:format_compile_xib).with("MainMenu.xib", "CocoaChip/en.lproj/MainMenu.xib")
106
+ @parser.parse(SAMPLE_COMPILE_XIB)
107
+ end
108
+
109
+ it "parses compiling storyboards" do
110
+ @formatter.should receive(:format_compile_storyboard).with("Main.storyboard", "sample/Main.storyboard")
111
+ @parser.parse(SAMPLE_COMPILE_STORYBOARD)
112
+ end
113
+
114
+ it 'parses CopyPlistFile' do
115
+ @formatter.should receive(:format_copy_plist_file).with(
116
+ '/path/to/Some.plist', '/some other/File.plist')
117
+ @parser.parse('CopyPlistFile /path/to/Some.plist /some other/File.plist')
118
+ end
119
+
120
+ it "parses CopyStringsFile" do
121
+ @formatter.should receive(:format_copy_strings_file).with('InfoPlist.strings')
122
+ @parser.parse(SAMPLE_COPYSTRINGS)
123
+ end
124
+
125
+ it "parses CpHeader" do
126
+ @formatter.should receive(:format_copy_header_file).with(
127
+ '/path/to/Header.h', '/some other/path/Header.h')
128
+ @parser.parse('CpHeader /path/to/Header.h /some other/path/Header.h')
129
+ end
130
+
131
+ it "parses CpResource" do
132
+ @formatter.should receive(:format_cpresource).with('ObjectiveSugar/Default-568h@2x.png')
133
+ @parser.parse(SAMPLE_CPRESOURCE)
134
+ end
135
+
136
+ it "parses GenerateDSYMFile" do
137
+ @formatter.should receive(:format_generate_dsym).with('ObjectiveSugarTests.octest.dSYM')
138
+ @parser.parse(SAMPLE_DSYM)
139
+ end
140
+
141
+ it "parses info.plist processing" do
142
+ @formatter.should receive(:format_process_info_plist).with('The Spacer-Info.plist', 'The Spacer/The Spacer-Info.plist')
143
+ @parser.parse(SAMPLE_PROCESS_INFOPLIST)
144
+ end
145
+
146
+ it "parses Ld" do
147
+ @formatter.should receive(:format_linking).with('ObjectiveSugar', 'normal', 'i386')
148
+ @parser.parse(SAMPLE_LD)
149
+ end
150
+
151
+ it "parses Libtool" do
152
+ @formatter.should receive(:format_libtool).with('libPods-ObjectiveSugarTests-Kiwi.a')
153
+ @parser.parse(SAMPLE_LIBTOOL)
154
+ end
155
+
156
+ it "parses specta failing tests" do
157
+ @formatter.should receive(:format_failing_test).with("SKWelcomeViewControllerSpecSpec",
158
+ "SKWelcomeViewController_When_a_user_opens_the_app_from_a_clean_installation_displays_the_welcome_screen",
159
+ "The step timed out after 2.00 seconds: Failed to find accessibility element with the label \"The asimplest way to make smarter business decisions\"",
160
+ "/Users/vickeryj/Code/ipad-register/KIFTests/Specs/SKWelcomeViewControllerSpec.m:11")
161
+ @parser.parse(SAMPLE_SPECTA_FAILURE)
162
+ end
163
+
164
+ it "parses old specta failing tests" do
165
+ @formatter.should receive(:format_failing_test).with("RACCommandSpec",
166
+ "enabled_signal_should_send_YES_while_executing_is_YES_and_allowsConcurrentExecution_is_YES",
167
+ "expected: 1, got: 0",
168
+ "/Users/musalj/code/OSS/ReactiveCocoa/ReactiveCocoaFramework/ReactiveCocoaTests/RACCommandSpec.m:458")
169
+ @parser.parse(SAMPLE_OLD_SPECTA_FAILURE)
170
+ end
171
+
172
+ it "parses ld bitcode errors" do
173
+ @formatter.should receive(:format_error).with(SAMPLE_BITCODE_LD.strip)
174
+ @parser.parse(SAMPLE_BITCODE_LD)
175
+ end
176
+
177
+ it "parses passing ocunit tests" do
178
+ @formatter.should receive(:format_passing_test).with('RACCommandSpec',
179
+ 'enabled_signal_should_send_YES_while_executing_is_YES_and_allowsConcurrentExecution_is_YES',
180
+ '0.001')
181
+ @parser.parse(SAMPLE_OCUNIT_TEST)
182
+ end
183
+
184
+ it "parses passing specta tests" do
185
+ @formatter.should receive(:format_passing_test).with('SKWelcomeActivationViewControllerSpecSpec',
186
+ 'SKWelcomeActivationViewController_When_a_user_enters_their_details_lets_them_enter_a_valid_manager_code',
187
+ '0.725')
188
+ @parser.parse(SAMPLE_SPECTA_TEST)
189
+ end
190
+
191
+ it "parses pending tests" do
192
+ @formatter.should receive(:format_pending_test).with('TAPIConversationSpec',
193
+ 'TAPIConversation_createConversation_SendsAPOSTRequestToTheConversationsEndpoint')
194
+ @parser.parse(SAMPLE_PENDING_KIWI_TEST)
195
+ end
196
+
197
+ it 'parses measuring tests' do
198
+ @formatter.should receive(:format_measuring_test).with(
199
+ 'SecEncodeTransformTests.SecEncodeTransformTests',
200
+ 'test_RFC4648_Decode_UsingBase32',
201
+ '0.013'
202
+ )
203
+ @parser.parse(SAMPLE_MEASURING_TEST)
204
+ end
205
+
206
+ it "parses build success indicator" do
207
+ @formatter.should receive(:format_phase_success).with('BUILD')
208
+ @parser.parse(SAMPLE_BUILD_SUCCEEDED)
209
+ end
210
+
211
+ it "parses clean success indicator" do
212
+ @formatter.should receive(:format_phase_success).with('CLEAN')
213
+ @parser.parse(SAMPLE_CLEAN_SUCCEEDED)
214
+ end
215
+
216
+ it "parses PhaseScriptExecution" do
217
+ @formatter.should receive(:format_phase_script_execution).with('Check Pods Manifest.lock')
218
+ @parser.parse(SAMPLE_RUN_SCRIPT)
219
+ end
220
+
221
+ it "parses process PCH" do
222
+ @formatter.should receive(:format_process_pch).with("Pods-CocoaLumberjack-prefix.pch")
223
+ @parser.parse(SAMPLE_PRECOMPILE)
224
+ end
225
+
226
+ it 'parses process PCH command' do
227
+ compile_statement = SAMPLE_PRECOMPILE.lines.to_a.last
228
+ @formatter.should receive(:format_process_pch_command).with("/Users/musalj/code/OSS/ObjectiveRecord/Pods/Pods-CocoaLumberjack-prefix.pch")
229
+ @parser.parse(compile_statement)
230
+ end
231
+
232
+ it "parses preprocessing" do
233
+ @formatter.should receive(:format_preprocess).with("CocoaChip/CocoaChip-Info.plist")
234
+ @parser.parse(SAMPLE_PREPROCESS)
235
+ end
236
+
237
+ it "parses PBXCp" do
238
+ @formatter.should receive(:format_pbxcp).with("build/Release/CocoaChipCore.framework")
239
+ @parser.parse(SAMPLE_PBXCP)
240
+ end
241
+
242
+ it 'parses changing directories' do
243
+ @formatter.should receive(:format_shell_command).with('cd',
244
+ '/some/place/out\ there')
245
+ @parser.parse(' cd /some/place/out\ there')
246
+ end
247
+
248
+ it 'parses any indented command' do
249
+ @formatter.should receive(:format_shell_command).with(
250
+ '/bin/rm', '-rf /bin /usr /Users')
251
+ @parser.parse(' /bin/rm -rf /bin /usr /Users')
252
+ end
253
+
254
+ it "parses Touch" do
255
+ @formatter.should receive(:format_touch).with(
256
+ '/Users/musalj/Library/Developer/Xcode/DerivedData/Alcatraz-aobuxcinaqyzjugrnxjjhfzgwaou/Build/Products/Debug/Alcatraz Tests.octest',
257
+ 'Alcatraz Tests.octest')
258
+ @parser.parse(SAMPLE_TOUCH)
259
+ end
260
+
261
+ it "parses write file" do
262
+ @formatter.should receive(:format_write_file).with(
263
+ '/Users/me/myproject/Build/Intermediates/Pods.build/Debug-iphonesimulator/Pods-AFNetworking.build/Objects-normal/x86_64/Pods-AFNetworking.LinkFileList')
264
+ @parser.parse(SAMPLE_WRITE_FILE)
265
+ end
266
+
267
+ it "parses write auxiliary files" do
268
+ @formatter.should receive(:format_write_auxiliary_files)
269
+ @parser.parse(SAMPLE_WRITE_AUXILIARY_FILES)
270
+ end
271
+
272
+ it "parses TiffUtil" do
273
+ @formatter.should receive(:format_tiffutil).with('eye_icon.tiff')
274
+ @parser.parse(SAMPLE_TIFFUTIL)
275
+ end
276
+
277
+ it "parses undefined symbols" do
278
+ @formatter.should receive(:format_undefined_symbols).with("Undefined symbols for architecture x86_64",
279
+ '_OBJC_CLASS_$_CABasicAnimation',
280
+ 'objc-class-ref in ATZRadialProgressControl.o')
281
+ SAMPLE_UNDEFINED_SYMBOLS.each_line do |line|
282
+ @parser.parse(line)
283
+ end
284
+ end
285
+
286
+ it "parses duplicate symbols" do
287
+ @formatter.should receive(:format_duplicate_symbols).with(
288
+ "duplicate symbol _OBJC_IVAR_$ClassName._ivarName in",
289
+ [
290
+ '/Users/username/Library/Developer/Xcode/DerivedData/App-arcyyktezaigixbocjwfhsjllojz/Build/Intermediates/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/ClassName.o',
291
+ '/Users/username/Library/Developer/Xcode/DerivedData/App-arcyyktezaigixbocjwfhsjllojz/Build/Products/Debug-iphonesimulator/libPods.a(DuplicateClassName.o)'
292
+ ]
293
+ )
294
+ SAMPLE_DUPLICATE_SYMBOLS.each_line do |line|
295
+ @parser.parse(line)
296
+ end
297
+ end
298
+
299
+ it "parses ocunit test run finished" do
300
+ @formatter.should receive(:format_test_run_finished).with('ReactiveCocoaTests.octest(Tests)', '2013-12-10 07:03:03 +0000.')
301
+ @parser.parse(SAMPLE_OCUNIT_TEST_RUN_COMPLETION)
302
+ end
303
+
304
+ it "parses ocunit test run passed" do
305
+ @formatter.should receive(:format_test_run_finished).with('Hazelnuts.xctest', '2014-09-24 23:09:20 +0000.')
306
+ @parser.parse(SAMPLE_OCUNIT_PASSED_TEST_RUN_COMPLETION)
307
+ end
308
+
309
+ it "parses ocunit test run failed" do
310
+ @formatter.should receive(:format_test_run_finished).with('Macadamia.octest', '2014-09-24 23:09:20 +0000.')
311
+ @parser.parse(SAMPLE_OCUNIT_FAILED_TEST_RUN_COMPLETION)
312
+ end
313
+
314
+ it "parses specta test run finished" do
315
+ @formatter.should receive(:format_test_run_finished).with('KIFTests.xctest', '2014-02-28 15:44:32 +0000.')
316
+ @parser.parse(SAMPLE_SPECTA_TEST_RUN_COMPLETION)
317
+ end
318
+
319
+ it "parses ocunit test run started" do
320
+ @formatter.should receive(:format_test_run_started).with('ReactiveCocoaTests.octest(Tests)')
321
+ @parser.parse(SAMPLE_OCUNIT_TEST_RUN_BEGINNING)
322
+ end
323
+
324
+ it "parses specta test run started" do
325
+ @formatter.should receive(:format_test_run_started).with('KIFTests.xctest')
326
+ @parser.parse(SAMPLE_SPECTA_TEST_RUN_BEGINNING)
327
+ end
328
+
329
+ it "parses ocunit test suite started" do
330
+ @formatter.should receive(:format_test_suite_started).with('RACKVOWrapperSpec')
331
+ @parser.parse(SAMPLE_OCUNIT_SUITE_BEGINNING)
332
+ end
333
+
334
+ it "parses specta test suite started" do
335
+ @formatter.should receive(:format_test_suite_started).with('All tests')
336
+ @parser.parse(SAMPLE_SPECTA_SUITE_BEGINNING)
337
+ end
338
+
339
+ context "errors" do
340
+ it "parses clang errors" do
341
+ @formatter.should receive(:format_error).with(SAMPLE_CLANG_ERROR)
342
+ @parser.parse(SAMPLE_CLANG_ERROR)
343
+ end
344
+
345
+ it "parses cocoapods errors" do
346
+ @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.")
347
+ @parser.parse(SAMPLE_PODS_ERROR)
348
+ end
349
+
350
+ it "parses compiling errors" do
351
+ @formatter.should receive(:format_compile_error).with(
352
+ "SampleTest.m",
353
+ "/Users/musalj/code/OSS/SampleApp/SampleTest.m:12:59",
354
+ "expected identifier",
355
+ " [[thread.lastMessage should] equal:thread.];",
356
+ " ^")
357
+ SAMPLE_COMPILE_ERROR.each_line do |line|
358
+ @parser.parse(line)
359
+ end
360
+ end
361
+
362
+ it 'parses fatal compiling errors' do
363
+ @formatter.should receive(:format_compile_error).with(
364
+ 'SomeRandomClass.h',
365
+ '/Users/musalj/code/OSS/SampleApp/Pods/Headers/LessCoolPod/SomeRandomClass.h:31:9',
366
+ "'SomeRandomHeader.h' file not found",
367
+ '#import "SomeRandomHeader.h"',
368
+ ' ^'
369
+ # For now, it's probably not worth to provide the import stack
370
+ # It'd require more state, and not sure if it'd be any useful
371
+ # %Q(In file included from /Users/musalj/code/OSS/SampleApp/Pods/SuperCoolPod/SuperAwesomeClass.m:12:
372
+ # In file included from /Users/musalj/code/OSS/SampleApp/Pods/../LessCoolPod/LessCoolClass.h:9:
373
+ # In file included from /Users/musalj/code/OSS/SampleApp/Pods/../LessCoolPod/EvenLessCoolClass.h:10:)
374
+ )
375
+ SAMPLE_FATAL_COMPILE_ERROR.each_line do |line|
376
+ @parser.parse(line)
377
+ end
378
+ end
379
+
380
+ it 'parses file missing errors' do
381
+ @formatter.should receive(:format_file_missing_error).with(
382
+ 'error: no such file or directory:',
383
+ '/Users/travis/build/supermarin/project/Classes/Class + Category/Two Words/MissingViewController.swift'
384
+ )
385
+ @parser.parse(SAMPLE_FILE_MISSING_ERROR)
386
+ end
387
+
388
+ it 'parses fatal error: on the beginning of the line for corrupted AST files' do
389
+ @formatter.should receive(:format_error).with(
390
+ "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'"
391
+ )
392
+ @parser.parse(SAMPLE_FATAL_HEADER_ERROR)
393
+ end
394
+
395
+ it 'parses fatal error: on the beginning of the line for cached PCH' do
396
+ @formatter.should receive(:format_error).with(
397
+ "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"
398
+ )
399
+ @parser.parse(SAMPLE_FATAL_COMPILE_PCH_ERROR)
400
+ end
401
+
402
+
403
+
404
+ it "parses compiling errors with tildes" do
405
+ @formatter.should receive(:format_compile_error).with(
406
+ 'NSSetTests.m',
407
+ '/Users/musalj/code/OSS/ObjectiveSugar/Example/ObjectiveSugarTests/NSSetTests.m:93:16',
408
+ "no visible @interface for 'NSArray' declares the selector 'shoulds'",
409
+ ' }] shoulds] equal:@[ @"F458 Italia", @"Testarossa" ]];',
410
+ ' ~~ ^~~~~~~')
411
+ SAMPLE_COMPILE_ERROR_WITH_TILDES.each_line do |line|
412
+ @parser.parse(line)
413
+ end
414
+ end
415
+
416
+ it "parses code sign error:" do
417
+ @formatter.should receive(:format_error).with(
418
+ '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.'
419
+ )
420
+ @parser.parse(SAMPLE_CODESIGN_ERROR)
421
+ end
422
+
423
+ it "parses CodeSign error: (no spaces)" do
424
+ @formatter.should receive(:format_error).with(
425
+ "CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 7.0'"
426
+ )
427
+ @parser.parse(SAMPLE_CODESIGN_ERROR_NO_SPACES)
428
+ end
429
+
430
+ it "parses ld library errors" do
431
+ @formatter.should receive(:format_error).with(
432
+ SAMPLE_LD_LIBRARY_ERROR
433
+ )
434
+ @parser.parse(SAMPLE_LD_LIBRARY_ERROR)
435
+ end
436
+
437
+ it 'parses ld symbols errors' do
438
+ @formatter.should receive(:format_error).with(
439
+ SAMPLE_LD_SYMBOLS_ERROR
440
+ )
441
+ @parser.parse(SAMPLE_LD_SYMBOLS_ERROR)
442
+ end
443
+
444
+ it "doesn't print the same error over and over" do
445
+ SAMPLE_COMPILE_ERROR.each_line do |line|
446
+ @parser.parse(line)
447
+ end
448
+ @formatter.should_not receive(:format_compile_error)
449
+ @parser.parse("hohohoooo")
450
+ end
451
+ end
452
+
453
+ context "warnings" do
454
+ it 'parses compiler warnings' do
455
+ @formatter.should receive(:format_warning).with("TEST 123")
456
+ @parser.parse("warning: TEST 123")
457
+ end
458
+
459
+ it "parses compiling warnings" do
460
+ @formatter.should receive(:format_compile_warning).with(
461
+ "AppDelegate.m",
462
+ "/Users/supermarin/code/oss/ObjectiveSugar/Example/ObjectiveSugar/AppDelegate.m:19:31",
463
+ "format specifies type 'id' but the argument has type 'int' [-Wformat]",
464
+ " NSLog(@\"I HAZ %@ CATS\", 1);",
465
+ " ~~ ^")
466
+ SAMPLE_FORMAT_WARNING.each_line do |line|
467
+ @parser.parse(line)
468
+ end
469
+ end
470
+
471
+ it "parses ld warnings" do
472
+ @formatter.should receive(:format_ld_warning).with("ld: embedded dylibs/frameworks only run on iOS 8 or later")
473
+ @parser.parse("ld: warning: embedded dylibs/frameworks only run on iOS 8 or later")
474
+ end
475
+ end
476
+
477
+ context "summary" do
478
+ def given_tests_have_started(reporter = SAMPLE_OCUNIT_TEST_RUN_BEGINNING)
479
+ @parser.parse(reporter)
480
+ end
481
+
482
+ def given_tests_are_done(reporter = SAMPLE_OCUNIT_TEST_RUN_COMPLETION)
483
+ @parser.parse(reporter)
484
+ end
485
+
486
+ def given_kiwi_tests_are_done
487
+ @parser.parse(SAMPLE_KIWI_TEST_RUN_COMPLETION)
488
+ @parser.parse(SAMPLE_EXECUTED_TESTS)
489
+ @parser.parse(SAMPLE_KIWI_SUITE_COMPLETION)
490
+ end
491
+
492
+ it "returns empty string if the suite is not done" do
493
+ @parser.parse(SAMPLE_EXECUTED_TESTS).should == ""
494
+ end
495
+
496
+ it "knows when the test suite is done for OCunit" do
497
+ given_tests_are_done
498
+ @formatter.should receive(:format_test_summary)
499
+ @parser.parse(SAMPLE_EXECUTED_TESTS)
500
+ end
501
+
502
+ it "knows when the test suite is done for Specta" do
503
+ given_tests_are_done
504
+ @formatter.should receive(:format_test_summary)
505
+ @parser.parse(SAMPLE_SPECTA_EXECUTED_TESTS)
506
+ end
507
+
508
+ it "doesn't print executed message twice for Kiwi tests" do
509
+ @formatter.should_receive(:format_test_summary).once
510
+ given_tests_have_started(SAMPLE_KIWI_TEST_RUN_BEGINNING)
511
+ given_kiwi_tests_are_done
512
+ end
513
+
514
+ it "knows when the test suite is done for XCtest" do
515
+ @formatter.should_receive(:format_test_summary).once
516
+ 2.times {
517
+ given_tests_are_done(SAMPLE_KIWI_TEST_RUN_COMPLETION)
518
+ @parser.parse(SAMPLE_EXECUTED_TESTS)
519
+ }
520
+ end
521
+
522
+ it "prints OCunit / XCTest summary twice if tests executed twice" do
523
+ @formatter.should_receive(:format_test_summary).twice
524
+ 2.times {
525
+ given_tests_have_started
526
+ given_tests_are_done
527
+ @parser.parse(SAMPLE_EXECUTED_TESTS)
528
+ }
529
+ end
530
+
531
+ it "prints Kiwi summary twice if tests executed twice" do
532
+ @formatter.should_receive(:format_test_summary).twice
533
+ 2.times {
534
+ given_tests_have_started(SAMPLE_KIWI_TEST_RUN_BEGINNING)
535
+ given_kiwi_tests_are_done
536
+ }
537
+ end
538
+ end
539
+
540
+ end
541
+ end
542
+
@@ -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
+
@@ -0,0 +1,46 @@
1
+ require 'xcpretty/snippet'
2
+
3
+ module XCPretty
4
+
5
+ describe Snippet do
6
+
7
+ it "gets the snippet out of the file path" do
8
+ path = File.expand_path('spec/fixtures/NSStringTests.m:36')
9
+ Snippet.from_filepath(path).contents.should ==
10
+ <<-EOS
11
+ it(@"-split: splits with delimiter string, not just a char", ^{
12
+ [[[@"one / two / three" split:@" / "] should] equal:@[@"one", @"two", @"three"]];
13
+ });
14
+ EOS
15
+ end
16
+
17
+ it 'saves the file path' do
18
+ path = File.expand_path('spec/fixtures/NSStringTests.m:36')
19
+ Snippet.from_filepath(path).file_path.should == path
20
+ end
21
+
22
+ it "doesn't crash when there's nothing to read" do
23
+ path = File.expand_path('spec/fixtures/NSStringTests.m:64')
24
+ Snippet.from_filepath(path).contents.should == "\nSPEC_END\n"
25
+ end
26
+
27
+ it "doesn't crash if file path is invalid" do
28
+ path = 'invalid-path'
29
+ Snippet.from_filepath(path).contents.should == ''
30
+ end
31
+
32
+ it "doesn't crash if a failure is on the first line" do
33
+ path = File.expand_path('spec/fixtures/NSStringTests.m:0')
34
+ Snippet.from_filepath(path).contents.should ==
35
+ "//\n// NSStringTests.m\n// SampleProject\n"
36
+ end
37
+
38
+ it "doesn't crash if the file has only 1 line" do
39
+ path = File.expand_path('spec/fixtures/oneliner.m:0')
40
+ Snippet.from_filepath(path).contents.should ==
41
+ "[[[@1 should] equal] @3];\n"
42
+ end
43
+
44
+ end
45
+ end
46
+
@@ -0,0 +1,39 @@
1
+ require 'xcpretty/syntax'
2
+
3
+ module XCPretty
4
+ describe Syntax do
5
+ it 'syntax highlights given code' do
6
+ code = 'self.color = [UIColor redColor];'
7
+ snippet = Snippet.new(code, 'test.m')
8
+ output = Syntax.highlight(snippet)
9
+
10
+ stripped_output = output.gsub(/(?:(?:\u001b\[)|\u009b)(?:(?:[0-9]{1,3})?(?:;[0-9]{0,3})*?[A-M|f-m])|\u001b[A-M]/, '')
11
+ stripped_output.should == code
12
+ end
13
+
14
+ it 'uses Objective-C lexer for Objective-C' do
15
+ Syntax.find_lexer('test.m', '').should == Rouge::Lexers::ObjectiveC
16
+ Syntax.find_lexer('test.h', '').should == Rouge::Lexers::ObjectiveC
17
+ end
18
+
19
+ it 'uses Swift lexer for Swift' do
20
+ Syntax.find_lexer('test.swift', '').should == Rouge::Lexers::Swift
21
+ end
22
+
23
+ it 'uses Ruby lexer for Ruby' do
24
+ Syntax.find_lexer('test.rb', '').should == Rouge::Lexers::Ruby
25
+ Syntax.find_lexer('test.ruby', '').should == Rouge::Lexers::Ruby
26
+ end
27
+
28
+ it 'uses C++ lexer for C++' do
29
+ Syntax.find_lexer('test.cpp', '').should == Rouge::Lexers::Cpp
30
+ Syntax.find_lexer('test.cc', '').should == Rouge::Lexers::Cpp
31
+ Syntax.find_lexer('test.c++', '').should == Rouge::Lexers::Cpp
32
+ Syntax.find_lexer('test.cxx', '').should == Rouge::Lexers::Cpp
33
+ Syntax.find_lexer('test.hpp', '').should == Rouge::Lexers::Cpp
34
+ Syntax.find_lexer('test.h++', '').should == Rouge::Lexers::Cpp
35
+ Syntax.find_lexer('test.hxx', '').should == Rouge::Lexers::Cpp
36
+ end
37
+ end
38
+ end
39
+