ci_reporter 1.9.3 → 2.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +22 -0
  3. data/.travis.yml +2 -6
  4. data/Gemfile +0 -9
  5. data/History.txt +0 -4
  6. data/LICENSE.txt +23 -21
  7. data/README.md +90 -0
  8. data/Rakefile +5 -99
  9. data/ci_reporter.gemspec +23 -52
  10. data/gemfiles/.gitignore +1 -0
  11. data/lib/ci/reporter/core.rb +0 -4
  12. data/lib/ci/reporter/internal.rb +31 -0
  13. data/lib/ci/reporter/rake/utils.rb +0 -4
  14. data/lib/ci/reporter/report_manager.rb +7 -11
  15. data/lib/ci/reporter/test_suite.rb +1 -9
  16. data/lib/ci/reporter/version.rb +1 -7
  17. data/spec/ci/reporter/output_capture_spec.rb +3 -7
  18. data/spec/ci/reporter/report_manager_spec.rb +6 -10
  19. data/spec/ci/reporter/test_suite_spec.rb +0 -4
  20. data/spec/spec_helper.rb +0 -7
  21. metadata +29 -138
  22. data/.gemtest +0 -0
  23. data/.hoerc +0 -2
  24. data/.travis.before_install.sh +0 -13
  25. data/Manifest.txt +0 -50
  26. data/README.rdoc +0 -111
  27. data/acceptance/cucumber/cucumber_example.feature +0 -19
  28. data/acceptance/cucumber/step_definitions/development_steps.rb +0 -40
  29. data/acceptance/minitest_example_test.rb +0 -17
  30. data/acceptance/rspec_example_spec.rb +0 -24
  31. data/acceptance/spinach/features/spinach_example.feature +0 -24
  32. data/acceptance/spinach/features/steps/example_spinach_feature.rb +0 -34
  33. data/acceptance/test_unit_example_test.rb +0 -23
  34. data/acceptance/verification_spec.rb +0 -185
  35. data/lib/ci/reporter/cucumber.rb +0 -127
  36. data/lib/ci/reporter/minitest.rb +0 -226
  37. data/lib/ci/reporter/rake/cucumber.rb +0 -17
  38. data/lib/ci/reporter/rake/cucumber_loader.rb +0 -6
  39. data/lib/ci/reporter/rake/minitest.rb +0 -15
  40. data/lib/ci/reporter/rake/minitest_loader.rb +0 -9
  41. data/lib/ci/reporter/rake/rspec.rb +0 -31
  42. data/lib/ci/reporter/rake/rspec_loader.rb +0 -6
  43. data/lib/ci/reporter/rake/spinach.rb +0 -19
  44. data/lib/ci/reporter/rake/spinach_loader.rb +0 -5
  45. data/lib/ci/reporter/rake/test_unit.rb +0 -15
  46. data/lib/ci/reporter/rake/test_unit_loader.rb +0 -38
  47. data/lib/ci/reporter/rspec.rb +0 -220
  48. data/lib/ci/reporter/spinach.rb +0 -80
  49. data/lib/ci/reporter/test_unit.rb +0 -163
  50. data/spec/ci/reporter/cucumber_spec.rb +0 -230
  51. data/spec/ci/reporter/rake/rake_tasks_spec.rb +0 -110
  52. data/spec/ci/reporter/rspec_spec.rb +0 -156
  53. data/spec/ci/reporter/test_unit_spec.rb +0 -152
  54. data/stub.rake +0 -16
  55. data/tasks/ci_reporter.rake +0 -20
