schubert-ci_reporter 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt ADDED
@@ -0,0 +1,110 @@
1
+ == 1.5.3
2
+
3
+ - Compatibility with latest RSpec (1.2.4); (Paul Boone)
4
+
5
+ == 1.5.2
6
+
7
+ - Compatibility with latest RSpec (1.1.11 or so); use example
8
+ description method if available
9
+ - Remove dependency on rubygems when requiring builder (rescue
10
+ LoadError) (Jari Bakken)
11
+ - Source repository moved to github/git.caldersphere.net
12
+
13
+ == 1.5.1
14
+
15
+ - Fix silly load-path error that some had been seeing
16
+
17
+ == 1.5
18
+
19
+ - Support for RSpec 1.1.1 example groups (which broke ci_reporter 1.4)
20
+ - Change internal model to delegation instead of inheritance, allowing
21
+ ci_reporter to wrap different output formatters
22
+ - Add 'ci:setup:rspecdoc' task to output specdoc format instead of
23
+ progress
24
+ - Add support for pending examples; they will be listed in the report
25
+ XML as successful, but the name will have a '(PENDING)' tag appended
26
+ - Support for RSpec < 0.9 removed as promised; use 1.4 if you still
27
+ need to use an older version of RSpec
28
+
29
+ == 1.4
30
+
31
+ - Test::Unit tests that fail in multiple places (setup, test method,
32
+ and teardown) are now tracked (marcog)
33
+ - Explicit dependency requirement on Builder (>= 2.1.2)
34
+ - Use of RSpec < 0.9 is now deprecated; support will probably
35
+ disappear in the next version
36
+
37
+ == 1.3.5
38
+
39
+ - Change way we append to environment variables to appease windows
40
+ (Tracker #13998, Adam Anderson)
41
+
42
+ == 1.3.4
43
+
44
+ - Call #to_s on the object passed in as the test suite name;
45
+ compatibility fix for RSpec trunk which passes a
46
+ Spec::DSL::Description instead of a string
47
+ - Fix broken spec due to pending feature introduced in recent RSpec
48
+ - Fix compatibility for JRuby
49
+ - Add stub.rake file as another way to wrap existing Rakefile, with
50
+ note in README
51
+
52
+ == 1.3.3
53
+
54
+ - Use SPEC_OPTS instead of RSPECOPTS (Aslak Hellesøy)
55
+ - Add assertions attribute to individual test cases (Tracker #11563,
56
+ Andy Sipe)
57
+
58
+ == 1.3.2
59
+
60
+ - Fix bug trying to modify frozen environment strings
61
+ - Upgrade all specs to RSpec 1.0 style
62
+ - Add specs for rake tasks
63
+
64
+ == 1.3.1
65
+
66
+ - Fixed to be compatible with RSpec 1.0.x (added fourth parameter to
67
+ Formatter#dump_summary)
68
+
69
+ == 1.3
70
+
71
+ - Fixed to be compatible with RSpec 0.9
72
+ - Failure location text now contains both the exception message and
73
+ class name (in case the type and message attributes were truncated)
74
+
75
+ == 1.2.4
76
+
77
+ - Allow to report on RSpec specs when working with non-gem RSpec
78
+ - Note: CI::Reporter is only compatible with RSpec up to 0.8.2
79
+
80
+ == 1.2.3
81
+
82
+ - Append to TESTOPTS and RSPECOPTS environment variables (Bret
83
+ Pettichord) so that other apps can put values in them as well
84
+
85
+ == 1.2.2
86
+
87
+ - Responds to environment variable CI_CAPTURE: if set to "off",
88
+ stdout/stderr capture will be disabled.
89
+
90
+ == 1.2.1
91
+
92
+ - Add license and copyright information (finally)
93
+
94
+ == 1.2
95
+
96
+ - Capture standard output and standard error during each individual
97
+ test suite and include in the XML file in system-out and system-err
98
+ elements, respectively
99
+ (Tracker#9054[http://rubyforge.org/tracker/index.php?func=detail&aid=9054&group_id=2857&atid=11007])
100
+
101
+ == 1.1
102
+
103
+ - Add +assertions+ attribute to the +testsuite+ element that will
104
+ contain per-suite assertion counts when used with Test::Unit. Not
105
+ useful with applications that read Ant/JUnit XML, but custom
106
+ applications may wish to access it.
107
+
108
+ == 1.0
109
+
110
+ - Initial Release.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ # (c) Copyright 2006-2007 Nick Sieger <nicksieger@gmail.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person
4
+ # obtaining a copy of this software and associated documentation files
5
+ # (the "Software"), to deal in the Software without restriction,
6
+ # including without limitation the rights to use, copy, modify, merge,
7
+ # publish, distribute, sublicense, and/or sell copies of the Software,
8
+ # and to permit persons to whom the Software is furnished to do so,
9
+ # subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18
+ # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19
+ # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,24 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ LICENSE.txt
5
+ Rakefile
6
+ stub.rake
7
+ lib/ci/reporter/core.rb
8
+ lib/ci/reporter/rake/rspec.rb
9
+ lib/ci/reporter/rake/rspec_loader.rb
10
+ lib/ci/reporter/rake/test_unit.rb
11
+ lib/ci/reporter/rake/test_unit_loader.rb
12
+ lib/ci/reporter/report_manager.rb
13
+ lib/ci/reporter/rspec.rb
14
+ lib/ci/reporter/test_suite.rb
15
+ lib/ci/reporter/test_unit.rb
16
+ lib/ci/reporter/version.rb
17
+ spec/ci/reporter/output_capture_spec.rb
18
+ spec/ci/reporter/rake/rake_tasks_spec.rb
19
+ spec/ci/reporter/report_manager_spec.rb
20
+ spec/ci/reporter/rspec_spec.rb
21
+ spec/ci/reporter/test_suite_spec.rb
22
+ spec/ci/reporter/test_unit_spec.rb
23
+ spec/spec_helper.rb
24
+ tasks/ci_reporter.rake
data/README.txt ADDED
@@ -0,0 +1,68 @@
1
+ (NOTE: This is a fork of the original, follow the link on github for the original)
2
+
3
+ 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.
4
+
5
+ == Dependencies
6
+
7
+ CI::Reporter has one required dependency on Builder, but since many will have a viable version of Builder via Rails' ActiveSupport gem, Builder is not a direct dependency of the project at the moment. Instead, ensure that you have either the +builder+ or +activesupport+ gem installed before continuing. CI::Reporter will raise an exception at runtime if it cannot locate Builder.
8
+
9
+ == Installation
10
+
11
+ CI::Reporter is available as a gem. To install the gem, use the usual gem command:
12
+
13
+ gem install ci_reporter
14
+
15
+ To use CI::Reporter as a Rails plugin, first install the gem, and then install the plugin as follows:
16
+
17
+ script/plugin install http://svn.caldersphere.net/svn/main/plugins/ci_reporter
18
+
19
+ == Usage
20
+
21
+ CI::Reporter works best with projects that use a +Rakefile+ along with the standard <code>Rake::TestTask</code> or <code>Spec::Rake::SpecTask</code> tasks for running tests or examples, respectively. In this fashion, it hooks into <code>Test::Unit</code> or +RSpec+ using environment variables recognized by these custom tasks to inject the CI::Reporter code into the test or spec runs. If you're using the Rails plugin, step 1 is unnecessary; skip to step 2.
22
+
23
+ 1. To use CI::Reporter, simply add the following lines to your Rakefile:
24
+
25
+ require 'rubygems'
26
+ gem 'ci_reporter'
27
+ require 'ci/reporter/rake/rspec' # use this if you're using RSpec
28
+ require 'ci/reporter/rake/test_unit' # use this if you're using Test::Unit
29
+
30
+ 2. Next, either modify your Rakefile to make the <code>ci:setup:rspec</code> or <code>ci:setup:testunit</code> task a dependency of your test tasks, or include them on the Rake command-line before the name of the task that runs the tests or specs.
31
+
32
+ rake ci:setup:testunit test
33
+
34
+ Report files are written, by default, to the <code>test/reports</code> or <code>spec/reports</code> subdirectory of your project. If you wish to customize the location, simply set the environment variable CI_REPORTS (either in the environment, on the Rake command line, or in your Rakefile) to the location where they should go.
35
+
36
+ == Advanced Usage
37
+
38
+ If you don't have control over the Rakefile or don't want to modify it, CI::Reporter has a substitute rake file that you can specify on the command-line. It assumes that the main project rake file is called +Rakefile+ and lives in the current directory. Run like so:
39
+
40
+ rake -f GEM_PATH/stub.rake ci:setup:testunit test
41
+ rake -f GEM_PATH/stub.rake ci:setup:rspec spec
42
+
43
+ If for some reason you can't use the above technique to inject CI::Reporter (e.g., you're not using Rake), you'll have to do one of these:
44
+
45
+ 1. If you're using <code>Test::Unit</code>, ensure the <code>ci/reporter/rake/test_unit_loader.rb</code> file is loaded or required at some point before the tests are run.
46
+ 2. If you're using +RSpec+, you'll need to pass the following arguments to the +spec+ command:
47
+ --require GEM_PATH/lib/ci/reporter/rake/rspec_loader
48
+ --format CI::Reporter::RSpec
49
+
50
+ There's a bit of a chicken and egg problem because rubygems needs to be loaded before you can require any CI::Reporter files. If you cringe hard-coding a full path to a specific version of the gem, you can also copy the +rspec_loader+ file into your project and require it directly -- the contents are version-agnostic and are not likely to change in future releases.
51
+
52
+ == Environment Variables
53
+
54
+ * +CI_REPORTS+: if set, points to a directory where report files will be written.
55
+ * +CI_CAPTURE+: if set to value "off", stdout/stderr capture will be disabled.
56
+
57
+ == Source
58
+
59
+ You can get the CI::Reporter source using Git, in any of the following ways:
60
+
61
+ git clone http://git.caldersphere.net/ci_reporter.git
62
+ git clone git://github.com/nicksieger/ci_reporter.git
63
+
64
+ You can also download a tarball of the latest CI::Reporter source at http://github.com/nicksieger/ci_reporter/tree/master.
65
+
66
+ == License
67
+
68
+ This software is released under an MIT license. For details, see the LICENSE.txt file included with the distribution. The software is copyright (c) 2006-2007 Nick Sieger <nicksieger@gmail.com>.
data/Rakefile ADDED
@@ -0,0 +1,76 @@
1
+ require 'spec/rake/spectask'
2
+ require 'spec/rake/verify_rcov'
3
+
4
+ MANIFEST = FileList["History.txt", "Manifest.txt", "README.txt", "LICENSE.txt", "Rakefile",
5
+ "*.rake", "lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake"]
6
+
7
+ begin
8
+ File.open("Manifest.txt", "w") {|f| MANIFEST.each {|n| f << "#{n}\n"} }
9
+ require 'hoe'
10
+ require File.dirname(__FILE__) + '/lib/ci/reporter/version'
11
+ hoe = Hoe.new("schubert-ci_reporter", CI::Reporter::VERSION) do |p|
12
+ p.url = "http://github.com/schubert/ci_reporter"
13
+ p.author = "Michael Schubert"
14
+ p.email = "michael@schubert.cx"
15
+ p.summary = "CI::Reporter allows you to generate reams of XML for use with continuous integration systems."
16
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
17
+ p.description = p.paragraphs_of('README.txt', 0...1).join("\n\n")
18
+ p.extra_deps.reject!{|d| d.first == "hoe"}
19
+ p.test_globs = ["spec/**/*_spec.rb"]
20
+ p.extra_deps << ['builder', ">= 2.1.2"]
21
+ end
22
+ hoe.spec.files = MANIFEST
23
+ hoe.spec.dependencies.delete_if { |dep| dep.name == "hoe" }
24
+ rescue LoadError
25
+ puts "You really need Hoe installed to be able to package this gem"
26
+ end
27
+
28
+ # Hoe insists on setting task :default => :test
29
+ # !@#$ no easy way to empty the default list of prerequisites
30
+ Rake::Task['default'].send :instance_variable_set, "@prerequisites", FileList[]
31
+
32
+ # No RCov on JRuby at the moment
33
+ if RUBY_PLATFORM =~ /java/
34
+ task :default => :spec
35
+ else
36
+ task :default => :rcov
37
+ end
38
+
39
+ Spec::Rake::SpecTask.new do |t|
40
+ t.spec_opts = ["--diff", "unified"]
41
+ end
42
+
43
+ Spec::Rake::SpecTask.new("spec:rcov") do |t|
44
+ t.rcov_opts << '--exclude gems/*'
45
+ t.rcov = true
46
+ end
47
+ # so we don't confuse autotest
48
+ RCov::VerifyTask.new(:rcov) do |t|
49
+ # Can't get threshold up to 100 unless RSpec backwards compatibility
50
+ # code is dropped
51
+ t.threshold = 98
52
+ t.require_exact_threshold = false
53
+ end
54
+ task "spec:rcov" do
55
+ rm_f "Manifest.txt"
56
+ end
57
+ task :rcov => "spec:rcov"
58
+
59
+ task :generate_output do
60
+ rm_f "acceptance/reports/*.xml"
61
+ ENV['CI_REPORTS'] = "acceptance/reports"
62
+ begin
63
+ `ruby -Ilib acceptance/test_unit_example_test.rb` rescue nil
64
+ `ruby -Ilib -S spec --require ci/reporter/rake/rspec_loader --format CI::Reporter::RSpec acceptance/rspec_example_spec.rb` rescue nil
65
+ ensure
66
+ ENV.delete 'CI_REPORTS'
67
+ end
68
+ end
69
+ task :acceptance => :generate_output
70
+
71
+ Spec::Rake::SpecTask.new(:acceptance_spec) do |t|
72
+ t.spec_files = FileList['acceptance/verification_spec.rb']
73
+ end
74
+ task :acceptance => :acceptance_spec
75
+
76
+ task :default => :acceptance
@@ -0,0 +1,6 @@
1
+ # (c) Copyright 2006-2007 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/test_suite'
6
+ require 'ci/reporter/report_manager'
@@ -0,0 +1,23 @@
1
+ # (c) Copyright 2006-2007 Nick Sieger <nicksieger@gmail.com>
2
+ # See the file LICENSE.txt included with the distribution for
3
+ # software license details.
4
+
5
+ namespace :ci do
6
+ namespace :setup do
7
+ task :spec_report_cleanup do
8
+ rm_rf ENV["CI_REPORTS"] || "spec/reports"
9
+ end
10
+
11
+ task :rspec => :spec_report_cleanup do
12
+ spec_opts = ["--require", "#{File.dirname(__FILE__)}/rspec_loader.rb",
13
+ "--format", "CI::Reporter::RSpec"].join(" ")
14
+ ENV["SPEC_OPTS"] = "#{ENV['SPEC_OPTS']} #{spec_opts}"
15
+ end
16
+
17
+ task :rspecdoc => :spec_report_cleanup do
18
+ spec_opts = ["--require", "#{File.dirname(__FILE__)}/rspec_loader.rb",
19
+ "--format", "CI::Reporter::RSpecDoc"].join(" ")
20
+ ENV["SPEC_OPTS"] = "#{ENV['SPEC_OPTS']} #{spec_opts}"
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,6 @@
1
+ # (c) Copyright 2006-2007 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/rspec'
@@ -0,0 +1,12 @@
1
+ # (c) Copyright 2006-2007 Nick Sieger <nicksieger@gmail.com>
2
+ # See the file LICENSE.txt included with the distribution for
3
+ # software license details.
4
+
5
+ namespace :ci do
6
+ namespace :setup do
7
+ task :testunit do
8
+ rm_rf ENV["CI_REPORTS"] || "test/reports"
9
+ ENV["TESTOPTS"] = "#{ENV["TESTOPTS"]} #{File.dirname(__FILE__)}/test_unit_loader.rb"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ # (c) Copyright 2006-2007 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
+ module Test #:nodoc:all
9
+ module Unit
10
+ module UI
11
+ module Console
12
+ class TestRunner
13
+ def create_mediator(suite)
14
+ # swap in our custom mediator
15
+ return CI::Reporter::TestUnit.new(suite)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ # (c) Copyright 2006-2007 Nick Sieger <nicksieger@gmail.com>
2
+ # See the file LICENSE.txt included with the distribution for
3
+ # software license details.
4
+
5
+ require 'fileutils'
6
+
7
+ module CI #:nodoc:
8
+ module Reporter #:nodoc:
9
+ class ReportManager
10
+ def initialize(prefix)
11
+ @basedir = ENV['CI_REPORTS'] || File.expand_path("#{Dir.getwd}/#{prefix.downcase}/reports")
12
+ @basename = "#{@basedir}/#{prefix.upcase}"
13
+ FileUtils.mkdir_p(@basedir)
14
+ end
15
+
16
+ def write_report(suite)
17
+ File.open("#{@basename}-#{suite.name.gsub(/[^a-zA-Z0-9]+/, '-')}.xml", "w") do |f|
18
+ f << suite.to_xml
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,143 @@
1
+ # (c) Copyright 2006-2009 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
+ tried_gem = false
7
+ begin
8
+ require 'spec'
9
+ require 'spec/runner/formatter/progress_bar_formatter'
10
+ require 'spec/runner/formatter/specdoc_formatter'
11
+ rescue LoadError
12
+ unless tried_gem
13
+ tried_gem = true
14
+ require 'rubygems'
15
+ gem 'rspec'
16
+ retry
17
+ end
18
+ end
19
+
20
+ module CI
21
+ module Reporter
22
+ # Wrapper around a <code>RSpec</code> error or failure to be used by the test suite to interpret results.
23
+ class RSpecFailure
24
+ def initialize(failure)
25
+ @failure = failure
26
+ end
27
+
28
+ def failure?
29
+ @failure.expectation_not_met?
30
+ end
31
+
32
+ def error?
33
+ !@failure.expectation_not_met?
34
+ end
35
+
36
+ def name() @failure.exception.class.name end
37
+ def message() @failure.exception.message end
38
+ def location() @failure.exception.backtrace.join("\n") end
39
+ end
40
+
41
+ # Custom +RSpec+ formatter used to hook into the spec runs and capture results.
42
+ class RSpec < Spec::Runner::Formatter::BaseFormatter
43
+ attr_accessor :report_manager
44
+ attr_accessor :formatter
45
+ def initialize(*args)
46
+ super
47
+ @formatter ||= Spec::Runner::Formatter::ProgressBarFormatter.new(*args)
48
+ @report_manager = ReportManager.new("spec")
49
+ @suite = nil
50
+ end
51
+
52
+ def start(spec_count)
53
+ @formatter.start(spec_count)
54
+ end
55
+
56
+ # rspec 0.9
57
+ def add_behaviour(name)
58
+ @formatter.add_behaviour(name)
59
+ new_suite(name)
60
+ end
61
+
62
+ # Compatibility with rspec < 1.2.4
63
+ def add_example_group(example_group)
64
+ @formatter.add_example_group(example_group)
65
+ new_suite(example_group.description)
66
+ end
67
+
68
+ # rspec >= 1.2.4
69
+ def example_group_started(example_group)
70
+ @formatter.example_group_started(example_group)
71
+ new_suite(example_group.description)
72
+ end
73
+
74
+ def example_started(name)
75
+ @formatter.example_started(name)
76
+ name = name.description if name.respond_to?(:description)
77
+ spec = TestCase.new name
78
+ @suite.testcases << spec
79
+ spec.start
80
+ end
81
+
82
+ def example_failed(name, counter, failure)
83
+ @formatter.example_failed(name, counter, failure)
84
+ spec = @suite.testcases.last
85
+ spec.finish
86
+ spec.failures << RSpecFailure.new(failure)
87
+ end
88
+
89
+ def example_passed(name)
90
+ @formatter.example_passed(name)
91
+ spec = @suite.testcases.last
92
+ spec.finish
93
+ end
94
+
95
+ def example_pending(*args)
96
+ @formatter.example_pending(*args)
97
+ spec = @suite.testcases.last
98
+ spec.finish
99
+ spec.name = "#{spec.name} (PENDING)"
100
+ end
101
+
102
+ def start_dump
103
+ @formatter.start_dump
104
+ end
105
+
106
+ def dump_failure(*args)
107
+ @formatter.dump_failure(*args)
108
+ end
109
+
110
+ def dump_summary(*args)
111
+ @formatter.dump_summary(*args)
112
+ write_report
113
+ end
114
+
115
+ def dump_pending
116
+ @formatter.dump_pending
117
+ end
118
+
119
+ def close
120
+ @formatter.close
121
+ end
122
+
123
+ private
124
+ def write_report
125
+ @suite.finish
126
+ @report_manager.write_report(@suite)
127
+ end
128
+
129
+ def new_suite(name)
130
+ write_report if @suite
131
+ @suite = TestSuite.new name
132
+ @suite.start
133
+ end
134
+ end
135
+
136
+ class RSpecDoc < RSpec
137
+ def initialize(*args)
138
+ @formatter = Spec::Runner::Formatter::SpecdocFormatter.new(*args)
139
+ super
140
+ end
141
+ end
142
+ end
143
+ end