minitest-ci 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/minitest/ci.rb CHANGED
@@ -1,13 +1,37 @@
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'
1
+ begin
2
+ gem 'minitest', '2.6.0'
3
+ require "minitest/unit"
4
+ rescue Gem::LoadError => e
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")
10
+ end
4
11
 
5
12
  require 'fileutils'
6
13
  require 'cgi'
7
14
 
8
15
  module MiniTest
9
16
  module Ci
10
- VERSION = '1.0.2'
17
+ ###
18
+ # copied
19
+ file = if RUBY_VERSION =~ /^1\.9/ then # bt's expanded, but __FILE__ isn't :(
20
+ File.expand_path __FILE__
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.3'
11
35
 
12
36
  @test_dir = nil #'test/reports'
13
37
  @error = nil
@@ -55,6 +79,24 @@ module MiniTest
55
79
  FileUtils.mkdir_p @test_dir
56
80
  end
57
81
 
82
+ def escape o
83
+ CGI.escapeHTML(o.to_s)
84
+ end
85
+
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
+
58
100
  def generate_suite name, suite
59
101
  total_time, assertions, errors, failures, skips = 0, 0, 0, 0, 0
60
102
  suite.each do |_, t, a, e|
@@ -77,9 +119,9 @@ module MiniTest
77
119
  suite.each do |method, time, asserts, error|
78
120
  f.puts " <testcase time='#{"%6f" % time}' name='#{method}' assertions='#{asserts}'>"
79
121
  if error
80
- bt = MiniTest::filter_backtrace(error.backtrace).join "\n"
81
- f.write " <#{type error} type='#{error.class}' message='#{CGI.escapeHTML(error.message)}'>"
82
- f.puts CGI.escapeHTML(bt)
122
+ bt = filter_backtrace(error.backtrace).join "\n"
123
+ f.write " <#{type error} type='#{escape error.class}' message='#{escape error.message}'>"
124
+ f.puts escape bt
83
125
  f.puts " </#{type error}>"
84
126
  end
85
127
  f.puts " </testcase>"
@@ -20,9 +20,13 @@ class MockTestSuite < MiniTest::Unit::TestCase
20
20
  pass
21
21
  end
22
22
 
23
- def test_cgi_message
23
+ def test_invalid_characters_in_message
24
24
  raise Object.new.inspect
25
25
  end
26
+
27
+ def test_invalid_error_name
28
+ raise Class.new(Exception)
29
+ end
26
30
  end
27
31
 
28
32
  class TestMinitest
@@ -50,21 +54,22 @@ class TestMinitest::TestCi < MiniTest::Unit::TestCase
50
54
  def setup
51
55
  file = "#{MiniTest::Ci.test_dir}/TEST-MockTestSuite.xml"
52
56
  assert File.exists?( file ), 'expected xml file to exists'
53
- @doc = Nokogiri.parse File.read file
57
+ @file = File.read file
58
+ @doc = Nokogiri.parse @file
54
59
  @doc = @doc.at_xpath('/testsuite')
55
60
  end
56
61
 
57
62
  def test_testsuite
58
63
  assert_equal "1", @doc['skipped']
59
64
  assert_equal "1", @doc['failures']
60
- assert_equal "3", @doc['errors']
65
+ assert_equal "4", @doc['errors']
61
66
  assert_equal "2", @doc['assertions']
62
- assert_equal "5", @doc['tests']
67
+ assert_equal "6", @doc['tests']
63
68
  assert_equal "MockTestSuite", @doc['name']
64
69
  end
65
70
 
66
71
  def test_testcase
67
- assert_equal 5, @doc.children.count {|c| Nokogiri::XML::Element === c}
72
+ assert_equal 6, @doc.children.count {|c| Nokogiri::XML::Element === c}
68
73
  @doc.children.each do |c|
69
74
  next unless Nokogiri::XML::Element === c
70
75
  assert_equal 'testcase', c.name
@@ -86,13 +91,26 @@ class TestMinitest::TestCi < MiniTest::Unit::TestCase
86
91
  assert_equal 'raise an error', error.at_xpath('failure')['message']
87
92
  assert_equal '0', error['assertions']