@@ -1,5 +0,0 @@
1
- $: << File.dirname(__FILE__) + "/../../.."
2
- require 'ci/reporter/spinach'
3
-
4
- ENV['CI_CAPTURE'] = 'off'
5
-
@@ -1,15 +0,0 @@
1
- # Copyright (c) 2006-2012 Nick Sieger <nicksieger@gmail.com>
2
- # See the file LICENSE.txt included with the distribution for
3
- # software license details.
4
-
5
- require File.expand_path('../utils', __FILE__)
6
-
7
- namespace :ci do
8
- namespace :setup do
9
- task :testunit do
10
- rm_rf ENV["CI_REPORTS"] || "test/reports"
11
- test_loader = CI::Reporter.maybe_quote_filename "#{File.dirname(__FILE__)}/test_unit_loader.rb"
12
- ENV["TESTOPTS"] = "#{ENV["TESTOPTS"]} #{test_loader}"
13
- end
14
- end
15
- end
@@ -1,38 +0,0 @@
1
- # Copyright (c) 2006-2012 Nick Sieger <nicksieger@gmail.com>
2
- # See the file LICENSE.txt included with the distribution for
3
- # software license details.
4
-
5
- $: << File.dirname(__FILE__) + "/../../.."
6
- require 'ci/reporter/test_unit'
7
-
8
- # Intercepts mediator creation in ruby-test < 2.1
9
- module Test #:nodoc:all
10
- module Unit
11
- module UI
12
- module Console
13
- class TestRunner
14
- undef :create_mediator if instance_methods.map(&:to_s).include?("create_mediator")
15
- def create_mediator(suite)
16
- # swap in our custom mediator
17
- return CI::Reporter::TestUnit.new(suite)
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
24
-
25
- # Intercepts mediator creation in ruby-test >= 2.1
26
- module Test #:nodoc:all
27
- module Unit
28
- module UI
29
- class TestRunner
30
- undef :setup_mediator if instance_methods.map(&:to_s).include?("setup_mediator")
31
- def setup_mediator
32
- # swap in our custom mediator
33
- @mediator = CI::Reporter::TestUnit.new(@suite)
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,220 +0,0 @@
1
- # Copyright (c) 2006-2012 Nick Sieger <nicksieger@gmail.com>
2
- # See the file LICENSE.txt included with the distribution for
3
- # software license details.
4
-
5
- require 'ci/reporter/core'
6
-
7
- module CI
8
- module Reporter
9
- module RSpecFormatters
10
- begin
11
- require 'rspec/core/formatters/base_formatter'
12
- require 'rspec/core/formatters/progress_formatter'
13
- require 'rspec/core/formatters/documentation_formatter'
14
- BaseFormatter = ::RSpec::Core::Formatters::BaseFormatter
15
- ProgressFormatter = ::RSpec::Core::Formatters::ProgressFormatter
16
- DocFormatter = ::RSpec::Core::Formatters::DocumentationFormatter
17
- # See https://github.com/nicksieger/ci_reporter/issues/76 and
18
- # https://github.com/nicksieger/ci_reporter/issues/80
19
- require 'rspec/core/version'
20
- RSpec_2_12_0_bug = (::RSpec::Core::Version::STRING == '2.12.0' &&
21
- !BaseFormatter.instance_methods(false).map(&:to_s).include?("format_backtrace"))
22
- rescue LoadError => first_error
23
- begin
24
- require 'spec/runner/formatter/progress_bar_formatter'
25
- require 'spec/runner/formatter/specdoc_formatter'
26
- BaseFormatter = ::Spec::Runner::Formatter::BaseFormatter
27
- ProgressFormatter = ::Spec::Runner::Formatter::ProgressBarFormatter
28
- DocFormatter = ::Spec::Runner::Formatter::SpecdocFormatter
29
- rescue LoadError
30
- raise first_error
31
- end
32
- end
33
- end
34
-
35
- # Wrapper around a <code>RSpec</code> error or failure to be used by the test suite to interpret results.
36
- class RSpecFailure
37
- attr_reader :exception
38
- def initialize(failure)
39
- @failure = failure
40
- @exception = failure.exception
41
- end
42
-
43
- def failure?
44
- @failure.expectation_not_met?
45
- end
46
-
47
- def error?
48
- !failure?
49
- end
50
-
51
- def name() exception.class.name end
52
- def message() exception.message end
53
- def location() (exception.backtrace || ["No backtrace available"]).join("\n") end
54
- end
55
-
56
- class RSpec2Failure < RSpecFailure
57
- def initialize(example, formatter)
58
- @formatter = formatter
59
- @example = example
60
- if @example.respond_to?(:execution_result)
61
- @exception = @example.execution_result[:exception] || @example.execution_result[:exception_encountered]
62
- else
63
- @exception = @example.metadata[:execution_result][:exception]
64
- end
65
- end
66
-
67
- def name
68
- @exception.class.name
69
- end
70
-
71
- def message
72
- @exception.message
73
- end
74
-
75
- def failure?
76
- exception.is_a?(::RSpec::Expectations::ExpectationNotMetError)
77
- end
78
-
79
- def location
80
- output = []
81
- output.push "#{exception.class.name << ":"}" unless exception.class.name =~ /RSpec/
82
- output.push @exception.message
83
-
84
- format_metadata = RSpecFormatters::RSpec_2_12_0_bug ? @example.metadata : @example
85
-
86
- [@formatter.format_backtrace(@exception.backtrace, format_metadata)].flatten.each do |backtrace_info|
87
- backtrace_info.lines.each do |line|
88
- output.push " #{line}"
89
- end
90
- end
91
- output.join "\n"
92
- end
93
- end
94
-
95
- # Custom +RSpec+ formatter used to hook into the spec runs and capture results.
96
- class RSpec
97
- attr_accessor :report_manager
98
- attr_accessor :formatter
99
- def initialize(*args)
100
- @formatter ||= RSpecFormatters::ProgressFormatter.new(*args)
101
- @report_manager = ReportManager.new("spec")
102
- @suite = nil
103
- end
104
-
105
- # rspec 0.9
106
- def add_behaviour(name)
107
- @formatter.add_behaviour(name)
108
- new_suite(name)
109
- end
110
-
111
- # Compatibility with rspec < 1.2.4
112
- def add_example_group(example_group)
113
- @formatter.add_example_group(example_group)
114
- new_suite(description_for(example_group))
115
- end
116
-
117
- # rspec >= 1.2.4
118
- def example_group_started(example_group)
119
- @formatter.example_group_started(example_group)
120
- new_suite(description_for(example_group))
121
- end
122
-
123
- def example_started(name_or_example)
124
- @formatter.example_started(name_or_example)
125
- spec = TestCase.new
126
- @suite.testcases << spec
127
- spec.start
128
- end
129
-
130
- def example_failed(name_or_example, *rest)
131
- @formatter.example_failed(name_or_example, *rest)
132
-
133
- # In case we fail in before(:all)
134
- example_started(name_or_example) if @suite.testcases.empty?
135
-
136
- if name_or_example.respond_to?(:execution_result) # RSpec 2
137
- failure = RSpec2Failure.new(name_or_example, @formatter)
138
- else
139
- failure = RSpecFailure.new(rest[1]) # example_failed(name, counter, failure) in RSpec 1
140
- end
141
-
142
- spec = @suite.testcases.last
143
- spec.finish
144
- spec.name = description_for(name_or_example)
145
- spec.failures << failure
146
- end
147
-
148
- def example_passed(name_or_example)
149
- @formatter.example_passed(name_or_example)
150
- spec = @suite.testcases.last
151
- spec.finish
152
- spec.name = description_for(name_or_example)
153
- end
154
-
155
- def example_pending(*args)
156
- @formatter.example_pending(*args)
157
- name = description_for(args[0])
158
- spec = @suite.testcases.last
159
- spec.finish
160
- spec.name = "#{name} (PENDING)"
161
- spec.skipped = true
162
- end
163
-
164
- def dump_summary(*args)
165
- @formatter.dump_summary(*args)
166
- write_report
167
- @formatter.dump_failures
168
- end
169
-
170
- def respond_to?(*args)
171
- @formatter.respond_to?(*args)
172
- end
173
-
174
- # Pass through other methods to RSpec formatter for compatibility
175
- def method_missing(meth,*args,&block)
176
- @formatter.send(meth,*args,&block)
177
- end
178
-
179
- private
180
- def description_for(name_or_example)
181
- if name_or_example.respond_to?(:full_description)
182
- name_or_example.full_description
183
- elsif name_or_example.respond_to?(:metadata)
184
- name_or_example.metadata[:example_group][:full_description]
185
- elsif name_or_example.respond_to?(:description)
186
- name_or_example.description
187
- else
188
- "UNKNOWN"
189
- end
190
- end
191
-
192
- def write_report
193
- if @suite
194
- @suite.finish
195
- @report_manager.write_report(@suite)
196
- end
197
- end
198
-
199
- def new_suite(name)
200
- write_report if @suite
201
- @suite = TestSuite.new name
202
- @suite.start
203
- end
204
- end
205
-
206
- class RSpecDoc < RSpec
207
- def initialize(*args)
208
- @formatter = RSpecFormatters::DocFormatter.new(*args)
209
- super
210
- end
211
- end
212
-
213
- class RSpecBase < RSpec
214
- def initialize(*args)
215
- @formatter = RSpecFormatters::BaseFormatter.new(*args)
216
- super
217
- end
218
- end
219
- end
220
- end
@@ -1,80 +0,0 @@
1
- require 'ci/reporter/core'
2
- require 'spinach'
3
-
4
- module CI
5
- module Reporter
6
- class Spinach < ::Spinach::Reporter
7
- def initialize(options = nil)
8
- @options = options
9
- @report_manager = ReportManager.new('features')
10
- end
11
-
12
- def before_feature_run(feature)
13
- @test_suite = TestSuite.new(feature.is_a?(Hash) ? feature['name'] : feature.name)
14
- @test_suite.start
15
- end
16
-
17
- def before_scenario_run(scenario, step_definitions = nil)
18
- @test_case = TestCase.new(scenario.is_a?(Hash) ? scenario['name'] : scenario.name)
19
- @test_case.start
20
- end
21
-
22
- def on_undefined_step(step, failure, step_definitions = nil)
23
- @test_case.failures << SpinachFailure.new(:error, step, failure, nil)
24
- end
25
-
26
- def on_failed_step(step, failure, step_location, step_definitions = nil)
27
- @test_case.failures << SpinachFailure.new(:failed, step, failure, step_location)
28
- end
29
-
30
- def on_error_step(step, failure, step_location, step_definitions = nil)
31
- @test_case.failures << SpinachFailure.new(:error, step, failure, step_location)
32
- end
33
-
34
- def after_scenario_run(scenario, step_definitions = nil)
35
- @test_case.finish
36
- @test_suite.testcases << @test_case
37
- @test_case = nil
38
- end
39
-
40
- def after_feature_run(feature)
41
- @test_suite.finish
42
- @report_manager.write_report(@test_suite)
43
- @test_suite = nil
44
- end
45
- end
46
-
47
- class SpinachFailure
48
- def initialize(type, step, failure, step_location)
49
- @type = type
50
- @step = step
51
- @failure = failure
52
- @step_location = step_location
53
- end
54
-
55
- def failure?
56
- @type == :failed
57
- end
58
-
59
- def error?
60
- @type == :error
61
- end
62
-
63
- def name
64
- @failure.class.name
65
- end
66
-
67
- def message
68
- @failure.message
69
- end
70
-
71
- def location
72
- @failure.backtrace.join("\n")
73
- end
74
- end
75
- end
76
- end
77
-
78
- class Spinach::Reporter
79
- CiReporter = ::CI::Reporter::Spinach
80
- end
@@ -1,163 +0,0 @@
1
- # Copyright (c) 2006-2012 Nick Sieger <nicksieger@gmail.com>
2
- # See the file LICENSE.txt included with the distribution for
3
- # software license details.
4
-
5
- require 'ci/reporter/core'
6
- require 'test/unit'
7
- require 'test/unit/ui/console/testrunner'
8
-
9
- module CI
10
- module Reporter
11
- # Factory for constructing either a CI::Reporter::TestUnitFailure or CI::Reporter::TestUnitError depending on the result
12
- # of the test.
13
- class Failure
14
- CONST_DEFINED_ARITY = Module.method(:const_defined?).arity
15
-
16
- def self.omission_constant?
17
- if CONST_DEFINED_ARITY == 1 # 1.8.7 varieties
18
- Test::Unit.const_defined?(:Omission)
19
- else
20
- Test::Unit.const_defined?(:Omission, false)
21
- end
22
- end
23
-
24
- def self.notification_constant?
25
- if CONST_DEFINED_ARITY == 1 # 1.8.7 varieties
26
- Test::Unit.const_defined?(:Notification)
27
- else
28
- Test::Unit.const_defined?(:Notification, false)
29
- end
30
- end
31
-
32
- def self.new(fault)
33
- return TestUnitFailure.new(fault) if fault.kind_of?(Test::Unit::Failure)
34
- return TestUnitSkipped.new(fault) if omission_constant? &&
35
- (fault.kind_of?(Test::Unit::Omission) || fault.kind_of?(Test::Unit::Pending))
36
- return TestUnitNotification.new(fault) if notification_constant? &&
37
- fault.kind_of?(Test::Unit::Notification)
38
- TestUnitError.new(fault)
39
- end
40
- end
41
-
42
- # Wrapper around a <code>Test::Unit</code> error to be used by the test suite to interpret results.
43
- class TestUnitError
44
- def initialize(fault) @fault = fault end
45
- def failure?() false end
46
- def error?() true end
47
- def name() @fault.exception.class.name end
48
- def message() @fault.exception.message end
49
- def location() @fault.exception.backtrace.join("\n") end
50
- end
51
-
52
- # Wrapper around a <code>Test::Unit</code> failure to be used by the test suite to interpret results.
53
- class TestUnitFailure
54
- def initialize(fault) @fault = fault end
55
- def failure?() true end
56
- def error?() false end
57
- def name() Test::Unit::AssertionFailedError.name end
58
- def message() @fault.message end
59
- def location() @fault.location.join("\n") end
60
- end
61
-
62
- # Wrapper around a <code>Test::Unit</code> 2.0 omission.
63
- class TestUnitSkipped
64
- def initialize(fault) @fault = fault end
65
- def failure?() false end
66
- def error?() false end
67
- def name() @fault.class.name end
68
- def message() @fault.message end
69
- def location() @fault.location.join("\n") end
70
- end
71
-
72
- # Wrapper around a <code>Test::Unit</code> 2.0 notification.
73
- class TestUnitNotification
74
- def initialize(fault) @fault = fault end
75
- def failure?() false end
76
- def error?() false end
77
- def name() @fault.class.name end
78
- def message() @fault.message end
79
- def location() @fault.location.join("\n") end
80
- end
81
-
82
- # Replacement Mediator that adds listeners to capture the results of the <code>Test::Unit</code> runs.
83
- class TestUnit < Test::Unit::UI::TestRunnerMediator
84
- def initialize(suite, report_mgr = nil)
85
- super(suite)
86
- @report_manager = report_mgr || ReportManager.new("test")
87
- add_listener(Test::Unit::UI::TestRunnerMediator::STARTED, &method(:started))
88
- add_listener(Test::Unit::TestCase::STARTED, &method(:test_started))
89
- add_listener(Test::Unit::TestCase::FINISHED, &method(:test_finished))
90
- add_listener(Test::Unit::TestResult::FAULT, &method(:fault))
91
- add_listener(Test::Unit::UI::TestRunnerMediator::FINISHED, &method(:finished))
92
- end
93
-
94
- def started(result)
95
- @suite_result = result
96
- @last_assertion_count = 0
97
- @current_suite = nil
98
- @unknown_count = 0
99
- @result_assertion_count = 0
100
- end
101
-
102
- def test_started(name)
103
- test_name, suite_name = extract_names(name)
104
- unless @current_suite && @current_suite.name == suite_name
105
- finish_suite
106
- start_suite(suite_name)
107
- end
108
- start_test(test_name)
109
- end
110
-
111
- def test_finished(name)
112
- finish_test
113
- end
114
-
115
- def fault(fault)
116
- tc = @current_suite.testcases.last
117
- tc.failures << Failure.new(fault)
118
- end
119
-
120
- def finished(elapsed_time)
121
- finish_suite
122
- end
123
-
124
- private
125
- def extract_names(name)
126
- match = name.match(/(.*)\(([^)]*)\)/)
127
- if match
128
- [match[1], match[2]]
129
- else
130
- @unknown_count += 1
131
- [name, "unknown-#{@unknown_count}"]
132
- end
133
- end
134
-
135
- def start_suite(suite_name)
136
- @current_suite = TestSuite.new(suite_name)
137
- @current_suite.start
138
- end
139
-
140
- def finish_suite
141
- if @current_suite
142
- @current_suite.finish
143
- @current_suite.assertions = @suite_result.assertion_count - @last_assertion_count
144
- @last_assertion_count = @suite_result.assertion_count
145
- @report_manager.write_report(@current_suite)
146
- end
147
- end
148
-
149
- def start_test(test_name)
150
- tc = TestCase.new(test_name)
151
- tc.start
152
- @current_suite.testcases << tc
153
- end
154
-
155
- def finish_test
156
- tc = @current_suite.testcases.last
157
- tc.finish
158
- tc.assertions = @suite_result.assertion_count - @result_assertion_count
159
- @result_assertion_count = @suite_result.assertion_count
160
- end
161
- end
162
- end
163
- end