minitest-ci 1.0.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +1 -16
- data/History.txt +5 -0
- data/Manifest.txt +0 -1
- data/README.txt +2 -1
- data/Rakefile +2 -1
- data/lib/minitest/ci.rb +27 -109
- data/test/test_minitest_ci.rb +6 -11
- metadata +42 -13
- data/.gitignore +0 -3
data/.autotest
CHANGED
@@ -1,26 +1,11 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
|
3
3
|
require 'autotest/restart'
|
4
|
+
require 'autotest/isolate'
|
4
5
|
|
5
6
|
Autotest.add_hook :initialize do |at|
|
6
7
|
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
8
|
false
|
21
9
|
end
|
22
10
|
|
23
|
-
# Autotest.add_hook :run_command do |at|
|
24
|
-
# system "rake build"
|
25
|
-
# end
|
26
11
|
# vim: syntax=ruby
|
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -5,11 +5,12 @@
|
|
5
5
|
== DESCRIPTION:
|
6
6
|
|
7
7
|
CI reporter plugin for MiniTest
|
8
|
+
|
8
9
|
This gem was made possible by ATT Interactive.
|
9
10
|
|
10
11
|
== FEATURES/PROBLEMS:
|
11
12
|
|
12
|
-
*
|
13
|
+
* Uses MiniTest::Unit#record which is only available since version 2.12.0
|
13
14
|
|
14
15
|
== SYNOPSIS:
|
15
16
|
|
data/Rakefile
CHANGED
@@ -4,13 +4,14 @@ require 'rubygems'
|
|
4
4
|
require 'hoe'
|
5
5
|
|
6
6
|
Hoe.plugin :isolate
|
7
|
+
Hoe.plugin :git
|
7
8
|
|
8
9
|
Hoe.spec 'minitest-ci' do
|
9
10
|
developer 'Brian Henderson', 'bhenderson@attinteractive.com'
|
10
11
|
|
11
12
|
self.testlib = :none
|
12
13
|
|
13
|
-
extra_deps << ['minitest', '2.
|
14
|
+
extra_deps << ['minitest', '~> 2.12.0']
|
14
15
|
extra_dev_deps << ['nokogiri', '~> 1.5.0']
|
15
16
|
extra_dev_deps << ['rdoc', '>= 2.4.2']
|
16
17
|
end
|
data/lib/minitest/ci.rb
CHANGED
@@ -1,12 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
msg = [
|
6
|
-
'minitest version 2.6.0 required',
|
7
|
-
'try: gem install minitest -v 2.6.0'
|
8
|
-
]
|
9
|
-
raise e.exception msg.join("\n")
|
1
|
+
require 'minitest/unit'
|
2
|
+
#unless MiniTest::Unit::VERSION >= '2.12.0'
|
3
|
+
unless MiniTest::Unit.public_method_defined? :record
|
4
|
+
abort 'you are running an unsupported version of MiniTest. try upgrading.'
|
10
5
|
end
|
11
6
|
|
12
7
|
require 'fileutils'
|
@@ -14,92 +9,49 @@ require 'cgi'
|
|
14
9
|
|
15
10
|
module MiniTest
|
16
11
|
module Ci
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
elsif __FILE__ =~ /^[^\.]/ then # assume both relative
|
22
|
-
require 'pathname'
|
23
|
-
pwd = Pathname.new Dir.pwd
|
24
|
-
pn = Pathname.new File.expand_path(__FILE__)
|
25
|
-
pn = File.join(".", pn.relative_path_from(pwd)) unless pn.relative?
|
26
|
-
pn.to_s
|
27
|
-
else # assume both are expanded
|
28
|
-
__FILE__
|
29
|
-
end
|
30
|
-
# end of copy
|
31
|
-
###
|
32
|
-
CI_MINI_DIR = File.dirname(File.dirname(file))
|
33
|
-
|
34
|
-
VERSION = '1.0.4'
|
35
|
-
|
36
|
-
@test_dir = nil #'test/reports'
|
37
|
-
@error = nil
|
38
|
-
@munit = nil
|
12
|
+
|
13
|
+
VERSION = '2.0.0'
|
14
|
+
|
15
|
+
@report_dir = nil
|
39
16
|
@suites = Hash.new {|h,k| h[k] = []}
|
40
17
|
|
41
18
|
class << self
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
def add_error e
|
46
|
-
@error = e
|
19
|
+
# Accessor method to change the report dir if you don't like the
|
20
|
+
# defaults.
|
21
|
+
attr_accessor :report_dir
|
47
22
|
end
|
48
23
|
|
49
|
-
def push suite, method, time,
|
50
|
-
|
51
|
-
if @error
|
52
|
-
a << @error
|
53
|
-
@error = nil
|
54
|
-
end
|
55
|
-
@suites[suite] << a
|
24
|
+
def push suite, method, num_assertions, time, error
|
25
|
+
@suites[suite] << [method, num_assertions, time, error]
|
56
26
|
end
|
57
27
|
|
58
|
-
def finish
|
59
|
-
|
60
|
-
|
28
|
+
def finish io
|
29
|
+
io.puts
|
30
|
+
io.puts 'generating ci files'
|
61
31
|
|
62
32
|
clean
|
63
33
|
|
64
|
-
Dir.chdir
|
34
|
+
Dir.chdir report_dir do
|
65
35
|
@suites.each do |name, suite|
|
66
36
|
generate_suite name, suite
|
67
37
|
end
|
68
38
|
end
|
69
39
|
end
|
70
40
|
|
71
|
-
def munit= m
|
72
|
-
@munit = m
|
73
|
-
end
|
74
|
-
|
75
41
|
private
|
76
42
|
|
77
43
|
def clean
|
78
|
-
FileUtils.rm_rf
|
79
|
-
FileUtils.mkdir_p
|
44
|
+
FileUtils.rm_rf report_dir
|
45
|
+
FileUtils.mkdir_p report_dir
|
80
46
|
end
|
81
47
|
|
82
48
|
def escape o
|
83
49
|
CGI.escapeHTML(o.to_s)
|
84
50
|
end
|
85
51
|
|
86
|
-
# use original as well as filtering this file.
|
87
|
-
def filter_backtrace bt
|
88
|
-
bt = MiniTest::filter_backtrace bt
|
89
|
-
orig_mini_dir = MiniTest::MINI_DIR
|
90
|
-
|
91
|
-
orig_verbose, $VERBOSE = $VERBOSE, nil
|
92
|
-
|
93
|
-
MiniTest.const_set :MINI_DIR, CI_MINI_DIR
|
94
|
-
MiniTest::filter_backtrace bt
|
95
|
-
ensure
|
96
|
-
MiniTest.const_set :MINI_DIR, orig_mini_dir
|
97
|
-
$VERBOSE = orig_verbose
|
98
|
-
end
|
99
|
-
|
100
52
|
def generate_suite name, suite
|
101
53
|
total_time, assertions, errors, failures, skips = 0, 0, 0, 0, 0
|
102
|
-
suite.each do |_,
|
54
|
+
suite.each do |_, a, t, e|
|
103
55
|
total_time += t
|
104
56
|
assertions += a
|
105
57
|
case e
|
@@ -116,12 +68,12 @@ module MiniTest
|
|
116
68
|
f.puts '<?xml version="1.0" encoding="UTF-8"?>'
|
117
69
|
f.puts "<testsuite time='#{"%6f" % total_time}' skipped='#{skips}' failures='#{failures}' errors='#{errors}' name='#{name}' assertions='#{assertions}' tests='#{suite.count}'>"
|
118
70
|
|
119
|
-
suite.each do |method,
|
71
|
+
suite.each do |method, asserts, time, error|
|
120
72
|
f.puts " <testcase time='#{"%6f" % time}' name='#{method}' assertions='#{asserts}'>"
|
121
73
|
if error
|
122
|
-
bt = filter_backtrace
|
74
|
+
bt = MiniTest::filter_backtrace error.backtrace
|
123
75
|
f.write " <#{type error} type='#{escape error.class}' message=#{escape( error.message ).inspect}>"
|
124
|
-
f.puts escape bt
|
76
|
+
f.puts escape bt.join "\n"
|
125
77
|
f.puts " </#{type error}>"
|
126
78
|
end
|
127
79
|
f.puts " </testcase>"
|
@@ -145,53 +97,19 @@ module MiniTest
|
|
145
97
|
|
146
98
|
class CiUnit < Unit
|
147
99
|
|
148
|
-
|
149
|
-
|
150
|
-
# added this line
|
151
|
-
MiniTest::Ci.munit = self
|
152
|
-
|
153
|
-
header = "#{type}_suite_header"
|
154
|
-
puts send(header, suite) if respond_to? header
|
155
|
-
|
156
|
-
filter = options[:filter] || '/./'
|
157
|
-
filter = Regexp.new $1 if filter =~ /\/(.*)\//
|
158
|
-
|
159
|
-
assertions = suite.send("#{type}_methods").grep(filter).map { |method|
|
160
|
-
inst = suite.new method
|
161
|
-
inst._assertions = 0
|
162
|
-
|
163
|
-
print "#{suite}##{method} = " if @verbose
|
164
|
-
|
165
|
-
@start_time = Time.now
|
166
|
-
result = inst.run self
|
167
|
-
time = Time.now - @start_time
|
168
|
-
|
169
|
-
print "%.2f s = " % time if @verbose
|
170
|
-
print result
|
171
|
-
puts if @verbose
|
172
|
-
|
173
|
-
# added this line
|
174
|
-
MiniTest::Ci.push suite, method, time, inst._assertions
|
175
|
-
|
176
|
-
inst._assertions
|
177
|
-
}
|
178
|
-
|
179
|
-
return assertions.size, assertions.inject(0) { |sum, n| sum + n }
|
180
|
-
end
|
181
|
-
|
182
|
-
def puke klass, meth, e
|
183
|
-
MiniTest::Ci.add_error e
|
100
|
+
def record suite, method, assertions, time, error
|
101
|
+
MiniTest::Ci.push suite, method, assertions, time, error
|
184
102
|
super
|
185
103
|
end
|
186
104
|
|
187
105
|
def status io = self.output
|
188
106
|
super
|
189
|
-
MiniTest::Ci.finish
|
107
|
+
MiniTest::Ci.finish io
|
190
108
|
end
|
191
109
|
|
192
110
|
end
|
193
111
|
end
|
194
112
|
|
195
113
|
# set defaults
|
196
|
-
MiniTest::Ci.
|
114
|
+
MiniTest::Ci.report_dir = 'test/reports'
|
197
115
|
MiniTest::Unit.runner = MiniTest::CiUnit.new
|
data/test/test_minitest_ci.rb
CHANGED
@@ -41,23 +41,22 @@ class TestMinitest::TestCi < MiniTest::Unit::TestCase
|
|
41
41
|
old_out, MiniTest::Unit.output = MiniTest::Unit.output, @output
|
42
42
|
begin
|
43
43
|
runner = MiniTest::CiUnit.new
|
44
|
-
MiniTest::Ci.munit = runner
|
45
44
|
|
46
45
|
runner._run_suite MockTestSuite, :test
|
47
46
|
|
48
47
|
@@test_suites.delete MockTestSuite
|
49
|
-
MiniTest::Ci.finish
|
48
|
+
MiniTest::Ci.finish runner.output
|
50
49
|
ensure
|
51
50
|
MiniTest::Unit.output = old_out
|
52
51
|
end
|
52
|
+
MiniTest::Unit.runner = nil # reset
|
53
53
|
|
54
54
|
def self.output
|
55
55
|
@output
|
56
56
|
end
|
57
57
|
|
58
58
|
def setup
|
59
|
-
file = "#{MiniTest::Ci.
|
60
|
-
assert File.exists?( file ), 'expected xml file to exists'
|
59
|
+
file = "#{MiniTest::Ci.report_dir}/TEST-MockTestSuite.xml"
|
61
60
|
@file = File.read file
|
62
61
|
@doc = Nokogiri.parse @file
|
63
62
|
@doc = @doc.at_xpath('/testsuite')
|
@@ -114,12 +113,8 @@ class TestMinitest::TestCi < MiniTest::Unit::TestCase
|
|
114
113
|
assert_match( /generating ci files/, self.class.output.read )
|
115
114
|
end
|
116
115
|
|
117
|
-
def
|
118
|
-
|
119
|
-
|
120
|
-
bt = MiniTest::Ci.send :filter_backtrace, bt
|
121
|
-
|
122
|
-
assert_equal 1, bt.size
|
123
|
-
assert_match( /#{__FILE__}/, bt.first )
|
116
|
+
def test_filtering_backtraces
|
117
|
+
error = @doc.at_xpath('/testsuite/testcase[@name="test_raise_error"]')
|
118
|
+
refute_match /lib\/minitest/, error.inner_text
|
124
119
|
end
|
125
120
|
end
|
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-ci
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 15
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 2.0.0
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- Brian Henderson
|
@@ -10,7 +15,7 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date:
|
18
|
+
date: 2012-04-15 00:00:00 Z
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: minitest
|
@@ -18,31 +23,45 @@ dependencies:
|
|
18
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
19
24
|
none: false
|
20
25
|
requirements:
|
21
|
-
- -
|
26
|
+
- - ~>
|
22
27
|
- !ruby/object:Gem::Version
|
23
|
-
|
28
|
+
hash: 63
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 12
|
32
|
+
- 0
|
33
|
+
version: 2.12.0
|
24
34
|
type: :runtime
|
25
35
|
version_requirements: *id001
|
26
36
|
- !ruby/object:Gem::Dependency
|
27
|
-
name:
|
37
|
+
name: rdoc
|
28
38
|
prerelease: false
|
29
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
30
40
|
none: false
|
31
41
|
requirements:
|
32
42
|
- - ~>
|
33
43
|
- !ruby/object:Gem::Version
|
34
|
-
|
44
|
+
hash: 19
|
45
|
+
segments:
|
46
|
+
- 3
|
47
|
+
- 10
|
48
|
+
version: "3.10"
|
35
49
|
type: :development
|
36
50
|
version_requirements: *id002
|
37
51
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
52
|
+
name: nokogiri
|
39
53
|
prerelease: false
|
40
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
41
55
|
none: false
|
42
56
|
requirements:
|
43
|
-
- -
|
57
|
+
- - ~>
|
44
58
|
- !ruby/object:Gem::Version
|
45
|
-
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 1
|
62
|
+
- 5
|
63
|
+
- 0
|
64
|
+
version: 1.5.0
|
46
65
|
type: :development
|
47
66
|
version_requirements: *id003
|
48
67
|
- !ruby/object:Gem::Dependency
|
@@ -53,11 +72,16 @@ dependencies:
|
|
53
72
|
requirements:
|
54
73
|
- - ~>
|
55
74
|
- !ruby/object:Gem::Version
|
56
|
-
|
75
|
+
hash: 7
|
76
|
+
segments:
|
77
|
+
- 3
|
78
|
+
- 0
|
79
|
+
version: "3.0"
|
57
80
|
type: :development
|
58
81
|
version_requirements: *id004
|
59
82
|
description: |-
|
60
83
|
CI reporter plugin for MiniTest
|
84
|
+
|
61
85
|
This gem was made possible by ATT Interactive.
|
62
86
|
email:
|
63
87
|
- bhenderson@attinteractive.com
|
@@ -71,7 +95,6 @@ extra_rdoc_files:
|
|
71
95
|
- README.txt
|
72
96
|
files:
|
73
97
|
- .autotest
|
74
|
-
- .gitignore
|
75
98
|
- History.txt
|
76
99
|
- Manifest.txt
|
77
100
|
- README.txt
|
@@ -93,19 +116,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
116
|
requirements:
|
94
117
|
- - ">="
|
95
118
|
- !ruby/object:Gem::Version
|
119
|
+
hash: 3
|
120
|
+
segments:
|
121
|
+
- 0
|
96
122
|
version: "0"
|
97
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
124
|
none: false
|
99
125
|
requirements:
|
100
126
|
- - ">="
|
101
127
|
- !ruby/object:Gem::Version
|
128
|
+
hash: 3
|
129
|
+
segments:
|
130
|
+
- 0
|
102
131
|
version: "0"
|
103
132
|
requirements: []
|
104
133
|
|
105
134
|
rubyforge_project: minitest-ci
|
106
|
-
rubygems_version: 1.8.
|
135
|
+
rubygems_version: 1.8.20
|
107
136
|
signing_key:
|
108
137
|
specification_version: 3
|
109
|
-
summary: CI reporter plugin for MiniTest
|
138
|
+
summary: CI reporter plugin for MiniTest This gem was made possible by ATT Interactive.
|
110
139
|
test_files:
|
111
140
|
- test/test_minitest_ci.rb
|
data/.gitignore
DELETED