ci_reporter_minitest 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 17d64dd80b9c39c5baaefe727fca515d3d0b658f
4
+ data.tar.gz: 70c430f164924643ea6de9534fbff1959bcb6020
5
+ SHA512:
6
+ metadata.gz: 43874ba8e95ea7d038e9fc6f4f17623471556dc5d4257914e5a0f99fb7dcab0075375d4cd5e7a004bbdbd24993bcd65b7ed18b87d8bb3aee1257f68b9de37160
7
+ data.tar.gz: fa3d51753788f67ec984f25e2dcab1b76a1a3056a7385fdc8cf73c6ec009a9964a6b434dc6bc943faf9fb7e51b6d9b52e9b3a3ca30f5097c479ac0fea7214503
data/.gitignore ADDED
@@ -0,0 +1,22 @@
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
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0
4
+ - 2.1
5
+ - jruby
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ci_reporter_minitest.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2006-2014 Nick Sieger <nicksieger@gmail.com>
2
+ Copyright (c) 2014 The CI Reporter authors
3
+
4
+ MIT License
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ "Software"), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # CI::Reporter::Minitest
2
+
3
+ Connects [Minitest][mt] to [CI::Reporter][ci], and then to your CI
4
+ system.
5
+
6
+ [mt]: https://github.com/seattlerb/minitest
7
+ [ci]: https://github.com/ci-reporter/ci_reporter
8
+
9
+ ## Supported versions
10
+
11
+ The latest release of Minitest 2.2 is supported.
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'ci_reporter_minitest'
19
+ ```
20
+
21
+ And then install it:
22
+
23
+ ```
24
+ $ bundle
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ Require the reporter in your Rakefile, and ensure that
30
+ `ci:setup:minitest` is a dependency of your RSpec task:
31
+
32
+ ```ruby
33
+ require 'ci/reporter/rake/minitest'
34
+
35
+ # ...
36
+ # Rake code that creates a task called `:minitest`
37
+ # ...
38
+
39
+ task :minitest => 'ci:setup:minitest'
40
+ ```
41
+
42
+ ### Advanced usage
43
+
44
+ Refer to the shared [documentation][ci] for details on setting up
45
+ CI::Reporter.
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it ( https://github.com/ci-reporter/ci_reporter_minitest/fork )
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Add a failing test.
52
+ 4. Commit your changes (`git commit -am 'Add some feature'`)
53
+ 5. Ensure tests pass.
54
+ 6. Push to the branch (`git push origin my-new-feature`)
55
+ 7. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ require "bundler/gem_tasks"
2
+ require 'ci/reporter/internal'
3
+ include CI::Reporter::Internal
4
+
5
+ namespace :generate do
6
+ task :clean do
7
+ rm_rf "acceptance/reports"
8
+ end
9
+
10
+ task :minitest do
11
+ run_ruby_acceptance "-rci/reporter/rake/minitest_loader acceptance/minitest_example_test.rb"
12
+ end
13
+
14
+ task :all => [:clean, :minitest]
15
+ end
16
+
17
+ task :acceptance => "generate:all"
18
+
19
+ require 'rspec/core/rake_task'
20
+ RSpec::Core::RakeTask.new(:acceptance_spec) do |t|
21
+ t.pattern = FileList['acceptance/verification_spec.rb']
22
+ t.rspec_opts = "--color"
23
+ end
24
+ task :acceptance => :acceptance_spec
25
+
26
+ task :default => :acceptance
@@ -0,0 +1 @@
1
+ reports/
@@ -0,0 +1,17 @@
1
+ require 'minitest/autorun'
2
+
3
+ class MiniTestExampleTestOne < MiniTest::Unit::TestCase
4
+ def test_one
5
+ puts "Some <![CDATA[on stdout]]>"
6
+ assert false
7
+ end
8
+ def teardown
9
+ raise "second failure"
10
+ end
11
+ end
12
+
13
+ class MiniTestExampleTestTwo < MiniTest::Unit::TestCase
14
+ def test_two
15
+ assert true
16
+ end
17
+ end
@@ -0,0 +1,38 @@
1
+ require 'rexml/document'
2
+
3
+ REPORTS_DIR = File.dirname(__FILE__) + '/reports'
4
+
5
+ describe "MiniTest::Unit acceptance" do
6
+ it "should generate two XML files" do
7
+ File.exist?(File.join(REPORTS_DIR, 'TEST-MiniTestExampleTestOne.xml')).should == true
8
+ File.exist?(File.join(REPORTS_DIR, 'TEST-MiniTestExampleTestTwo.xml')).should == true
9
+ end
10
+
11
+ it "should have one error and one failure for MiniTestExampleTestOne" do
12
+ doc = File.open(File.join(REPORTS_DIR, 'TEST-MiniTestExampleTestOne.xml')) do |f|
13
+ REXML::Document.new(f)
14
+ end
15
+ doc.root.attributes["errors"].should == "1"
16
+ doc.root.attributes["failures"].should == "1"
17
+ doc.root.attributes["assertions"].should == "1"
18
+ doc.root.attributes["tests"].should == "1"
19
+ doc.root.elements.to_a("/testsuite/testcase").size.should == 1
20
+ doc.root.elements.to_a("/testsuite/testcase/error").size.should == 1
21
+ doc.root.elements.to_a("/testsuite/testcase/failure").size.should == 1
22
+ doc.root.elements.to_a("/testsuite/system-out").first.texts.inject("") do |c,e|
23
+ c << e.value; c
24
+ end.strip.should == "Some <![CDATA[on stdout]]>"
25
+ end
26
+
27
+ it "should have no errors or failures for MiniTestExampleTestTwo" do
28
+ doc = File.open(File.join(REPORTS_DIR, 'TEST-MiniTestExampleTestTwo.xml')) do |f|
29
+ REXML::Document.new(f)
30
+ end
31
+ doc.root.attributes["errors"].should == "0"
32
+ doc.root.attributes["failures"].should == "0"
33
+ doc.root.attributes["assertions"].should == "1"
34
+ doc.root.attributes["tests"].should == "1"
35
+ doc.root.elements.to_a("/testsuite/testcase").size.should == 1
36
+ doc.root.elements.to_a("/testsuite/testcase/failure").size.should == 0
37
+ end
38
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ci/reporter/minitest/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ci_reporter_minitest"
8
+ spec.version = CI::Reporter::Minitest::VERSION
9
+ spec.authors = ["Nick Sieger", "Jake Goulding"]
10
+ spec.email = ["nick@nicksieger.com", "jake.goulding@gmail.com"]
11
+ spec.summary = %q{Connects CI::Reporter to Minitest}
12
+ spec.homepage = "https://github.com/ci-reporter/ci_reporter_minitest"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features|acceptance)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "minitest", "~> 2.2.0"
21
+ spec.add_dependency "ci_reporter", "2.0.0.alpha1"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec", "~> 2.0"
26
+ end
@@ -0,0 +1,219 @@
1
+ require 'ci/reporter/core'
2
+ require 'minitest/unit'
3
+
4
+ module CI
5
+ module Reporter
6
+ class Failure
7
+ def self.new(fault, type = nil, meth = nil)
8
+ return MiniTestSkipped.new(fault) if type == :skip
9
+ return MiniTestFailure.new(fault, meth) if type == :failure
10
+ MiniTestError.new(fault)
11
+ end
12
+ end
13
+
14
+ class FailureCore
15
+ def location(e)
16
+ last_before_assertion = ""
17
+ e.backtrace.reverse_each do |s|
18
+ break if s =~ /in .(assert|refute|flunk|pass|fail|raise|must|wont)/
19
+ last_before_assertion = s
20
+ end
21
+ last_before_assertion.sub(/:in .*$/, '')
22
+ end
23
+ end
24
+
25
+ class MiniTestSkipped < FailureCore
26
+ def initialize(fault) @fault = fault end
27
+ def failure?() false end
28
+ def error?() false end
29
+ def name() @fault.class.name end
30
+ def message() @fault.message end
31
+ def location() super @fault end
32
+ end
33
+
34
+ class MiniTestFailure < FailureCore
35
+ def initialize(fault, meth) @fault = fault; @meth = meth end
36
+ def failure?() true end
37
+ def error?() false end
38
+ def name() @meth end
39
+ def message() @fault.message end
40
+ def location() super @fault end
41
+ end
42
+
43
+ class MiniTestError < FailureCore
44
+ def initialize(fault) @fault = fault end
45
+ def failure?() false end
46
+ def error?() true end
47
+ def name() @fault.class.name end
48
+ def message() @fault.message end
49
+ def location() @fault.backtrace.join("\n") end
50
+ end
51
+
52
+ class Runner < MiniTest::Unit
53
+
54
+ @@out = $stdout
55
+
56
+ def initialize
57
+ super
58
+ @report_manager = ReportManager.new("test")
59
+ end
60
+
61
+ def _run_anything(type)
62
+ suites = MiniTest::Unit::TestCase.send "#{type}_suites"
63
+ return if suites.empty?
64
+
65
+ started_anything type
66
+
67
+ sync = output.respond_to? :"sync=" # stupid emacs
68
+ old_sync, output.sync = output.sync, true if sync
69
+
70
+ _run_suites(suites, type)
71
+
72
+ output.sync = old_sync if sync
73
+
74
+ finished_anything(type)
75
+ end
76
+
77
+ def _run_suites(suites, type)
78
+ suites.map { |suite| _run_suite suite, type }
79
+ end
80
+
81
+ def _run_suite(suite, type)
82
+ start_suite(suite)
83
+
84
+ header = "#{type}_suite_header"
85
+ puts send(header, suite) if respond_to? header
86
+
87
+ filter_suite_methods(suite, type).each do |method|
88
+ _run_test(suite, method)
89
+ end
90
+
91
+ finish_suite
92
+ end
93
+
94
+ def _run_test(suite, method)
95
+ start_case(method)
96
+
97
+ result = run_test(suite, method)
98
+
99
+ @assertion_count += result._assertions
100
+ @test_count += 1
101
+
102
+ finish_case
103
+ end
104
+
105
+ def puke(klass, meth, e)
106
+ e = case e
107
+ when MiniTest::Skip then
108
+ @skips += 1
109
+ fault(e, :skip)
110
+ return "S" unless @verbose
111
+ "Skipped:\n#{meth}(#{klass}) [#{location e}]:\n#{e.message}\n"
112
+ when MiniTest::Assertion then
113
+ @failures += 1
114
+ fault(e, :failure, meth)
115
+ "Failure:\n#{meth}(#{klass}) [#{location e}]:\n#{e.message}\n"
116
+ else
117
+ @errors += 1
118
+ fault(e, :error)
119
+ bt = MiniTest::filter_backtrace(e.backtrace).join "\n "
120
+ "Error:\n#{meth}(#{klass}):\n#{e.class}: #{e.message}\n #{bt}\n"
121
+ end
122
+ @report << e
123
+ e[0, 1]
124
+ end
125
+
126
+ private
127
+
128
+ def started_anything(type)
129
+ @test_count = 0
130
+ @assertion_count = 0
131
+ @last_assertion_count = 0
132
+ @result_assertion_count = 0
133
+ @start = Time.now
134
+
135
+ puts
136
+ puts "# Running #{type}s:"
137
+ puts
138
+ end
139
+
140
+ def finished_anything(type)
141
+ t = Time.now - @start
142
+ puts
143
+ puts
144
+ puts "Finished #{type}s in %.6fs, %.4f tests/s, %.4f assertions/s." %
145
+ [t, @test_count / t, @assertion_count / t]
146
+
147
+ report.each_with_index do |msg, i|
148
+ puts "\n%3d) %s" % [i + 1, msg]
149
+ end
150
+
151
+ puts
152
+
153
+ status
154
+ end
155
+
156
+ def filter_suite_methods(suite, type)
157
+ filter = options[:filter] || '/./'
158
+ filter = Regexp.new $1 if filter =~ /\/(.*)\//
159
+
160
+ suite.send("#{type}_methods").grep(filter)
161
+ end
162
+
163
+ def run_test(suite, method)
164
+ inst = suite.new method
165
+ inst._assertions = 0
166
+
167
+ print "#{suite}##{method} = " if @verbose
168
+
169
+ @start_time = Time.now
170
+ result = inst.run self
171
+ time = Time.now - @start_time
172
+
173
+ print "%.2f s = " % time if @verbose
174
+ print result
175
+ puts if @verbose
176
+
177
+ return inst
178
+ end
179
+
180
+ def start_suite(suite_name)
181
+ @current_suite = CI::Reporter::TestSuite.new(suite_name)
182
+ @current_suite.start
183
+ end
184
+
185
+ def finish_suite
186
+ if @current_suite
187
+ @current_suite.finish
188
+ @current_suite.assertions = @assertion_count - @last_assertion_count
189
+ @last_assertion_count = @assertion_count
190
+ @report_manager.write_report(@current_suite)
191
+ end
192
+ end
193
+
194
+ def start_case(test_name)
195
+ tc = CI::Reporter::TestCase.new(test_name)
196
+ tc.start
197
+ @current_suite.testcases << tc
198
+ end
199
+
200
+ def finish_case
201
+ tc = @current_suite.testcases.last
202
+ tc.finish
203
+ tc.assertions = @assertion_count - @result_assertion_count
204
+ @result_assertion_count = @assertion_count
205
+ end
206
+
207
+ def fault(fault, type = nil, meth = nil)
208
+ tc = @current_suite.testcases.last
209
+ if :skip == type
210
+ tc.skipped = true
211
+ else
212
+ tc.failures << Failure.new(fault, type, meth)
213
+ end
214
+ end
215
+
216
+ end
217
+
218
+ end
219
+ end
@@ -0,0 +1,7 @@
1
+ module CI
2
+ module Reporter
3
+ class Minitest
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ require 'ci/reporter/rake/utils'
2
+
3
+ namespace :ci do
4
+ namespace :setup do
5
+ task :minitest do
6
+ rm_rf ENV["CI_REPORTS"] || "test/reports"
7
+ test_loader = CI::Reporter.maybe_quote_filename "#{File.dirname(__FILE__)}/minitest_loader.rb"
8
+ ENV["TESTOPTS"] = "#{ENV["TESTOPTS"]} #{test_loader}"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ $: << File.dirname(__FILE__) + "/../../.."
2
+ require 'ci/reporter/minitest'
3
+
4
+ # set defaults
5
+ MiniTest::Unit.runner = CI::Reporter::Runner.new
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ci_reporter_minitest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nick Sieger
8
+ - Jake Goulding
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-06-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: minitest
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 2.2.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 2.2.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: ci_reporter
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '='
33
+ - !ruby/object:Gem::Version
34
+ version: 2.0.0.alpha1
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '='
40
+ - !ruby/object:Gem::Version
41
+ version: 2.0.0.alpha1
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.6'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.6'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '2.0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '2.0'
84
+ description:
85
+ email:
86
+ - nick@nicksieger.com
87
+ - jake.goulding@gmail.com
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - ".travis.yml"
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - acceptance/.gitignore
99
+ - acceptance/minitest_example_test.rb
100
+ - acceptance/verification_spec.rb
101
+ - ci_reporter_minitest.gemspec
102
+ - lib/ci/reporter/minitest.rb
103
+ - lib/ci/reporter/minitest/version.rb
104
+ - lib/ci/reporter/rake/minitest.rb
105
+ - lib/ci/reporter/rake/minitest_loader.rb
106
+ homepage: https://github.com/ci-reporter/ci_reporter_minitest
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.2.2
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Connects CI::Reporter to Minitest
130
+ test_files:
131
+ - acceptance/.gitignore
132
+ - acceptance/minitest_example_test.rb
133
+ - acceptance/verification_spec.rb