88
93
 
89
- error = @doc.at_xpath('/testsuite/testcase[@name="test_cgi_message"]')
94
+ error = @doc.at_xpath('/testsuite/testcase[@name="test_invalid_characters_in_message"]')
90
95
  assert_match( /^#<Object/, error.at_xpath('failure')['message'] )
91
96
  assert_equal '0', error['assertions']
97
+
98
+ error = @doc.at_xpath('/testsuite/testcase[@name="test_invalid_error_name"]')
99
+ assert_match( /^#<Class/, error.at_xpath('failure')['message'] )
100
+ assert_equal '0', error['assertions']
92
101
  end
93
102
 
94
103
  def test_output
95
104
  self.class.output.rewind
96
105
  assert_match( /generating ci files/, self.class.output.read )
97
106
  end
107
+
108
+ def test_filter_backtrace
109
+ bt = begin; raise; rescue => e; e.backtrace; end
110
+
111
+ bt = MiniTest::Ci.send :filter_backtrace, bt
112
+
113
+ assert_equal 1, bt.size
114
+ assert_match( /#{__FILE__}/, bt.first )
115
+ end
98
116
  end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-ci
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
4
  prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 2
10
- version: 1.0.2
5
+ version: 1.0.3
11
6
  platform: ruby
12
7
  authors:
13
8
  - Brian Henderson
@@ -15,8 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-09-27 00:00:00 -07:00
19
- default_executable:
13
+ date: 2011-10-04 00:00:00 Z
20
14
  dependencies:
21
15
  - !ruby/object:Gem::Dependency
22
16
  name: minitest
@@ -26,11 +20,6 @@ dependencies:
26
20
  requirements:
27
21
  - - "="
28
22
  - !ruby/object:Gem::Version
29
- hash: 23
30
- segments:
31
- - 2
32
- - 6
33
- - 0
34
23
  version: 2.6.0
35
24
  type: :runtime
36
25
  version_requirements: *id001
@@ -42,11 +31,6 @@ dependencies:
42
31
  requirements:
43
32
  - - ~>
44
33
  - !ruby/object:Gem::Version
45
- hash: 3
46
- segments:
47
- - 1
48
- - 5
49
- - 0
50
34
  version: 1.5.0
51
35
  type: :development
52
36
  version_requirements: *id002
@@ -58,11 +42,6 @@ dependencies:
58
42
  requirements:
59
43
  - - ">="
60
44
  - !ruby/object:Gem::Version
61
- hash: 27
62
- segments:
63
- - 2
64
- - 4
65
- - 2
66
45
  version: 2.4.2
67
46
  type: :development
68
47
  version_requirements: *id003
@@ -74,10 +53,6 @@ dependencies:
74
53
  requirements:
75
54
  - - ~>
76
55
  - !ruby/object:Gem::Version
77
- hash: 27
78
- segments:
79
- - 2
80
- - 12
81
56
  version: "2.12"
82
57
  type: :development
83
58
  version_requirements: *id004
@@ -104,7 +79,6 @@ files:
104
79
  - lib/minitest/ci.rb
105
80
  - test/test_minitest_ci.rb
106
81
  - .gemtest
107
- has_rdoc: true
108
82
  homepage: https://github.com/bhenderson/minitest-ci
109
83
  licenses: []
110
84
 
@@ -119,23 +93,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
93
  requirements:
120
94
  - - ">="
121
95
  - !ruby/object:Gem::Version
122
- hash: 3
123
- segments:
124
- - 0
125
96
  version: "0"
126
97
  required_rubygems_version: !ruby/object:Gem::Requirement
127
98
  none: false
128
99
  requirements:
129
100
  - - ">="
130
101
  - !ruby/object:Gem::Version
131
- hash: 3
132
- segments:
133
- - 0
134
102
  version: "0"
135
103
  requirements: []
136
104
 
137
105
  rubyforge_project: minitest-ci
138
- rubygems_version: 1.6.2
106
+ rubygems_version: 1.8.10
139
107
  signing_key:
140
108
  specification_version: 3
141
109
  summary: CI reporter plugin for MiniTest This gem was made possible by ATT Interactive.