test-unit 3.0.4 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf2bacf30a66a56af147ea9e94da6e0494a2651d
4
- data.tar.gz: dc496f0ff48c039ce45d31d9b0aeda8c8fe3207c
3
+ metadata.gz: 82214fb59acb16827aacf60b960cefc080128e3d
4
+ data.tar.gz: 2639d42836d7ca114f9acb65e1e6c67136672acc
5
5
  SHA512:
6
- metadata.gz: ea2f7f667dbc1ebb99e234c2634f2b8ed4651d1d56704a5ab800d4f0fd285d97309a4ed4920020ef37cdc4eb8316c114d75045e33ba20652ee04e4d565ae519b
7
- data.tar.gz: c8301808c3e979ee04682074550643a7b0ae214bba5eb60f4c9808be7d86ff2faa7eaded9829e47e9f841fd76257d37bdb1b294163faad401bc9150fe4c1a671
6
+ metadata.gz: 814c6f16fe4e256ad788617cb627441b93ce32c20a3b8972e5e4e799534a8c3350ff77ecdef0bc13ab6fcb5b532b7efec814717f2cfee6fbbabdfd04829f5b4c
7
+ data.tar.gz: a6301d7b7e109157505e354dd3c43393921f51b10bbddd5f44e26f1e2689b8c7be9059da74d61be8bfc73fc626ae3f9d601292ccbb1ce9d80f14bb0f21fe5327
@@ -1,5 +1,19 @@
1
1
  # News
2
2
 
