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,7 @@
1
+ $LOAD_PATH.unshift('.', __FILE__)
2
+ require "lib/xcpretty/ansi"
3
+ require "support/matchers/colors"
4
+ require "fixtures/constants"
5
+
6
+ include XCPretty::ANSI
7
+
@@ -0,0 +1,21 @@
1
+ require 'rspec' unless Object.const_defined? :RSpec
2
+
3
+ RSpec::Matchers.define :be_colored do |expected|
4
+
5
+ def effects_string(actual)
6
+ effects = applied_effects(actual).join(' and ')
7
+ effects.length > 0 ? effects : "unformatted"
8
+ end
9
+
10
+ match do |actual|
11
+ applied_effects(actual).include? expected.to_sym
12
+ end
13
+
14
+ failure_message_for_should do |actual|
15
+ "expected that '#{strip(actual)}' would be colored #{expected}, but was #{effects_string(actual)}"
16
+ end
17
+ failure_message_for_should_not do |actual|
18
+ "expected that #{strip(actual)} would not be colored #{expected}, but was #{effects_string(actual)}"
19
+ end
20
+ end
21
+
@@ -0,0 +1,47 @@
1
+ require "xcpretty/ansi"
2
+
3
+ module XCPretty
4
+ describe ANSI do
5
+ include ANSI
6
+
7
+ before do
8
+ self.colorize = true
9
+ @text = "This is the PARTY"
10
+ end
11
+
12
+ describe "color helpers" do
13
+ it "colors text red" do
14
+ red(@text).should == "\e[31m#{@text}\e[0m"
15
+ end
16
+
17
+ it "formats text bold" do
18
+ white(@text).should == "\e[39;1m#{@text}\e[0m"
19
+ end
20
+
21
+ it "colors text green" do
22
+ green(@text).should == "\e[32;1m#{@text}\e[0m"
23
+ end
24
+
25
+ it "colors text cyan" do
26
+ cyan(@text).should == "\e[36m#{@text}\e[0m"
27
+ end
28
+ end
29
+
30
+ describe "custom color mixing" do
31
+ it "can mix random known colors" do
32
+ ansi_parse(@text, :yellow, :underline).should == "\e[33;4m#{@text}\e[0m"
33
+ end
34
+ end
35
+
36
+ describe "debug helpers" do
37
+ it "can remove formatting from text" do
38
+ strip("\e[33;4m#{@text}\e[0m").should == @text
39
+ end
40
+
41
+ it "can list known applied effects" do
42
+ applied_effects("\e[33;1m#{@text}\e[0m").should == [:yellow, :bold]
43
+ end
44
+ end
45
+ end
46
+ end
47
+
@@ -0,0 +1,140 @@
1
+ # encoding: utf-8
2
+
3
+ require 'xcpretty'
4
+ require 'fixtures/constants'
5
+
6
+ module XCPretty
7
+
8
+ describe Formatter do
9
+
10
+ before(:each) do
11
+ @formatter = Formatter.new(true, true)
12
+ end
13
+
14
+ it "initializes with unicode" do
15
+ @formatter.use_unicode?.should be_truthy
16
+ end
17
+
18
+ it "initializes with color" do
19
+ @formatter.colorize?.should be_truthy
20
+ end
21
+
22
+ it "outputs to new lines by default" do
23
+ @formatter.optional_newline.should == "\n"
24
+ end
25
+
26
+ it "formats cocoapods errors" do
27
+ @formatter.format_error("The sandbox is not in sync...").should ==
28
+ "\n#{@formatter.red("❌ The sandbox is not in sync...")}\n\n"
29
+ end
30
+
31
+ it "formats compiling errors" do
32
+ @formatter.format_compile_error("file", "path/to/file", "expected valid syntax",
33
+ "[a should",
34
+ " ^").should ==
35
+ %Q(
36
+ #{@formatter.red('❌ ')}path/to/file: #{@formatter.red("expected valid syntax")}
37
+
38
+ [a should
39
+ #{@formatter.cyan(" ^")}
40
+
41
+ )
42
+ end
43
+
44
+ it "formats file missing errors" do
45
+ @formatter.format_file_missing_error("error: no such file or directory:",
46
+ "/path/to/file.swift").should ==
47
+ "\n#{@formatter.red(
48
+ '❌ error: no such file or directory:'
49
+ )} /path/to/file.swift\n\n"
50
+ end
51
+
52
+ it "formats compiling warnings" do
53
+ reason = "format specifies type 'id' but the argument has type 'int' [-Wformat]"
54
+
55
+ @formatter.format_compile_warning("file", "path/to/file", reason,
56
+ %Q( NSLog(@"alsdkflsakdj %@", 1);),
57
+ %Q( ~~ ^)).should ==
58
+
59
+ %Q(
60
+ #{@formatter.yellow('⚠️ ')}path/to/file: #{@formatter.yellow(reason)}
61
+
62
+ NSLog(@"alsdkflsakdj %@", 1);
63
+ #{@formatter.cyan(" ~~ ^")}
64
+
65
+ )
66
+ end
67
+
68
+ it "formats linker warnings" do
69
+ @formatter.format_ld_warning("ld: embedded dylibs/frameworks only run on iOS 8 or later").should ==
70
+ "#{@formatter.yellow("⚠️ ld: embedded dylibs/frameworks only run on iOS 8 or later")}"
71
+ end
72
+
73
+ it "formats linker undefined symbols by default" do
74
+ @formatter.format_undefined_symbols("Undefined symbols for architecture x86_64",
75
+ '_OBJC_CLASS_$_CABasicAnimation',
76
+ 'objc-class-ref in ATZRadialProgressControl.o').should == %Q(
77
+ #{@formatter.red("❌ Undefined symbols for architecture x86_64")}
78
+ > Symbol: _OBJC_CLASS_$_CABasicAnimation
79
+ > Referenced from: objc-class-ref in ATZRadialProgressControl.o
80
+
81
+ )
82
+ end
83
+
84
+ it "formats linker duplicate symbols by default" do
85
+ @formatter.format_duplicate_symbols("duplicate symbol _OBJC_IVAR_$ClassName._ivarName in",
86
+ ['/Users/username/Library/Developer/Xcode/DerivedData/App-arcyyktezaigixbocjwfhsjllojz/Build/Intermediates/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/ClassName.o',
87
+ '/Users/username/Library/Developer/Xcode/DerivedData/App-arcyyktezaigixbocjwfhsjllojz/Build/Products/Debug-iphonesimulator/libPods.a(DuplicateClassName.o)']).should == %Q(
88
+ #{@formatter.red("❌ duplicate symbol _OBJC_IVAR_$ClassName._ivarName in")}
89
+ > ClassName.o
90
+ > libPods.a(DuplicateClassName.o)
91
+ )
92
+ end
93
+
94
+
95
+ it "formats failures per suite" do
96
+ Syntax.stub(:highlight) { |snippet| snippet.contents }
97
+
98
+ first_path = File.expand_path('spec/fixtures/NSStringTests.m:46')
99
+ second_path = File.expand_path('spec/fixtures/NSStringTests.m:57')
100
+
101
+ failures = {
102
+ 'CarSpec' => [
103
+ {
104
+ file_path: first_path,
105
+ reason: "just doesn't work",
106
+ test_case: 'Starting the car'
107
+ }],
108
+ 'StringSpec' => [
109
+ {
110
+ file_path: second_path,
111
+ reason: "doesn't split",
112
+ test_case: 'Splitting the string'
113
+ }]
114
+ }
115
+ @formatter.format_test_summary(SAMPLE_EXECUTED_TESTS, failures).should == %Q(
116
+
117
+ CarSpec
118
+ Starting the car, #{@formatter.red("just doesn't work")}
119
+ #{@formatter.cyan(first_path)}
120
+ ```
121
+ it(@"converts snake_cased to CamelCased", ^{
122
+ [[[@"snake_case" camelCase] should] equal:@"SnakeCase"];
123
+ });
124
+ ```
125
+
126
+ StringSpec
127
+ Splitting the string, #{@formatter.red("doesn't split")}
128
+ #{@formatter.cyan(second_path)}
129
+ ```
130
+ it(@"-strip strips whitespaces and newlines from both ends", ^{
131
+ [[[@" Look mo, no empties! " strip] should] equal:@"Look mo, no empties!"];
132
+ });
133
+ ```
134
+
135
+
136
+ #{@formatter.red(SAMPLE_EXECUTED_TESTS)})
137
+ end
138
+ end
139
+ end
140
+
@@ -0,0 +1,56 @@
1
+ require "spec_helper"
2
+ require "xcpretty"
3
+ require "xcpretty/formatters/rspec"
4
+
5
+ module XCPretty
6
+
7
+ describe RSpec do
8
+
9
+ before(:each) do
10
+ @formatter = RSpec.new(false, false)
11
+ end
12
+
13
+ it "prints dots in the same line" do
14
+ @formatter.optional_newline.should == ""
15
+ end
16
+
17
+ context "without colors" do
18
+
19
+ it "prints dots for passing tests" do
20
+ @formatter.format_passing_test("sweez testz", "sample spec", "0.002").should == "."
21
+ end
22
+
23
+ it "prints P for pending tests" do
24
+ @formatter.format_pending_test("sweez testz", "sample spec").should == "P"
25
+ end
26
+
27
+ it "prints F for failing tests" do
28
+ @formatter.format_failing_test(
29
+ "///file", "NSNumber Specs", "adding numbers", "should add 2 numbers"
30
+ ).should == "F"
31
+ end
32
+ end
33
+
34
+ context "with colors" do
35
+
36
+ before { @formatter.colorize = true }
37
+
38
+ it "prints green for passing tests" do
39
+ @formatter.format_passing_test("sweez testz", "sample spec", "0.002"
40
+ ).should be_colored :green
41
+ end
42
+
43
+ it "prints yellow for pending tests" do
44
+ @formatter.format_pending_test("sweez testz", "sample spec"
45
+ ).should be_colored :yellow
46
+ end
47
+
48
+ it "prints red for failing tests" do
49
+ @formatter.format_failing_test(
50
+ "///file", "NSNumber Specs", "adding numbers", "should add 2 numbers"
51
+ ).should be_colored :red
52
+ end
53
+ end
54
+ end
55
+ end
56
+
@@ -0,0 +1,173 @@
1
+ require 'xcpretty/formatters/formatter'
2
+ require "xcpretty/formatters/simple"
3
+ require "fixtures/constants"
4
+
5
+ module XCPretty
6
+
7
+ describe Simple do
8
+
9
+ before(:each) do
10
+ @formatter = Simple.new(false, false)
11
+ end
12
+
13
+ it "formats analyzing" do
14
+ @formatter.format_analyze("CCChip8DisplayView.m", 'path/to/file').should ==
15
+ "> Analyzing CCChip8DisplayView.m"
16
+ end
17
+
18
+ it "formats build target/project/configuration with target" do
19
+ @formatter.format_build_target("The Spacer", "Pods", "Debug").should ==
20
+ "> Building Pods/The Spacer [Debug]"
21
+ end
22
+
23
+ it "formats analyze target/project/configuration with target" do
24
+ @formatter.format_analyze_target("The Spacer", "Pods", "Debug").should ==
25
+ "> Analyzing Pods/The Spacer [Debug]"
26
+ end
27
+
28
+ it "formats clean target/project/configuration" do
29
+ @formatter.format_clean_target("Pods-ObjectiveSugar", "Pods", "Debug").should ==
30
+ "> Cleaning Pods/Pods-ObjectiveSugar [Debug]"
31
+ end
32
+
33
+ it 'formats compiler warnings' do
34
+ warning = 'warning: stuff is broken'
35
+ @formatter.format_warning(warning).should == ' ' + warning
36
+ end
37
+
38
+ it "formats compiling output" do
39
+ @formatter.format_compile("NSMutableArray+ObjectiveSugar.m", 'path/to/file').should ==
40
+ "> Compiling NSMutableArray+ObjectiveSugar.m"
41
+ end
42
+
43
+ it "formats compiling xib output" do
44
+ @formatter.format_compile_xib("MainMenu.xib", 'path/to/file').should ==
45
+ "> Compiling MainMenu.xib"
46
+ end
47
+
48
+ it "formats compiling storyboard output" do
49
+ @formatter.format_compile_xib("Main.storyboard", 'path/to/file').should ==
50
+ "> Compiling Main.storyboard"
51
+ end
52
+
53
+ it 'formats copying header files' do
54
+ @formatter.format_copy_header_file('Source.h',
55
+ 'dir/Destination.h').should == '> Copying Source.h'
56
+ end
57
+
58
+ it 'formats copying plist files' do
59
+ @formatter.format_copy_plist_file("Source.plist",
60
+ 'dir/Destination.plist').should == '> Copying Source.plist'
61
+ end
62
+
63
+ it "formats copy resource" do
64
+ @formatter.format_cpresource("ObjectiveSugar/Default-568h@2x.png").should ==
65
+ "> Copying ObjectiveSugar/Default-568h@2x.png"
66
+ end
67
+
68
+ it "formats Copy strings file" do
69
+ @formatter.format_copy_strings_file("InfoPlist.strings").should ==
70
+ "> Copying InfoPlist.strings"
71
+ end
72
+
73
+ it "formats GenerateDSYMFile" do
74
+ @formatter.format_generate_dsym("ObjectiveSugarTests.octest.dSYM").should ==
75
+ "> Generating 'ObjectiveSugarTests.octest.dSYM'"
76
+ end
77
+
78
+ it "formats info.plist processing" do
79
+ @formatter.format_process_info_plist("The Spacer-Info.plist", "The Spacer/The Spacer-Info.plist").should ==
80
+ "> Processing The Spacer-Info.plist"
81
+ end
82
+
83
+ it "formats Linking" do
84
+ @formatter.format_linking("ObjectiveSugar", 'normal', 'i386').should ==
85
+ "> Linking ObjectiveSugar"
86
+ end
87
+
88
+ it "formats Libtool" do
89
+ @formatter.format_libtool("libPods-ObjectiveSugarTests-Kiwi.a").should ==
90
+ "> Building library libPods-ObjectiveSugarTests-Kiwi.a"
91
+ end
92
+
93
+ it "formats failing tests" do
94
+ @formatter.format_failing_test("RACCommandSpec", "enabled_signal_should_send_YES_while_executing_is_YES_and_allowsConcurrentExecution_is_YES", "expected: 1, got: 0", 'path/to/file').should ==
95
+ " x enabled_signal_should_send_YES_while_executing_is_YES_and_allowsConcurrentExecution_is_YES, expected: 1, got: 0"
96
+ end
97
+
98
+ it "formats passing tests" do
99
+ @formatter.format_passing_test("RACCommandSpec", "_tupleByAddingObject__should_add_a_non_nil_object", "0.001").should ==
100
+ " . _tupleByAddingObject__should_add_a_non_nil_object (0.001 seconds)"
101
+ end
102
+
103
+ it "formats pending tests" do
104
+ @formatter.format_pending_test("RACCommandSpec", "_tupleByAddingObject__should_add_a_non_nil_object").should ==
105
+ " P _tupleByAddingObject__should_add_a_non_nil_object [PENDING]"
106
+ end
107
+
108
+ it "formats measuring tests" do
109
+ @formatter.format_measuring_test("RACCommandSpec", "_tupleByAddingObject__should_add_a_non_nil_object", "0.001").should ==
110
+ " T _tupleByAddingObject__should_add_a_non_nil_object measured (0.001 seconds)"
111
+ end
112
+
113
+ it "formats build success output" do
114
+ @formatter.format_phase_success("BUILD").should == "> Build Succeeded"
115
+ end
116
+
117
+ it "formats clean success output" do
118
+ @formatter.format_phase_success("CLEAN").should == "> Clean Succeeded"
119
+ end
120
+
121
+ it "formats Phase Script Execution" do
122
+ @formatter.format_phase_script_execution("Check Pods Manifest.lock").should ==
123
+ "> Running script 'Check Pods Manifest.lock'"
124
+ end
125
+
126
+ it "formats precompiling output" do
127
+ @formatter.format_process_pch("Pods-CocoaLumberjack-prefix.pch").should ==
128
+ "> Precompiling Pods-CocoaLumberjack-prefix.pch"
129
+ end
130
+
131
+ it "formats code signing" do
132
+ @formatter.format_codesign("build/Release/CocoaChip.app").should ==
133
+ "> Signing build/Release/CocoaChip.app"
134
+ end
135
+
136
+ it "formats preprocessing a file" do
137
+ @formatter.format_preprocess("CocoaChip/CocoaChip-Info.plist").should ==
138
+ "> Preprocessing CocoaChip/CocoaChip-Info.plist"
139
+ end
140
+
141
+ it "formats PBXCp" do
142
+ @formatter.format_pbxcp("build/Release/CocoaChipCore.framework").should ==
143
+ "> Copying build/Release/CocoaChipCore.framework"
144
+ end
145
+
146
+ it "formats test run start" do
147
+ @formatter.format_test_run_started("ReactiveCocoaTests.octest(Tests)").should ==
148
+ "Test Suite ReactiveCocoaTests.octest(Tests) started"
149
+ end
150
+
151
+ it "formats tests suite started" do
152
+ @formatter.format_test_suite_started("RACKVOWrapperSpec").should ==
153
+ "RACKVOWrapperSpec"
154
+ end
155
+
156
+ it "formats Touch" do
157
+ @formatter.format_touch("/path/to/SomeFile.txt", "SomeFile.txt").should ==
158
+ "> Touching SomeFile.txt"
159
+ end
160
+
161
+ it "formats TiffUtil" do
162
+ @formatter.format_tiffutil("unbelievable.tiff").should ==
163
+ "> Validating unbelievable.tiff"
164
+ end
165
+
166
+ it 'formats Check Dependencies' do
167
+ @formatter.format_check_dependencies.should ==
168
+ '> Check Dependencies'
169
+ end
170
+
171
+ end
172
+ end
173
+