ci_reporter 1.3.5 → 1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,9 @@
1
+ == 1.4
2
+
3
+ - Test::Unit tests that fail in multiple places (setup, test method, and teardown) are now tracked (marcog)
4
+ - Explicit dependency requirement on Builder (>= 2.1.2)
5
+ - Use of RSpec < 0.9 is now deprecated; support will probably disappear in the next version
6
+
1
7
  == 1.3.5
2
8
 
3
9
  - Change way we append to environment variables to appease windows (Tracker #13998, Adam Anderson)
data/Rakefile CHANGED
@@ -1,12 +1,13 @@
1
1
  require 'spec/rake/spectask'
2
+ require 'spec/rake/verify_rcov'
2
3
 
3
4
  MANIFEST = FileList["History.txt", "Manifest.txt", "README.txt", "LICENSE.txt", "Rakefile",
4
5
  "*.rake", "lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake"]
5
6
 
6
- require File.dirname(__FILE__) + '/lib/ci/reporter/version'
7
7
  begin
8
- touch("Manifest.txt") unless File.exist?("Manifest.txt")
8
+ File.open("Manifest.txt", "w") {|f| MANIFEST.each {|n| f << "#{n}\n"} }
9
9
  require 'hoe'
10
+ require File.dirname(__FILE__) + '/lib/ci/reporter/version'
10
11
  hoe = Hoe.new("ci_reporter", CI::Reporter::VERSION) do |p|
11
12
  p.rubyforge_name = "caldersphere"
12
13
  p.url = "http://caldersphere.rubyforge.org/ci_reporter"
@@ -17,6 +18,7 @@ begin
17
18
  p.description = p.paragraphs_of('README.txt', 0...1).join("\n\n")
18
19
  p.extra_deps.reject!{|d| d.first == "hoe"}
19
20
  p.test_globs = ["spec/**/*_spec.rb"]
21
+ p.extra_deps << ['builder', ">= 2.1.2"]
20
22
  end
21
23
  hoe.spec.files = MANIFEST
22
24
  hoe.spec.dependencies.delete_if { |dep| dep.name == "hoe" }
@@ -28,16 +30,42 @@ end
28
30
  # !@#$ no easy way to empty the default list of prerequisites
29
31
  Rake::Task['default'].send :instance_variable_set, "@prerequisites", FileList[]
30
32
 
31
- task :default => :spec
33
+ task :default => :rcov
32
34
 
33
35
  Spec::Rake::SpecTask.new do |t|
34
36
  t.spec_opts ||= []
35
37
  t.spec_opts << "--diff" << "unified"
36
38
  end
37
39
 
38
- # Automated manifest
39
- task :manifest do
40
- File.open("Manifest.txt", "w") {|f| MANIFEST.each {|n| f << "#{n}\n"} }
40
+ Spec::Rake::SpecTask.new("spec:rcov") do |t|
41
+ t.rcov = true
42
+ end
43
+ # so we don't confuse autotest
44
+ RCov::VerifyTask.new(:rcov) do |t|
45
+ # Can't get threshold up to 100 until the RSpec < 1.0 compatibility
46
+ # code is dropped
47
+ t.threshold = 97
48
+ t.require_exact_threshold = false
49
+ end
50
+ task "spec:rcov" do
51
+ rm_f "Manifest.txt"
52
+ end
53
+ task :rcov => "spec:rcov"
54
+
55
+ task :generate_output do
56
+ ENV['CI_REPORTS'] = "acceptance/reports"
57
+ begin
58
+ `ruby -Ilib acceptance/test_unit_example_test.rb` rescue nil
59
+ `ruby -Ilib -S spec --require ci/reporter/rake/rspec_loader --format CI::Reporter::RSpec acceptance/rspec_example_spec.rb` rescue nil
60
+ ensure
61
+ ENV.delete 'CI_REPORTS'
62
+ end
63
+ end
64
+ task :acceptance => :generate_output
65
+
66
+ Spec::Rake::SpecTask.new(:acceptance_spec) do |t|
67
+ t.spec_files = FileList['acceptance/verification_spec.rb']
41
68
  end
69
+ task :acceptance => :acceptance_spec
42
70
 
43
- task :package => :manifest
71
+ task :default => :acceptance
@@ -46,6 +46,15 @@ module CI
46
46
  @suite = nil
47
47
  end
48
48
 
49
+ def deprecated
50
+ unless @warned
51
+ require 'ci/reporter/version'
52
+ warn "warning: use of RSpec < 0.9 with CI::Reporter #{CI::Reporter::VERSION} is deprecated;"
53
+ warn "a future version will not be compatible."
54
+ end
55
+ @warned = true
56
+ end
57
+
49
58
  def start(spec_count)
50
59
  super
51
60
  end
@@ -53,6 +62,7 @@ module CI
53
62
  # Pre-0.9 hook
54
63
  def add_context(name, first)
55
64
  super
65
+ deprecated
56
66
  new_suite(name)
57
67
  end
58
68
 
@@ -65,6 +75,7 @@ module CI
65
75
  # Pre-0.9 hook
66
76
  def spec_started(name)
67
77
  super
78
+ deprecated
68
79
  case_started(name)
69
80
  end
70
81
 
@@ -77,6 +88,7 @@ module CI
77
88
  # Pre-0.9 hook
78
89
  def spec_failed(name, counter, failure)
79
90
  super
91
+ deprecated
80
92
  case_failed(name, counter, failure)
81
93
  end
82
94
 
@@ -89,6 +101,7 @@ module CI
89
101
  # Pre-0.9 hook
90
102
  def spec_passed(name)
91
103
  super
104
+ deprecated
92
105
  case_passed(name)
93
106
  end
94
107
 
@@ -136,7 +149,7 @@ module CI
136
149
  def case_failed(name, counter, failure)
137
150
  spec = @suite.testcases.last
138
151
  spec.finish
139
- spec.failure = RSpecFailure.new(failure)
152
+ spec.failures << RSpecFailure.new(failure)
140
153
  end
141
154
 
142
155
  def case_passed(name)
@@ -57,25 +57,17 @@ module CI
57
57
  def finish
58
58
  self.tests = testcases.size
59
59
  self.time = Time.now - @start
60
- self.failures = testcases.select {|tc| tc.failure? }.size
61
- self.errors = testcases.select {|tc| tc.error? }.size
60
+ self.failures = testcases.inject(0) {|sum,tc| sum += tc.failures.select{|f| f.failure? }.size }
61
+ self.errors = testcases.inject(0) {|sum,tc| sum += tc.failures.select{|f| f.error? }.size }
62
62
  self.stdout = @capture_out.finish if @capture_out
63
63
  self.stderr = @capture_err.finish if @capture_err
64
64
  end
65
65
 
66
66
  # Creates the xml builder instance used to create the report xml document.
67
67
  def create_builder
68
- begin
69
- gem 'builder'
70
- require 'builder'
71
- rescue
72
- begin
73
- gem 'activesupport'
74
- require 'active_support'
75
- rescue
76
- raise LoadError, "XML Builder is required by CI::Reporter"
77
- end
78
- end unless defined?(Builder::XmlMarkup)
68
+ require 'rubygems'
69
+ gem 'builder'
70
+ require 'builder'
79
71
  # :escape_attrs is obsolete in a newer version, but should do no harm
80
72
  Builder::XmlMarkup.new(:indent => 2, :escape_attrs => true)
81
73
  end
@@ -84,14 +76,8 @@ module CI
84
76
  def to_xml
85
77
  builder = create_builder
86
78
  # more recent version of Builder doesn't need the escaping
87
- if Builder::XmlMarkup.private_instance_methods.include?("_attr_value")
88
- def builder.trunc!(txt)
89
- txt.sub(/\n.*/m, '...')
90
- end
91
- else
92
- def builder.trunc!(txt)
93
- _escape(txt.sub(/\n.*/m, '...'))
94
- end
79
+ def builder.trunc!(txt)
80
+ txt.sub(/\n.*/m, '...')
95
81
  end
96
82
  builder.instruct!
97
83
  attrs = {}
@@ -112,7 +98,12 @@ module CI
112
98
 
113
99
  # Structure used to represent an individual test case. Used to time the test and store the result.
114
100
  class TestCase < Struct.new(:name, :time, :assertions)
115
- attr_accessor :failure
101
+ attr_accessor :failures
102
+
103
+ def initialize(*args)
104
+ super
105
+ @failures = []
106
+ end
116
107
 
117
108
  # Starts timing the test.
118
109
  def start
@@ -126,12 +117,12 @@ module CI
126
117
 
127
118
  # Returns non-nil if the test failed.
128
119
  def failure?
129
- failure && failure.failure?
120
+ !failures.empty? && failures.detect {|f| f.failure? }
130
121
  end
131
122
 
132
123
  # Returns non-nil if the test had an error.
133
124
  def error?
134
- failure && failure.error?
125
+ !failures.empty? && failures.detect {|f| f.error? }
135
126
  end
136
127
 
137
128
  # Writes xml representing the test result to the provided builder.
@@ -139,7 +130,7 @@ module CI
139
130
  attrs = {}
140
131
  each_pair {|k,v| attrs[k] = builder.trunc!(v.to_s) unless v.nil? || v.to_s.empty?}
141
132
  builder.testcase(attrs) do
142
- if failure
133
+ failures.each do |failure|
143
134
  builder.failure(:type => builder.trunc!(failure.name), :message => builder.trunc!(failure.message)) do
144
135
  builder.text!(failure.message + " (#{failure.name})\n")
145
136
  builder.text!(failure.location)
@@ -74,7 +74,8 @@ module CI
74
74
  end
75
75
 
76
76
  def fault(fault)
77
- finish_test(fault)
77
+ tc = @current_suite.testcases.last
78
+ tc.failures << Failure.new(fault)
78
79
  end
79
80
 
80
81
  def finished(elapsed_time)
@@ -112,10 +113,9 @@ module CI
112
113
  @current_suite.testcases << tc
113
114
  end
114
115
 
115
- def finish_test(failure = nil)
116
+ def finish_test
116
117
  tc = @current_suite.testcases.last
117
118
  tc.finish
118
- tc.failure = Failure.new(failure) if failure
119
119
  tc.assertions = @suite_result.assertion_count - @result_assertion_count
120
120
  @result_assertion_count = @suite_result.assertion_count
121
121
  end
@@ -1,5 +1,5 @@
1
1
  module CI
2
2
  module Reporter
3
- VERSION = "1.3.5"
3
+ VERSION = "1.4"
4
4
  end
5
5
  end
@@ -8,13 +8,6 @@ require 'stringio'
8
8
  describe "The RSpec reporter" do
9
9
  before(:each) do
10
10
  @error = mock("error")
11
- @error.stub!(:exception).and_return do
12
- begin
13
- raise StandardError, "error message"
14
- rescue => e
15
- e
16
- end
17
- end
18
11
  @error.stub!(:expectation_not_met?).and_return(false)
19
12
  @error.stub!(:pending_fixed?).and_return(false)
20
13
  @report_mgr = mock("report manager")
@@ -37,4 +30,11 @@ describe "The RSpec reporter" do
37
30
  @fmt.example_failed("should fail", 1, @error)
38
31
  @fmt.dump_summary(0.1, 2, 1)
39
32
  end
33
+
34
+ it "should report deprecation when called with RSpec < 0.9" do
35
+ @fmt.should_receive(:warn).exactly(2).times
36
+ @fmt.deprecated
37
+ @fmt.deprecated
38
+ @fmt.deprecated
39
+ end
40
40
  end
@@ -41,9 +41,9 @@ describe "A TestSuite" do
41
41
  @suite.start
42
42
  @suite.testcases << CI::Reporter::TestCase.new("example test")
43
43
  @suite.testcases << CI::Reporter::TestCase.new("failure test")
44
- @suite.testcases.last.failure = failure
44
+ @suite.testcases.last.failures << failure
45
45
  @suite.testcases << CI::Reporter::TestCase.new("error test")
46
- @suite.testcases.last.failure = error
46
+ @suite.testcases.last.failures << error
47
47
  @suite.finish
48
48
  @suite.tests.should == 3
49
49
  @suite.failures.should == 1
@@ -80,9 +80,9 @@ describe "TestSuite xml" do
80
80
  @suite.start
81
81
  @suite.testcases << CI::Reporter::TestCase.new("example test")
82
82
  @suite.testcases << CI::Reporter::TestCase.new("failure test")
83
- @suite.testcases.last.failure = failure
83
+ @suite.testcases.last.failures << failure
84
84
  @suite.testcases << CI::Reporter::TestCase.new("error test")
85
- @suite.testcases.last.failure = error
85
+ @suite.testcases.last.failures << error
86
86
  @suite.finish
87
87
 
88
88
  xml = @suite.to_xml
@@ -108,7 +108,7 @@ describe "TestSuite xml" do
108
108
  @suite.start
109
109
  @suite.testcases << CI::Reporter::TestCase.new("example test")
110
110
  @suite.testcases << CI::Reporter::TestCase.new("failure test")
111
- @suite.testcases.last.failure = failure
111
+ @suite.testcases.last.failures << failure
112
112
  @suite.finish
113
113
 
114
114
  xml = @suite.to_xml
@@ -129,7 +129,7 @@ describe "TestSuite xml" do
129
129
 
130
130
  @suite.start
131
131
  @suite.testcases << CI::Reporter::TestCase.new("failure test")
132
- @suite.testcases.last.failure = failure
132
+ @suite.testcases.last.failures << failure
133
133
  @suite.finish
134
134
 
135
135
  xml = @suite.to_xml
@@ -69,6 +69,24 @@ describe "The TestUnit reporter" do
69
69
  end
70
70
 
71
71
  it "should add failures to testcases when encountering a fault" do
72
+ @failure = Test::Unit::Failure.new("test_one(TestCaseClass)", "somewhere:10", "it failed")
73
+
74
+ @suite = nil
75
+ @report_mgr.should_receive(:write_report).once.and_return {|suite| @suite = suite }
76
+
77
+ @testunit.started(@result)
78
+ @testunit.test_started("test_one(TestCaseClass)")
79
+ @testunit.fault(@failure)
80
+ @testunit.test_finished("test_one(TestCaseClass)")
81
+ @testunit.finished(10)
82
+
83
+ @suite.name.should == "TestCaseClass"
84
+ @suite.testcases.length.should == 1
85
+ @suite.testcases.first.name.should == "test_one"
86
+ @suite.testcases.first.should be_failure
87
+ end
88
+
89
+ it "should add errors to testcases when encountering a fault" do
72
90
  begin
73
91
  raise StandardError, "error"
74
92
  rescue => e
@@ -83,6 +101,7 @@ describe "The TestUnit reporter" do
83
101
  @testunit.test_finished("test_one(TestCaseClass)")
84
102
  @testunit.test_started("test_two(TestCaseClass)")
85
103
  @testunit.fault(@error)
104
+ @testunit.test_finished("test_two(TestCaseClass)")
86
105
  @testunit.finished(10)
87
106
 
88
107
  @suite.name.should == "TestCaseClass"
@@ -94,4 +113,40 @@ describe "The TestUnit reporter" do
94
113
  @suite.testcases.last.should_not be_failure
95
114
  @suite.testcases.last.should be_error
96
115
  end
116
+
117
+ it "should add multiple failures to a testcase" do
118
+ @failure1 = Test::Unit::Failure.new("test_one(TestCaseClass)", "somewhere:10", "it failed")
119
+ @failure2 = Test::Unit::Failure.new("test_one(TestCaseClass)", "somewhere:12", "it failed again in teardown")
120
+
121
+ @suite = nil
122
+ @report_mgr.should_receive(:write_report).once.and_return {|suite| @suite = suite }
123
+
124
+ @testunit.started(@result)
125
+ @testunit.test_started("test_one(TestCaseClass)")
126
+ @testunit.fault(@failure1)
127
+ @testunit.fault(@failure2)
128
+ @testunit.test_finished("test_one(TestCaseClass)")
129
+ @testunit.finished(10)
130
+
131
+ @suite.name.should == "TestCaseClass"
132
+ @suite.testcases.length.should == 1
133
+ @suite.testcases.first.name.should == "test_one"
134
+ @suite.testcases.first.should be_failure
135
+ @suite.testcases.first.failures.size.should == 2
136
+ @suite.failures.should == 2
137
+ end
138
+
139
+ it "should count test case names that don't conform to the standard pattern" do
140
+ @suite = nil
141
+ @report_mgr.should_receive(:write_report).once.and_return {|suite| @suite = suite }
142
+
143
+ @testunit.started(@result)
144
+ @testunit.test_started("some unknown test")
145
+ @testunit.test_finished("some unknown test")
146
+ @testunit.finished(10)
147
+
148
+ @suite.name.should == "unknown-1"
149
+ @suite.testcases.length.should == 1
150
+ @suite.testcases.first.name.should == "some unknown test"
151
+ end
97
152
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: ci_reporter
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.3.5
7
- date: 2007-09-25 00:00:00 -05:00
6
+ version: "1.4"
7
+ date: 2007-11-23 00:00:00 -06:00
8
8
  summary: CI::Reporter allows you to generate reams of XML for use with continuous integration systems.
9
9
  require_paths:
10
10
  - lib
@@ -74,5 +74,13 @@ extensions: []
74
74
 
75
75
  requirements: []
76
76
 
77
- dependencies: []
78
-
77
+ dependencies:
78
+ - !ruby/object:Gem::Dependency
79
+ name: builder
80
+ version_requirement:
81
+ version_requirements: !ruby/object:Gem::Version::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 2.1.2
86
+ version: