april_oneil 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 289a7918592568e9792a5b64a6398518ae5e6ee9
4
+ data.tar.gz: 033f669d4b571761aa6bb04916f1aec10cc30e96
5
+ SHA512:
6
+ metadata.gz: c7813565b000e5a2b6ebcaba732f19582bc38349914b9c8135f675393b17b827d632f754ae8272580abf09b563512c6617bb1e24ed0e3f8aeb0f36c8124f8b5d
7
+ data.tar.gz: 8cac46229dc1410301f67bec458e866004970d10578d09e0ef9ed74988b2fd55413ff2d98383adce285582a824458d49c8ad6535a63b505c2081ae5dd43e168e
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in april_oneil.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Michael Enriquez (http://enriquez.me)
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,62 @@
1
+ # April O'Neil
2
+
3
+ April O'Neil is a reporter for [Facebook's xctool](http://github.com/facebook/xctool).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ gem install april_oneil
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Pass the location of the formatter's executable to xctool's `-reporter` argument.
14
+
15
+ ```bash
16
+ xctool -workspace YourProject.xcworkspace \
17
+ -scheme YourProject \
18
+ -sdk iphonesimulator \
19
+ -reporter "$(which ao-kiwi-progress)" \
20
+ test
21
+ ```
22
+
23
+ ## Formatters
24
+
25
+ ### Kiwi Progress `ao-kiwi-progress`
26
+
27
+ Used for tests written with [Kiwi](http://github.com/allending/kiwi). Inspired by [RSpec's](http://rspec.info) progress formatter.
28
+
29
+ Example output:
30
+
31
+ ![Kiwi Progress Passing](https://github.com/enriquez/april_oneil/wiki/readme-assets/ao-kiwi-progress-passing.png)
32
+ ![Kiwi Progress Pending](https://github.com/enriquez/april_oneil/wiki/readme-assets/ao-kiwi-progress-pending.png)
33
+ ![Kiwi Progress Compile Error](https://github.com/enriquez/april_oneil/wiki/readme-assets/ao-kiwi-progress-compile-error.png)
34
+ ![Kiwi Progress Failures](https://github.com/enriquez/april_oneil/wiki/readme-assets/ao-kiwi-progress-failing.png)
35
+
36
+
37
+
38
+
39
+ ## MIT License
40
+
41
+ Copyright (c) 2013 Michael Enriquez (http://enriquez.me)
42
+
43
+ MIT License
44
+
45
+ Permission is hereby granted, free of charge, to any person obtaining
46
+ a copy of this software and associated documentation files (the
47
+ "Software"), to deal in the Software without restriction, including
48
+ without limitation the rights to use, copy, modify, merge, publish,
49
+ distribute, sublicense, and/or sell copies of the Software, and to
50
+ permit persons to whom the Software is furnished to do so, subject to
51
+ the following conditions:
52
+
53
+ The above copyright notice and this permission notice shall be
54
+ included in all copies or substantial portions of the Software.
55
+
56
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
57
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
58
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
59
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
60
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
61
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
62
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'april_oneil/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "april_oneil"
8
+ spec.version = AprilONeil::VERSION
9
+ spec.authors = ["Mike Enriquez"]
10
+ spec.email = ["mike@enriquez.me"]
11
+ spec.description = %q{xctool reporter}
12
+ spec.summary = %q{April O'Neil is a reporter for Facebook's xctool. Comes with an rspec-style progress formatter for tests using Kiwi.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake", "~> 10.1"
23
+
24
+ spec.add_dependency "rainbow", "~> 1.1"
25
+ end
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ require 'april_oneil'
3
+
4
+ STDOUT.sync = true
5
+
6
+ formatter = AprilONeil::Formatters::KiwiProgress.new(STDOUT)
7
+ xctool = AprilONeil::XCTool.new(STDIN, formatter)
8
+
9
+ xctool.start
@@ -0,0 +1,6 @@
1
+ require 'april_oneil/version'
2
+ require 'april_oneil/xctool'
3
+ require 'april_oneil/formatters'
4
+
5
+ module AprilONeil
6
+ end
@@ -0,0 +1,5 @@
1
+ require 'april_oneil/formatters/base_formatter'
2
+ require 'april_oneil/formatters/kiwi_progress'
3
+
4
+ module AprilONeil::Formatters
5
+ end
@@ -0,0 +1,70 @@
1
+ module AprilONeil
2
+ module Formatters
3
+ # xctool events: https://github.com/facebook/xctool/blob/master/Common/ReporterEvents.h
4
+ class BaseFormatter
5
+ def initialize(output)
6
+ @output = output
7
+ end
8
+
9
+ def before_start
10
+ end
11
+
12
+ def begin_status(opts)
13
+ end
14
+
15
+ def end_status(opts)
16
+ end
17
+
18
+ def begin_action(opts)
19
+ end
20
+
21
+ def begin_xcodebuild(opts)
22
+ end
23
+
24
+ def begin_build_target(opts)
25
+ end
26
+
27
+ def begin_build_command(opts)
28
+ end
29
+
30
+ def end_build_command(opts)
31
+ end
32
+
33
+ def end_build_target(opts)
34
+ end
35
+
36
+ def end_xcodebuild(opts)
37
+ end
38
+
39
+ def begin_ocunit(opts)
40
+ end
41
+
42
+ def begin_test_suite(opts)
43
+ end
44
+
45
+ def begin_test(opts)
46
+ end
47
+
48
+ def test_output(opts)
49
+ end
50
+
51
+ def end_test(opts)
52
+ end
53
+
54
+ def end_test_suite(opts)
55
+ end
56
+
57
+ def end_ocunit(opts)
58
+ end
59
+
60
+ def end_action(opts)
61
+ end
62
+
63
+ def analyzer_result(opts)
64
+ end
65
+
66
+ def after_end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,166 @@
1
+ require 'april_oneil/formatters/base_formatter'
2
+ require 'rainbow'
3
+
4
+ module AprilONeil
5
+ module Formatters
6
+ class KiwiProgress < BaseFormatter
7
+ DARK_GRAY_COLOR = "333333"
8
+
9
+ def initialize(output)
10
+ super(output)
11
+
12
+ Sickill::Rainbow.enabled = true
13
+
14
+ @passed = []
15
+ @pending = []
16
+ @failed = []
17
+ end
18
+
19
+ def begin_build_target(opts)
20
+ project = opts['project']
21
+ target = opts['target']
22
+ @output.puts if @test_target
23
+ @output.puts "Building #{project} / #{target}"
24
+ @test_target = target # assume last target is the test target
25
+ end
26
+
27
+ def end_build_command(opts)
28
+ succeeded = opts['succeeded']
29
+ if succeeded
30
+ @output.print ".".foreground(:cyan)
31
+ else
32
+ @output.print "E".foreground(:red)
33
+ @output.puts
34
+ @output.puts
35
+ @output.puts opts["emittedOutputText"].color(DARK_GRAY_COLOR)
36
+ end
37
+ end
38
+
39
+ def begin_ocunit(opts)
40
+ @output.puts
41
+ @output.puts "Running Tests"
42
+ end
43
+
44
+ def test_output(opts)
45
+ # print NSLog statements while ignoring Kiwi output
46
+ output = opts["output"]
47
+ @output.print output.color(DARK_GRAY_COLOR) unless output =~ /^.+\[.+\] \+/
48
+ end
49
+
50
+ def end_test(opts)
51
+ succeeded = opts["succeeded"]
52
+ if succeeded
53
+ output = opts["output"]
54
+ if output[/\[([A-Z]+)\]/] == '[PENDING]'
55
+ @output.print "*".foreground(:yellow)
56
+ @pending << opts
57
+ else
58
+ @output.print ".".foreground(:green)
59
+ @passed << opts
60
+ end
61
+ else
62
+ @output.print "F".foreground(:red)
63
+ @failed << opts
64
+ end
65
+ end
66
+
67
+ def end_action(opts)
68
+ @summary = opts if opts["name"] == "test"
69
+ end
70
+
71
+ def after_end
72
+ @output.puts
73
+ @output.print pending_summary
74
+ @output.print failure_summary
75
+ @output.print run_summary
76
+ end
77
+
78
+ protected
79
+
80
+ def pending_summary
81
+ output = ''
82
+
83
+ if @pending.count > 0
84
+ output = "\nPending:\n"
85
+ @pending.each do |pending|
86
+ if pending["output"] =~ /\+ \'(.+)\'/
87
+ test_name = $1
88
+ output << " #{test_name}\n"
89
+ end
90
+ end
91
+ end
92
+
93
+ output
94
+ end
95
+
96
+ def failure_summary
97
+ output = ''
98
+ if @failed.count > 0
99
+ output << "\nFailures:\n"
100
+ @failed.each do |failed|
101
+ name_added = false
102
+ exceptions = failed["exceptions"]
103
+ class_name = failed["className"]
104
+ method_name = failed["methodName"]
105
+ exceptions.each do |exception|
106
+ test_file = File.basename(exception["filePathInProject"])
107
+ line_number = exception["lineNumber"]
108
+ reason = exception["reason"]
109
+ if reason =~ /\'(.+)\' \[\w+\], (.+)/
110
+ test_name = $1
111
+ message = $2
112
+
113
+ if !name_added
114
+ output << " #{test_name}\n"
115
+ output << " -only #{@test_target}:#{class_name}/#{method_name}\n".foreground(:cyan)
116
+ name_added = true
117
+ end
118
+
119
+ if test_file =~ /Unknown File/
120
+ output << " #{message}\n".foreground(:red)
121
+ else
122
+ location = "# #{test_file}:#{line_number}".color(DARK_GRAY_COLOR)
123
+ output << " #{message.color(:red)} #{location}\n"
124
+ end
125
+ end
126
+ end
127
+ end
128
+ output << "\n"
129
+ end
130
+
131
+ output
132
+ end
133
+
134
+ def run_summary
135
+ output = ''
136
+ if @summary
137
+ duration = @summary["duration"].to_f
138
+ duration_in_ms = (duration * 1000).floor
139
+ failure_count = @failed.count
140
+ pending_count = @pending.count
141
+ total_count = @passed.count + pending_count + failure_count
142
+
143
+ output = "\nFinished in #{duration_in_ms}ms\n"
144
+ counts = ''
145
+
146
+ if total_count > 0
147
+ counts << "#{total_count} tests, #{failure_count} failures"
148
+ counts << ", #{pending_count} pending" if pending_count > 0
149
+ end
150
+
151
+ counts << "\n"
152
+
153
+ if failure_count > 0
154
+ output << counts.foreground(:red)
155
+ elsif pending_count > 0
156
+ output << counts.foreground(:yellow)
157
+ else
158
+ output << counts.foreground(:green)
159
+ end
160
+ end
161
+
162
+ output
163
+ end
164
+ end
165
+ end
166
+ end
@@ -0,0 +1,3 @@
1
+ module AprilONeil
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,25 @@
1
+ require 'json'
2
+
3
+ module AprilONeil
4
+ class XCTool
5
+ def initialize(input, formatter)
6
+ @input = input
7
+ @formatter = formatter
8
+ @events = {}
9
+ end
10
+
11
+ def start
12
+ @formatter.before_start
13
+
14
+ @input.each_line do |line|
15
+ json = JSON.parse(line)
16
+ event_name = json["event"]
17
+ event_method = event_name.gsub("-", "_")
18
+
19
+ @formatter.send(event_method, json)
20
+ end
21
+
22
+ @formatter.after_end
23
+ end
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: april_oneil
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mike Enriquez
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rainbow
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
55
+ description: xctool reporter
56
+ email:
57
+ - mike@enriquez.me
58
+ executables:
59
+ - ao-kiwi-progress
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - april_oneil.gemspec
69
+ - bin/ao-kiwi-progress
70
+ - lib/april_oneil.rb
71
+ - lib/april_oneil/formatters.rb
72
+ - lib/april_oneil/formatters/base_formatter.rb
73
+ - lib/april_oneil/formatters/kiwi_progress.rb
74
+ - lib/april_oneil/version.rb
75
+ - lib/april_oneil/xctool.rb
76
+ homepage: ''
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.0.3
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: April O'Neil is a reporter for Facebook's xctool. Comes with an rspec-style
100
+ progress formatter for tests using Kiwi.
101
+ test_files: []
102
+ has_rdoc: