minitest-ci 1.0.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/.autotest +26 -0
- data/.gemtest +0 -0
- data/.gitignore +3 -0
- data/History.txt +6 -0
- data/Manifest.txt +8 -0
- data/README.txt +58 -0
- data/Rakefile +18 -0
- data/lib/minitest/ci.rb +146 -0
- data/test/test_minitest_ci.rb +98 -0
- metadata +143 -0
data/.autotest
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# -*- ruby -*-
|
|
2
|
+
|
|
3
|
+
require 'autotest/restart'
|
|
4
|
+
|
|
5
|
+
Autotest.add_hook :initialize do |at|
|
|
6
|
+
at.add_exception 'test/reports'
|
|
7
|
+
# at.extra_files << "../some/external/dependency.rb"
|
|
8
|
+
#
|
|
9
|
+
# at.libs << ":../some/external"
|
|
10
|
+
#
|
|
11
|
+
# at.add_exception 'vendor'
|
|
12
|
+
#
|
|
13
|
+
# at.add_mapping(/dependency.rb/) do |f, _|
|
|
14
|
+
# at.files_matching(/test_.*rb$/)
|
|
15
|
+
# end
|
|
16
|
+
#
|
|
17
|
+
# %w(TestA TestB).each do |klass|
|
|
18
|
+
# at.extra_class_map[klass] = "test/test_misc.rb"
|
|
19
|
+
# end
|
|
20
|
+
false
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Autotest.add_hook :run_command do |at|
|
|
24
|
+
# system "rake build"
|
|
25
|
+
# end
|
|
26
|
+
# vim: syntax=ruby
|
data/.gemtest
ADDED
|
File without changes
|
data/.gitignore
ADDED
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
= minitest-ci
|
|
2
|
+
|
|
3
|
+
* https://github.com/bhenderson/minitest-ci
|
|
4
|
+
|
|
5
|
+
== DESCRIPTION:
|
|
6
|
+
|
|
7
|
+
CI reporter plugin for MiniTest
|
|
8
|
+
This gem was made possible by ATT Interactive.
|
|
9
|
+
|
|
10
|
+
== FEATURES/PROBLEMS:
|
|
11
|
+
|
|
12
|
+
* Monkeypatches MiniTest::Unit#_run_suite so I have to fix the version of MiniTest I support.
|
|
13
|
+
|
|
14
|
+
== SYNOPSIS:
|
|
15
|
+
|
|
16
|
+
require 'minitest/ci'
|
|
17
|
+
|
|
18
|
+
== REQUIREMENTS:
|
|
19
|
+
|
|
20
|
+
* See Rakefile
|
|
21
|
+
|
|
22
|
+
== INSTALL:
|
|
23
|
+
|
|
24
|
+
* gem install minitest-ci
|
|
25
|
+
|
|
26
|
+
== DEVELOPERS:
|
|
27
|
+
|
|
28
|
+
After checking out the source, run:
|
|
29
|
+
|
|
30
|
+
$ rake newb
|
|
31
|
+
|
|
32
|
+
This task will install any missing dependencies, run the tests/specs,
|
|
33
|
+
and generate the RDoc.
|
|
34
|
+
|
|
35
|
+
== LICENSE:
|
|
36
|
+
|
|
37
|
+
(The MIT License)
|
|
38
|
+
|
|
39
|
+
Copyright (c) 2011 bhenderson
|
|
40
|
+
|
|
41
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
42
|
+
a copy of this software and associated documentation files (the
|
|
43
|
+
'Software'), to deal in the Software without restriction, including
|
|
44
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
45
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
46
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
47
|
+
the following conditions:
|
|
48
|
+
|
|
49
|
+
The above copyright notice and this permission notice shall be
|
|
50
|
+
included in all copies or substantial portions of the Software.
|
|
51
|
+
|
|
52
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
53
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
54
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
55
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
56
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
57
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
58
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# -*- ruby -*-
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'hoe'
|
|
5
|
+
|
|
6
|
+
Hoe.plugin :isolate
|
|
7
|
+
|
|
8
|
+
Hoe.spec 'minitest-ci' do
|
|
9
|
+
developer 'Brian Henderson', 'bhenderson@attinteractive.com'
|
|
10
|
+
|
|
11
|
+
self.testlib = :none
|
|
12
|
+
|
|
13
|
+
extra_deps << ['minitest', '2.6.0']
|
|
14
|
+
extra_dev_deps << ['nokogiri', '~> 1.5.0']
|
|
15
|
+
extra_dev_deps << ['rdoc', '>= 2.4.2']
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# vim: syntax=ruby
|
data/lib/minitest/ci.rb
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
gem 'minitest', '2.6.0'
|
|
2
|
+
require "minitest/unit"
|
|
3
|
+
abort 'minitest version 2.6.0 required' unless MiniTest::Unit::VERSION == '2.6.0'
|
|
4
|
+
|
|
5
|
+
require 'fileutils'
|
|
6
|
+
require 'cgi'
|
|
7
|
+
|
|
8
|
+
module MiniTest
|
|
9
|
+
module Ci
|
|
10
|
+
VERSION = '1.0.1'
|
|
11
|
+
|
|
12
|
+
@test_dir = nil #'test/reports'
|
|
13
|
+
@error = nil
|
|
14
|
+
@munit = nil
|
|
15
|
+
@suites = Hash.new {|h,k| h[k] = []}
|
|
16
|
+
|
|
17
|
+
class << self
|
|
18
|
+
attr_accessor :test_dir
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def add_error e
|
|
22
|
+
@error = e
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def push suite, method, time, num
|
|
26
|
+
a = [method, time, num]
|
|
27
|
+
if @error
|
|
28
|
+
a << @error
|
|
29
|
+
@error = nil
|
|
30
|
+
end
|
|
31
|
+
@suites[suite] << a
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def finish
|
|
35
|
+
@munit.puts
|
|
36
|
+
@munit.puts 'generating ci files'
|
|
37
|
+
|
|
38
|
+
clean
|
|
39
|
+
|
|
40
|
+
Dir.chdir @test_dir do
|
|
41
|
+
@suites.each do |name, suite|
|
|
42
|
+
generate_suite name, suite
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def munit= m
|
|
48
|
+
@munit = m
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
|
|
53
|
+
def clean
|
|
54
|
+
FileUtils.rm_rf @test_dir
|
|
55
|
+
FileUtils.mkdir_p @test_dir
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def generate_suite name, suite
|
|
59
|
+
total_time, assertions, errors, failures, skips = 0, 0, 0, 0, 0
|
|
60
|
+
suite.each do |_, t, a, e|
|
|
61
|
+
total_time += t
|
|
62
|
+
assertions += a
|
|
63
|
+
case e
|
|
64
|
+
when MiniTest::Skip
|
|
65
|
+
skips += 1
|
|
66
|
+
when MiniTest::Assertion
|
|
67
|
+
failures += 1
|
|
68
|
+
else
|
|
69
|
+
errors += 1
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
File.open "TEST-#{name}.xml", "w" do |f|
|
|
74
|
+
f.puts '<?xml version="1.0" encoding="UTF-8"?>'
|
|
75
|
+
f.puts "<testsuite time='#{"%6f" % total_time}' skipped='#{skips}' failures='#{failures}' errors='#{errors}' name='#{name}' assertions='#{assertions}' tests='#{suite.count}'>"
|
|
76
|
+
|
|
77
|
+
suite.each do |method, time, asserts, error|
|
|
78
|
+
f.puts " <testcase time='#{"%6f" % time}' name='#{method}' assertions='#{asserts}'>"
|
|
79
|
+
if error
|
|
80
|
+
bt = MiniTest::filter_backtrace(error.backtrace).join "\n"
|
|
81
|
+
f.write " <failure type='#{error.class}' message='#{CGI.escapeHTML(error.message)}'>"
|
|
82
|
+
f.puts CGI.escapeHTML(bt)
|
|
83
|
+
f.puts " </failure>"
|
|
84
|
+
end
|
|
85
|
+
f.puts " </testcase>"
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
f.puts "</testsuite>"
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
extend self
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
class CiUnit < Unit
|
|
96
|
+
|
|
97
|
+
# copied out of MiniTest::Unit
|
|
98
|
+
def _run_suite suite, type
|
|
99
|
+
# added this line
|
|
100
|
+
MiniTest::Ci.munit = self
|
|
101
|
+
|
|
102
|
+
header = "#{type}_suite_header"
|
|
103
|
+
puts send(header, suite) if respond_to? header
|
|
104
|
+
|
|
105
|
+
filter = options[:filter] || '/./'
|
|
106
|
+
filter = Regexp.new $1 if filter =~ /\/(.*)\//
|
|
107
|
+
|
|
108
|
+
assertions = suite.send("#{type}_methods").grep(filter).map { |method|
|
|
109
|
+
inst = suite.new method
|
|
110
|
+
inst._assertions = 0
|
|
111
|
+
|
|
112
|
+
print "#{suite}##{method} = " if @verbose
|
|
113
|
+
|
|
114
|
+
@start_time = Time.now
|
|
115
|
+
result = inst.run self
|
|
116
|
+
time = Time.now - @start_time
|
|
117
|
+
|
|
118
|
+
print "%.2f s = " % time if @verbose
|
|
119
|
+
print result
|
|
120
|
+
puts if @verbose
|
|
121
|
+
|
|
122
|
+
# added this line
|
|
123
|
+
MiniTest::Ci.push suite, method, time, inst._assertions
|
|
124
|
+
|
|
125
|
+
inst._assertions
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return assertions.size, assertions.inject(0) { |sum, n| sum + n }
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def puke klass, meth, e
|
|
132
|
+
MiniTest::Ci.add_error e
|
|
133
|
+
super
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def status io = self.output
|
|
137
|
+
super
|
|
138
|
+
MiniTest::Ci.finish
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# set defaults
|
|
145
|
+
MiniTest::Ci.test_dir = 'test/reports'
|
|
146
|
+
MiniTest::Unit.runner = MiniTest::CiUnit.new
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
require "minitest/ci"
|
|
2
|
+
require "minitest/autorun"
|
|
3
|
+
require 'stringio'
|
|
4
|
+
require 'nokogiri'
|
|
5
|
+
|
|
6
|
+
class MockTestSuite < MiniTest::Unit::TestCase
|
|
7
|
+
def test_raise_error
|
|
8
|
+
raise 'raise an error'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_fail_assertion
|
|
12
|
+
flunk 'fail assertion'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_skip_assertion
|
|
16
|
+
skip 'skip assertion'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_pass
|
|
20
|
+
pass
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_cgi_message
|
|
24
|
+
raise Object.new.inspect
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class TestMinitest
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
class TestMinitest::TestCi < MiniTest::Unit::TestCase
|
|
32
|
+
@output = StringIO.new
|
|
33
|
+
old_out, MiniTest::Unit.output = MiniTest::Unit.output, @output
|
|
34
|
+
begin
|
|
35
|
+
runner = MiniTest::CiUnit.new
|
|
36
|
+
MiniTest::Ci.munit = runner
|
|
37
|
+
|
|
38
|
+
runner._run_suite MockTestSuite, :test
|
|
39
|
+
|
|
40
|
+
@@test_suites.delete MockTestSuite
|
|
41
|
+
MiniTest::Ci.finish
|
|
42
|
+
ensure
|
|
43
|
+
MiniTest::Unit.output = old_out
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.output
|
|
47
|
+
@output
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def setup
|
|
51
|
+
file = "#{MiniTest::Ci.test_dir}/TEST-MockTestSuite.xml"
|
|
52
|
+
assert File.exists?( file ), 'expected xml file to exists'
|
|
53
|
+
@doc = Nokogiri.parse File.read file
|
|
54
|
+
@doc = @doc.at_xpath('/testsuite')
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_testsuite
|
|
58
|
+
assert_equal "1", @doc['skipped']
|
|
59
|
+
assert_equal "1", @doc['failures']
|
|
60
|
+
assert_equal "3", @doc['errors']
|
|
61
|
+
assert_equal "2", @doc['assertions']
|
|
62
|
+
assert_equal "5", @doc['tests']
|
|
63
|
+
assert_equal "MockTestSuite", @doc['name']
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_testcase
|
|
67
|
+
assert_equal 5, @doc.children.count {|c| Nokogiri::XML::Element === c}
|
|
68
|
+
@doc.children.each do |c|
|
|
69
|
+
next unless Nokogiri::XML::Element === c
|
|
70
|
+
assert_equal 'testcase', c.name
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
passed = @doc.at_xpath('/testsuite/testcase[@name="test_pass"]')
|
|
74
|
+
assert_equal 0, passed.children.count {|c| Nokogiri::XML::Element === c}
|
|
75
|
+
assert_equal '1', passed['assertions']
|
|
76
|
+
|
|
77
|
+
skipped = @doc.at_xpath('/testsuite/testcase[@name="test_skip_assertion"]')
|
|
78
|
+
assert_equal 'skip assertion', skipped.at_xpath('failure')['message']
|
|
79
|
+
assert_equal '0', skipped['assertions']
|
|
80
|
+
|
|
81
|
+
failure = @doc.at_xpath('/testsuite/testcase[@name="test_fail_assertion"]')
|
|
82
|
+
assert_equal 'fail assertion', failure.at_xpath('failure')['message']
|
|
83
|
+
assert_equal '1', failure['assertions']
|
|
84
|
+
|
|
85
|
+
error = @doc.at_xpath('/testsuite/testcase[@name="test_raise_error"]')
|
|
86
|
+
assert_equal 'raise an error', error.at_xpath('failure')['message']
|
|
87
|
+
assert_equal '0', error['assertions']
|
|
88
|
+
|
|
89
|
+
error = @doc.at_xpath('/testsuite/testcase[@name="test_cgi_message"]')
|
|
90
|
+
assert_match( /^#<Object/, error.at_xpath('failure')['message'] )
|
|
91
|
+
assert_equal '0', error['assertions']
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def test_output
|
|
95
|
+
self.class.output.rewind
|
|
96
|
+
assert_match( /generating ci files/, self.class.output.read )
|
|
97
|
+
end
|
|
98
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: minitest-ci
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 21
|
|
5
|
+
prerelease:
|
|
6
|
+
segments:
|
|
7
|
+
- 1
|
|
8
|
+
- 0
|
|
9
|
+
- 1
|
|
10
|
+
version: 1.0.1
|
|
11
|
+
platform: ruby
|
|
12
|
+
authors:
|
|
13
|
+
- Brian Henderson
|
|
14
|
+
autorequire:
|
|
15
|
+
bindir: bin
|
|
16
|
+
cert_chain: []
|
|
17
|
+
|
|
18
|
+
date: 2011-09-26 00:00:00 -07:00
|
|
19
|
+
default_executable:
|
|
20
|
+
dependencies:
|
|
21
|
+
- !ruby/object:Gem::Dependency
|
|
22
|
+
name: minitest
|
|
23
|
+
prerelease: false
|
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - "="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
hash: 23
|
|
30
|
+
segments:
|
|
31
|
+
- 2
|
|
32
|
+
- 6
|
|
33
|
+
- 0
|
|
34
|
+
version: 2.6.0
|
|
35
|
+
type: :runtime
|
|
36
|
+
version_requirements: *id001
|
|
37
|
+
- !ruby/object:Gem::Dependency
|
|
38
|
+
name: nokogiri
|
|
39
|
+
prerelease: false
|
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ~>
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
hash: 3
|
|
46
|
+
segments:
|
|
47
|
+
- 1
|
|
48
|
+
- 5
|
|
49
|
+
- 0
|
|
50
|
+
version: 1.5.0
|
|
51
|
+
type: :development
|
|
52
|
+
version_requirements: *id002
|
|
53
|
+
- !ruby/object:Gem::Dependency
|
|
54
|
+
name: rdoc
|
|
55
|
+
prerelease: false
|
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
hash: 27
|
|
62
|
+
segments:
|
|
63
|
+
- 2
|
|
64
|
+
- 4
|
|
65
|
+
- 2
|
|
66
|
+
version: 2.4.2
|
|
67
|
+
type: :development
|
|
68
|
+
version_requirements: *id003
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: hoe
|
|
71
|
+
prerelease: false
|
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
73
|
+
none: false
|
|
74
|
+
requirements:
|
|
75
|
+
- - ~>
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
hash: 27
|
|
78
|
+
segments:
|
|
79
|
+
- 2
|
|
80
|
+
- 12
|
|
81
|
+
version: "2.12"
|
|
82
|
+
type: :development
|
|
83
|
+
version_requirements: *id004
|
|
84
|
+
description: |-
|
|
85
|
+
CI reporter plugin for MiniTest
|
|
86
|
+
This gem was made possible by ATT Interactive.
|
|
87
|
+
email:
|
|
88
|
+
- bhenderson@attinteractive.com
|
|
89
|
+
executables: []
|
|
90
|
+
|
|
91
|
+
extensions: []
|
|
92
|
+
|
|
93
|
+
extra_rdoc_files:
|
|
94
|
+
- History.txt
|
|
95
|
+
- Manifest.txt
|
|
96
|
+
- README.txt
|
|
97
|
+
files:
|
|
98
|
+
- .autotest
|
|
99
|
+
- .gitignore
|
|
100
|
+
- History.txt
|
|
101
|
+
- Manifest.txt
|
|
102
|
+
- README.txt
|
|
103
|
+
- Rakefile
|
|
104
|
+
- lib/minitest/ci.rb
|
|
105
|
+
- test/test_minitest_ci.rb
|
|
106
|
+
- .gemtest
|
|
107
|
+
has_rdoc: true
|
|
108
|
+
homepage: https://github.com/bhenderson/minitest-ci
|
|
109
|
+
licenses: []
|
|
110
|
+
|
|
111
|
+
post_install_message:
|
|
112
|
+
rdoc_options:
|
|
113
|
+
- --main
|
|
114
|
+
- README.txt
|
|
115
|
+
require_paths:
|
|
116
|
+
- lib
|
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
|
+
none: false
|
|
119
|
+
requirements:
|
|
120
|
+
- - ">="
|
|
121
|
+
- !ruby/object:Gem::Version
|
|
122
|
+
hash: 3
|
|
123
|
+
segments:
|
|
124
|
+
- 0
|
|
125
|
+
version: "0"
|
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
|
+
none: false
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
hash: 3
|
|
132
|
+
segments:
|
|
133
|
+
- 0
|
|
134
|
+
version: "0"
|
|
135
|
+
requirements: []
|
|
136
|
+
|
|
137
|
+
rubyforge_project: minitest-ci
|
|
138
|
+
rubygems_version: 1.6.2
|
|
139
|
+
signing_key:
|
|
140
|
+
specification_version: 3
|
|
141
|
+
summary: CI reporter plugin for MiniTest This gem was made possible by ATT Interactive.
|
|
142
|
+
test_files:
|
|
143
|
+
- test/test_minitest_ci.rb
|