ci_reporter 1.1 → 1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -1
- data/Manifest.txt +1 -0
- data/README.txt +2 -6
- data/Rakefile +1 -1
- data/lib/ci/reporter/test_suite.rb +42 -0
- data/spec/ci/reporter/output_capture_spec.rb +53 -0
- metadata +4 -2
data/History.txt
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
+
== 1.2
|
2
|
+
|
3
|
+
- Capture standard output and standard error during each individual test suite and include in the XML file in system-out and system-err elements, respectively (Tracker#9054[http://rubyforge.org/tracker/index.php?func=detail&aid=9054&group_id=2857&atid=11007])
|
4
|
+
|
1
5
|
== 1.1
|
2
6
|
|
3
7
|
- Add +assertions+ attribute to the +testsuite+ element that will contain per-suite assertion counts when used with Test::Unit. Not useful with applications that read Ant/JUnit XML, but custom applications may wish to access it.
|
4
8
|
|
5
9
|
== 1.0
|
6
10
|
|
7
|
-
Initial Release.
|
11
|
+
- Initial Release.
|
data/Manifest.txt
CHANGED
@@ -12,6 +12,7 @@ lib/ci/reporter/rake/rspec_loader.rb
|
|
12
12
|
lib/ci/reporter/rake/test_unit.rb
|
13
13
|
lib/ci/reporter/rake/test_unit_loader.rb
|
14
14
|
spec/spec_helper.rb
|
15
|
+
spec/ci/reporter/output_capture_spec.rb
|
15
16
|
spec/ci/reporter/report_manager_spec.rb
|
16
17
|
spec/ci/reporter/rspec_spec.rb
|
17
18
|
spec/ci/reporter/test_suite_spec.rb
|
data/README.txt
CHANGED
@@ -1,8 +1,4 @@
|
|
1
|
-
CI::Reporter is an add-on to Test::Unit and RSpec that allows you to generate
|
2
|
-
XML reports of your test and/or spec runs. The resulting files can be read by
|
3
|
-
a continuous integration system that understands Ant's JUnit report XML
|
4
|
-
format, thus allowing your CI system to track test/spec successes and
|
5
|
-
failures.
|
1
|
+
CI::Reporter is an add-on to Test::Unit and RSpec that allows you to generate XML reports of your test and/or spec runs. The resulting files can be read by a continuous integration system that understands Ant's JUnit report XML format, thus allowing your CI system to track test/spec successes and failures.
|
6
2
|
|
7
3
|
== Dependencies
|
8
4
|
|
@@ -10,7 +6,7 @@ CI::Reporter has one required dependency on Builder, but since many will have a
|
|
10
6
|
|
11
7
|
== Installation
|
12
8
|
|
13
|
-
CI::Reporter is available as a gem. To install the gem, use the usual gem command:
|
9
|
+
CI::Reporter is available as a gem. To install the gem, use the usual gem command:
|
14
10
|
|
15
11
|
gem install ci_reporter
|
16
12
|
|
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ require 'hoe'
|
|
4
4
|
MANIFEST = FileList["History.txt", "Manifest.txt", "README.txt", "Rakefile",
|
5
5
|
"lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake"]
|
6
6
|
|
7
|
-
Hoe.new("ci_reporter", "1.
|
7
|
+
Hoe.new("ci_reporter", "1.2") do |p|
|
8
8
|
p.rubyforge_name = "caldersphere"
|
9
9
|
p.url = "http://caldersphere.rubyforge.org/ci_reporter"
|
10
10
|
p.author = "Nick Sieger"
|
@@ -1,8 +1,40 @@
|
|
1
|
+
require 'delegate'
|
2
|
+
require 'stringio'
|
3
|
+
|
1
4
|
module CI
|
2
5
|
module Reporter
|
6
|
+
# Emulates/delegates IO to $stdout or $stderr in order to capture output to report in the XML file.
|
7
|
+
class OutputCapture < DelegateClass(IO)
|
8
|
+
# Start capturing IO, using the given block to assign self to the proper IO global.
|
9
|
+
def initialize(io, &assign)
|
10
|
+
super
|
11
|
+
@delegate_io = io
|
12
|
+
@captured_io = StringIO.new
|
13
|
+
@assign_block = assign
|
14
|
+
@assign_block.call self
|
15
|
+
end
|
16
|
+
|
17
|
+
# Finalize the capture and reset to the original IO object.
|
18
|
+
def finish
|
19
|
+
@assign_block.call @delegate_io
|
20
|
+
@captured_io.string
|
21
|
+
end
|
22
|
+
|
23
|
+
# setup tee methods
|
24
|
+
%w(<< print printf putc puts write).each do |m|
|
25
|
+
module_eval(<<-EOS, __FILE__, __LINE__)
|
26
|
+
def #{m}(*args, &block)
|
27
|
+
@delegate_io.send(:#{m}, *args, &block)
|
28
|
+
@captured_io.send(:#{m}, *args, &block)
|
29
|
+
end
|
30
|
+
EOS
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
3
34
|
# Basic structure representing the running of a test suite. Used to time tests and store results.
|
4
35
|
class TestSuite < Struct.new(:name, :tests, :time, :failures, :errors, :assertions)
|
5
36
|
attr_accessor :testcases
|
37
|
+
attr_accessor :stdout, :stderr
|
6
38
|
def initialize(name)
|
7
39
|
super
|
8
40
|
@testcases = []
|
@@ -11,6 +43,8 @@ module CI
|
|
11
43
|
# Starts timing the test suite.
|
12
44
|
def start
|
13
45
|
@start = Time.now
|
46
|
+
@capture_out = OutputCapture.new($stdout) {|io| $stdout = io }
|
47
|
+
@capture_err = OutputCapture.new($stderr) {|io| $stderr = io }
|
14
48
|
end
|
15
49
|
|
16
50
|
# Finishes timing the test suite.
|
@@ -19,6 +53,8 @@ module CI
|
|
19
53
|
self.time = Time.now - @start
|
20
54
|
self.failures = testcases.select {|tc| tc.failure? }.size
|
21
55
|
self.errors = testcases.select {|tc| tc.error? }.size
|
56
|
+
self.stdout = @capture_out.finish
|
57
|
+
self.stderr = @capture_err.finish
|
22
58
|
end
|
23
59
|
|
24
60
|
# Creates the xml builder instance used to create the report xml document.
|
@@ -58,6 +94,12 @@ module CI
|
|
58
94
|
@testcases.each do |tc|
|
59
95
|
tc.to_xml(builder)
|
60
96
|
end
|
97
|
+
builder.tag! "system-out" do
|
98
|
+
builder.cdata! self.stdout
|
99
|
+
end
|
100
|
+
builder.tag! "system-err" do
|
101
|
+
builder.cdata! self.stderr
|
102
|
+
end
|
61
103
|
end
|
62
104
|
end
|
63
105
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../spec_helper.rb"
|
2
|
+
require 'rexml/document'
|
3
|
+
|
4
|
+
context "Output capture" do
|
5
|
+
setup do
|
6
|
+
@suite = CI::Reporter::TestSuite.new "test"
|
7
|
+
end
|
8
|
+
|
9
|
+
specify "should save stdout and stderr messages written during the test run" do
|
10
|
+
@suite.start
|
11
|
+
puts "Hello"
|
12
|
+
$stderr.print "Hi"
|
13
|
+
@suite.finish
|
14
|
+
@suite.stdout.should == "Hello\n"
|
15
|
+
@suite.stderr.should == "Hi"
|
16
|
+
end
|
17
|
+
|
18
|
+
specify "should include system-out and system-err elements in the xml output" do
|
19
|
+
@suite.start
|
20
|
+
puts "Hello"
|
21
|
+
$stderr.print "Hi"
|
22
|
+
@suite.finish
|
23
|
+
|
24
|
+
root = REXML::Document.new(@suite.to_xml).root
|
25
|
+
root.elements.to_a('//system-out').length.should == 1
|
26
|
+
root.elements.to_a('//system-err').length.should == 1
|
27
|
+
root.elements.to_a('//system-out').first.cdatas.first.to_s.should == "Hello\n"
|
28
|
+
root.elements.to_a('//system-err').first.cdatas.first.to_s.should == "Hi"
|
29
|
+
end
|
30
|
+
|
31
|
+
specify "should return $stdout and $stderr to original value after finish" do
|
32
|
+
out, err = $stdout, $stderr
|
33
|
+
@suite.start
|
34
|
+
$stdout.object_id.should_not == out.object_id
|
35
|
+
$stderr.object_id.should_not == err.object_id
|
36
|
+
@suite.finish
|
37
|
+
$stdout.object_id.should == out.object_id
|
38
|
+
$stderr.object_id.should == err.object_id
|
39
|
+
end
|
40
|
+
|
41
|
+
specify "should capture only during run of owner test suite" do
|
42
|
+
$stdout.print "A"
|
43
|
+
$stderr.print "A"
|
44
|
+
@suite.start
|
45
|
+
$stdout.print "B"
|
46
|
+
$stderr.print "B"
|
47
|
+
@suite.finish
|
48
|
+
$stdout.print "C"
|
49
|
+
$stderr.print "C"
|
50
|
+
@suite.stdout.should == "B"
|
51
|
+
@suite.stderr.should == "B"
|
52
|
+
end
|
53
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: ci_reporter
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "1.
|
7
|
-
date: 2007-03-
|
6
|
+
version: "1.2"
|
7
|
+
date: 2007-03-25 00:00:00 -05: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
|
@@ -43,12 +43,14 @@ files:
|
|
43
43
|
- lib/ci/reporter/rake/test_unit.rb
|
44
44
|
- lib/ci/reporter/rake/test_unit_loader.rb
|
45
45
|
- spec/spec_helper.rb
|
46
|
+
- spec/ci/reporter/output_capture_spec.rb
|
46
47
|
- spec/ci/reporter/report_manager_spec.rb
|
47
48
|
- spec/ci/reporter/rspec_spec.rb
|
48
49
|
- spec/ci/reporter/test_suite_spec.rb
|
49
50
|
- spec/ci/reporter/test_unit_spec.rb
|
50
51
|
- tasks/ci_reporter.rake
|
51
52
|
test_files:
|
53
|
+
- spec/ci/reporter/output_capture_spec.rb
|
52
54
|
- spec/ci/reporter/report_manager_spec.rb
|
53
55
|
- spec/ci/reporter/rspec_spec.rb
|
54
56
|
- spec/ci/reporter/test_suite_spec.rb
|