3
+ ## 3.0.5 - 2014-11-08 {#version-3-0-5}
4
+
5
+ It's a minor update release.
6
+
7
+ ### Fixes
8
+
9
+ * Fixed a bug that startup/shutdown of parent test case isn't called
10
+ when the test case includes one or more modules.
11
+ [GitHub#83][Reported by Chadderton Odwazny]
12
+
13
+ ### Thanks
14
+
15
+ * Chadderton Odwazny
16
+
3
17
  ## 3.0.4 - 2014-11-01 {#version-3-0-4}
4
18
 
5
19
  It's a minor update release.
@@ -24,10 +24,13 @@ module Test
24
24
 
25
25
  def add_test_cases(suite, test_cases)
26
26
  children_map = {}
27
- test_cases.each do |descendant_test_case|
28
- parent = descendant_test_case.ancestors[1]
27
+ test_cases.each do |test_case|
28
+ ancestor_classes = test_case.ancestors.find_all do |ancestor|
29
+ ancestor.is_a?(Class)
30
+ end
31
+ parent = ancestor_classes[1]
29
32
  children_map[parent] ||= []
30
- children_map[parent] << descendant_test_case
33
+ children_map[parent] << test_case
31
34
  end
32
35
 
33
36
  root_test_cases = children_map.keys - test_cases
@@ -1,5 +1,5 @@
1
1
  module Test
2
2
  module Unit
3
- VERSION = '3.0.4'
3
+ VERSION = '3.0.5'
4
4
  end
5
5
  end
@@ -5,129 +5,174 @@ class TestUnitCollectorDescendant < Test::Unit::TestCase
5
5
  def setup
6
6
  @previous_descendants = Test::Unit::TestCase::DESCENDANTS.dup
7
7
  Test::Unit::TestCase::DESCENDANTS.clear
8
+ end
9
+
10
+ def teardown
11
+ Test::Unit::TestCase::DESCENDANTS.replace(@previous_descendants)
12
+ end
13
+
14
+ private
15
+ def assert_collect(expected, *collect_args)
16
+ collector = Test::Unit::Collector::Descendant.new
17
+ yield(collector) if block_given?
18
+ assert_equal(expected, collector.send(:collect, *collect_args))
19
+ end
20
+
21
+ def default_name
22
+ Test::Unit::Collector::Descendant::NAME
23
+ end
8
24
 
9
- @test_case1 = Class.new(Test::Unit::TestCase) do
10
- def self.name
11
- "test-case1"
25
+ def empty_suite(name=nil)
26
+ Test::Unit::TestSuite.new(name || default_name)
27
+ end
28
+
29
+ class TestCollect < self
30
+ def setup
31
+ super
32
+
33
+ @test_case1 = Class.new(Test::Unit::TestCase) do
34
+ def self.name
35
+ "test-case1"
36
+ end
37
+
38
+ def test_1
39
+ end
40
+
41
+ def test_2
42
+ end
12
43
  end
13
44
 
14
- def test_1
45
+ @test_case2 = Class.new(Test::Unit::TestCase) do
46
+ def self.name
47
+ "test-case2"
48
+ end
49
+
50
+ def test_0
51
+ end
15
52
  end
16
53
 
17
- def test_2
54
+ @no_test_case = Class.new do
55
+ def self.name
56
+ "no-test-case"
57
+ end
58
+
59
+ def test_4
60
+ end
18
61
  end
19
62
  end
20
63
 
21
- @test_case2 = Class.new(Test::Unit::TestCase) do
22
- def self.name
23
- "test-case2"
24
- end
64
+ def test_basic
65
+ assert_collect(full_suite("name"), "name")
25
66
 
26
- def test_0
67
+ assert_collect(full_suite("name"), "name") do |collector|
68
+ collector.filter = []
27
69
  end
28
70
  end
29
71
 
30
- @no_test_case = Class.new do
31
- def self.name
32
- "no-test-case"
72
+ def test_filtered
73
+ assert_collect(empty_suite) do |collector|
74
+ collector.filter = Proc.new {false}
33
75
  end
34
76
 
35
- def test_4
77
+ assert_collect(full_suite) do |collector|
78
+ collector.filter = Proc.new {true}
36
79
  end
37
- end
38
- end
39
80
 
40
- def teardown
41
- Test::Unit::TestCase::DESCENDANTS.replace(@previous_descendants)
42
- end
81
+ assert_collect(full_suite) do |collector|
82
+ collector.filter = Proc.new {nil}
83
+ end
43
84
 
44
- def test_basic_collection
45
- assert_collect(full_suite("name"), "name")
85
+ assert_collect(empty_suite) do |collector|
86
+ collector.filter = [Proc.new {false}, Proc.new {true}]
87
+ end
46
88
 
47
- assert_collect(full_suite("name"), "name") do |collector|
48
- collector.filter = []
49
- end
50
- end
89
+ assert_collect(empty_suite) do |collector|
90
+ collector.filter = [Proc.new {true}, Proc.new {false}]
91
+ end
51
92
 
52
- def test_filtered_collection
53
- assert_collect(empty_suite) do |collector|
54
- collector.filter = Proc.new {false}
55
- end
93
+ assert_collect(empty_suite) do |collector|
94
+ collector.filter = [Proc.new {nil}, Proc.new {false}]
95
+ end
56
96
 
57
- assert_collect(full_suite) do |collector|
58
- collector.filter = Proc.new {true}
59
- end
97
+ assert_collect(full_suite) do |collector|
98
+ collector.filter = [Proc.new {nil}, Proc.new {true}]
99
+ end
60
100
 
61
- assert_collect(full_suite) do |collector|
62
- collector.filter = Proc.new {nil}
63
- end
101
+ expected = empty_suite
102
+ suite1 = Test::Unit::TestSuite.new(@test_case1.name)
103
+ suite1 << @test_case1.new("test_1")
104
+ suite2 = Test::Unit::TestSuite.new(@test_case2.name)
105
+ suite2 << @test_case2.new("test_0")
106
+ expected << suite1 << suite2
107
+ assert_collect(expected) do |collector|
108
+ collector.filter = Proc.new do |test|
109
+ ['test_1', 'test_0'].include?(test.method_name)
110
+ end
111
+ end
64
112
 
65
- assert_collect(empty_suite) do |collector|
66
- collector.filter = [Proc.new {false}, Proc.new {true}]
113
+ suite1 = Test::Unit::TestSuite.new(@test_case1.name)
114
+ suite1 << @test_case1.new("test_1")
115
+ suite2 = Test::Unit::TestSuite.new(@test_case2.name)
116
+ suite2 << @test_case2.new("test_0")
117
+ assert_collect(empty_suite) do |collector|
118
+ filters = [Proc.new {|test| test.method_name == 'test_1' ? true : nil},
119
+ Proc.new {|test| test.method_name == 'test_0' ? true : nil},
120
+ Proc.new {false}]
121
+ collector.filter = filters
122
+ end
67
123
  end
68
124
 
69
- assert_collect(empty_suite) do |collector|
70
- collector.filter = [Proc.new {true}, Proc.new {false}]
71
- end
125
+ private
126
+ def full_suite(name=nil)
127
+ sub_suite1 = Test::Unit::TestSuite.new(@test_case1.name)
128
+ sub_suite1 << @test_case1.new('test_1')
129
+ sub_suite1 << @test_case1.new('test_2')
72
130
 
73
- assert_collect(empty_suite) do |collector|
74
- collector.filter = [Proc.new {nil}, Proc.new {false}]
75
- end
131
+ sub_suite2 = Test::Unit::TestSuite.new(@test_case2.name)
132
+ sub_suite2 << @test_case2.new('test_0')
76
133
 
77
- assert_collect(full_suite) do |collector|
78
- collector.filter = [Proc.new {nil}, Proc.new {true}]
134
+ suite = empty_suite(name)
135
+ suite << sub_suite1
136
+ suite << sub_suite2
137
+ suite
79
138
  end
139
+ end
80
140
 
81
- expected = empty_suite
82
- suite1 = Test::Unit::TestSuite.new(@test_case1.name)
83
- suite1 << @test_case1.new("test_1")
84
- suite2 = Test::Unit::TestSuite.new(@test_case2.name)
85
- suite2 << @test_case2.new("test_0")
86
- expected << suite1 << suite2
87
- assert_collect(expected) do |collector|
88
- collector.filter = Proc.new do |test|
89
- ['test_1', 'test_0'].include?(test.method_name)
141
+ class TestModule < self
142
+ def test_included_in_child
143
+ tests = Module.new do
144
+ def test_in_module
145
+ end
90
146
  end
91
- end
92
147
 
93
- suite1 = Test::Unit::TestSuite.new(@test_case1.name)
94
- suite1 << @test_case1.new("test_1")
95
- suite2 = Test::Unit::TestSuite.new(@test_case2.name)
96
- suite2 << @test_case2.new("test_0")
97
- assert_collect(empty_suite) do |collector|
98
- filters = [Proc.new {|test| test.method_name == 'test_1' ? true : nil},
99
- Proc.new {|test| test.method_name == 'test_0' ? true : nil},
100
- Proc.new {false}]
101
- collector.filter = filters
102
- end
103
- end
148
+ parent_test_case = Class.new(Test::Unit::TestCase) do
149
+ class << self
150
+ def name
151
+ "Parent"
152
+ end
153
+ end
154
+ end
104
155
 
105
- private
106
- def assert_collect(expected, *collect_args)
107
- collector = Test::Unit::Collector::Descendant.new
108
- yield(collector) if block_given?
109
- assert_equal(expected, collector.send(:collect, *collect_args))
110
- end
156
+ child_test_case = Class.new(parent_test_case) do
157
+ include tests
111
158
 
112
- def default_name
113
- Test::Unit::Collector::Descendant::NAME
114
- end
159
+ class << self
160
+ def name
161
+ "Child"
162
+ end
163
+ end
164
+ end
115
165
 
116
- def empty_suite(name=nil)
117
- Test::Unit::TestSuite.new(name || default_name)
118
- end
166
+ child_suite = Test::Unit::TestSuite.new(child_test_case.name)
167
+ child_suite << child_test_case.new("test_in_module")
119
168
 
120
- def full_suite(name=nil)
121
- sub_suite1 = Test::Unit::TestSuite.new(@test_case1.name)
122
- sub_suite1 << @test_case1.new('test_1')
123
- sub_suite1 << @test_case1.new('test_2')
169
+ parent_suite = Test::Unit::TestSuite.new(parent_test_case.name)
170
+ parent_suite << child_suite
124
171
 
125
- sub_suite2 = Test::Unit::TestSuite.new(@test_case2.name)
126
- sub_suite2 << @test_case2.new('test_0')
172
+ suite = empty_suite("all")
173
+ suite << parent_suite
127
174
 
128
- suite = empty_suite(name)
129
- suite << sub_suite1
130
- suite << sub_suite2
131
- suite
175
+ assert_collect(suite, "all")
176
+ end
132
177
  end
133
178
  end
@@ -159,6 +159,18 @@ module Test
159
159
  end
160
160
  end
161
161
 
162
+ def jruby?
163
+ defined?(JRUBY_VERSION)
164
+ end
165
+
166
+ def rubinius?
167
+ false # TODO
168
+ end
169
+
170
+ def cruby?
171
+ (not jruby?) and (not rubinius?)
172
+ end
173
+
162
174
  def test_add_error
163
175
  test_case = @tc_failure_error.new(:test_error)
164
176
  assert do
@@ -180,15 +192,16 @@ module Test
180
192
  :location => normalize_location(fault.location),
181
193
  }
182
194
  end
195
+ location = []
196
+ location << "#{__FILE__}:0:in `/'" if cruby?
197
+ location << "#{__FILE__}:0:in `test_error'"
198
+ location << "#{__FILE__}:0:in `#{__method__}'"
183
199
  assert_equal([
184
200
  {
185
201
  :class => Error,
186
202
  :message => "ZeroDivisionError: divided by 0",
187
203
  :test_name => "test_error(TC_FailureError)",
188
- :location => [
189
- "#{__FILE__}:0:in `test_error'",
190
- "#{__FILE__}:0:in `#{__method__}'",
191
- ],
204
+ :location => location,
192
205
  },
193
206
  ],
194
207
  fault_details)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-unit
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 3.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-01 00:00:00.000000000 Z
12
+ date: 2014-11-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: power_assert