minitest-ci 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,19 @@
1
+ === 2.1.0 / 2012-05-10
2
+ * 1 minor enhancement
3
+
4
+ * Adds ability to disable cleaning report dir. #2
5
+
6
+ * 1 bug fix
7
+
8
+ * Uses M::Unit::after_tests instead of M::Unit#status to trigger finish method. Fixes #3
9
+
10
+ * 6 unknowns:
11
+
12
+ * @report_dir doesn't need to be initialized here because I do it a few lines later.
13
+ * Changes clean switch to positive accessor. #2
14
+ * Cleans up init variables. Removes runner reset. Appeases warning.
15
+ * Removes cruft
16
+
1
17
  === 2.0.0 / 2012-04-15
2
18
  * 1 major enhancement
3
19
 
data/README.txt CHANGED
@@ -16,6 +16,20 @@ This gem was made possible by ATT Interactive.
16
16
 
17
17
  require 'minitest/ci'
18
18
 
19
+ Records test results and generates XML files (for junit hudson plugin
20
+ for example) at the end of the test run. The report directory is cleaned
21
+ between test runs. To disable:
22
+
23
+ # test/helper.rb
24
+ MiniTest::Ci.auto_clean = false
25
+
26
+ # Rakefile (optional, but recommended!)
27
+ task :ci_cleanup do
28
+ require 'minitest/ci'
29
+ MiniTest::Ci.clean
30
+ end
31
+ task :test => %w[ci_cleanup test:one test:two]
32
+
19
33
  == REQUIREMENTS:
20
34
 
21
35
  * See Rakefile
data/lib/minitest/ci.rb CHANGED
@@ -10,16 +10,20 @@ require 'cgi'
10
10
  module MiniTest
11
11
  module Ci
12
12
 
13
- VERSION = '2.0.0'
13
+ VERSION = '2.1.0'
14
14
 
15
- @report_dir = nil
16
15
  @suites = Hash.new {|h,k| h[k] = []}
17
16
 
18
17
  class << self
19
18
  # Accessor method to change the report dir if you don't like the
20
19
  # defaults.
21
20
  attr_accessor :report_dir
21
+
22
+ # Clean the report_dir between test runs? (defaults to true)
23
+ attr_accessor :auto_clean
22
24
  end
25
+ self.report_dir = 'test/reports'
26
+ self.auto_clean = true
23
27
 
24
28
  def push suite, method, num_assertions, time, error
25
29
  @suites[suite] << [method, num_assertions, time, error]
@@ -38,19 +42,19 @@ module MiniTest
38
42
  end
39
43
  end
40
44
 
41
- private
42
-
43
- def clean
44
- FileUtils.rm_rf report_dir
45
- FileUtils.mkdir_p report_dir
45
+ def clean verbose = false
46
+ FileUtils.rm_rf report_dir, :verbose => verbose if auto_clean
47
+ FileUtils.mkdir_p report_dir, :verbose => verbose
46
48
  end
47
49
 
50
+ private
51
+
48
52
  def escape o
49
53
  CGI.escapeHTML(o.to_s)
50
54
  end
51
55
 
52
56
  def generate_suite name, suite
53
- total_time, assertions, errors, failures, skips = 0, 0, 0, 0, 0
57
+ total_time = assertions = errors = failures = skips = 0
54
58
  suite.each do |_, a, t, e|
55
59
  total_time += t
56
60
  assertions += a
@@ -97,19 +101,17 @@ module MiniTest
97
101
 
98
102
  class CiUnit < Unit
99
103
 
100
- def record suite, method, assertions, time, error
101
- MiniTest::Ci.push suite, method, assertions, time, error
102
- super
104
+ after_tests do
105
+ MiniTest::Ci.finish self.output
103
106
  end
104
107
 
105
- def status io = self.output
108
+ def record suite, method, assertions, time, error
109
+ MiniTest::Ci.push suite, method, assertions, time, error
106
110
  super
107
- MiniTest::Ci.finish io
108
111
  end
109
112
 
110
113
  end
111
114
  end
112
115
 
113
- # set defaults
114
- MiniTest::Ci.report_dir = 'test/reports'
116
+ # use
115
117
  MiniTest::Unit.runner = MiniTest::CiUnit.new
@@ -49,7 +49,6 @@ class TestMinitest::TestCi < MiniTest::Unit::TestCase
49
49
  ensure
50
50
  MiniTest::Unit.output = old_out
51
51
  end
52
- MiniTest::Unit.runner = nil # reset
53
52
 
54
53
  def self.output
55
54
  @output
@@ -115,6 +114,6 @@ class TestMinitest::TestCi < MiniTest::Unit::TestCase
115
114
 
116
115
  def test_filtering_backtraces
117
116
  error = @doc.at_xpath('/testsuite/testcase[@name="test_raise_error"]')
118
- refute_match /lib\/minitest/, error.inner_text
117
+ refute_match( /lib\/minitest/, error.inner_text )
119
118
  end
120
119
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-ci
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 2.0.0
10
+ version: 2.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Henderson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-15 00:00:00 Z
18
+ date: 2012-05-10 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: minitest