test-unit 2.0.6 → 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +28 -0
- data/README.txt +2 -1
- data/lib/test/unit/autorunner.rb +21 -16
- data/lib/test/unit/collector.rb +1 -8
- data/lib/test/unit/collector/dir.rb +1 -1
- data/lib/test/unit/collector/load.rb +1 -1
- data/lib/test/unit/error.rb +4 -0
- data/lib/test/unit/failure.rb +4 -0
- data/lib/test/unit/notification.rb +8 -4
- data/lib/test/unit/omission.rb +4 -0
- data/lib/test/unit/pending.rb +4 -0
- data/lib/test/unit/priority.rb +2 -3
- data/lib/test/unit/testcase.rb +16 -7
- data/lib/test/unit/ui/console/testrunner.rb +4 -2
- data/lib/test/unit/version.rb +1 -1
- data/test/collector/test-descendant.rb +2 -4
- data/test/collector/test-load.rb +19 -0
- data/test/collector/test_objectspace.rb +7 -5
- data/test/test-testcase.rb +48 -38
- metadata +23 -3
data/History.txt
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
+
=== 2.0.7 / 2010-03-09
|
2
|
+
|
3
|
+
* 4 major enhancements
|
4
|
+
* detect redefined test methods.
|
5
|
+
* [INTERFACE IMCOMPATIBLE] multiple --name and --testcase
|
6
|
+
options narrow down targets instead of adding targets.
|
7
|
+
* [#27764] accept custom test_order for each test case.
|
8
|
+
[Suggested by David MARCHALAND]
|
9
|
+
* [#27790] ignore omitted tests from 'n% passed' report.
|
10
|
+
[Suggested by Daniel Berger]
|
11
|
+
|
12
|
+
* 2 minor enchancements
|
13
|
+
* [#27832] ignore .git directory. [Suggested by Daniel Berger]
|
14
|
+
* [#27792] require 'fileutils' and 'tmpdir' lazily for non-priority
|
15
|
+
mode users. [Suggested by David MARCHALAND]
|
16
|
+
|
17
|
+
* 2n bug fixes
|
18
|
+
* [#27892] modify processed arguments array destructively.
|
19
|
+
[Reported by Bob Saveland]
|
20
|
+
* work without HOME environment variable.
|
21
|
+
[Reported by Champak Ch]
|
22
|
+
|
23
|
+
* Thanks
|
24
|
+
* David MARCHALAND
|
25
|
+
* Daniel Berger
|
26
|
+
* Bob Saveland
|
27
|
+
* Champak Ch
|
28
|
+
|
1
29
|
=== 2.0.6 / 2010-01-09
|
2
30
|
|
3
31
|
* 3 major enhancements
|
data/README.txt
CHANGED
@@ -51,5 +51,6 @@ This software is distributed under the same terms as ruby.
|
|
51
51
|
* Diego Pettenò: A bug report.
|
52
52
|
* Angelo Lakra: A bug report.
|
53
53
|
* Mike Pomraning: A bug report.
|
54
|
-
* David MARCHALAND:
|
54
|
+
* David MARCHALAND: Suggestions and bug reports.
|
55
55
|
* Andrew Grimm: A bug report.
|
56
|
+
* Champak Ch: A bug report.
|
data/lib/test/unit/autorunner.rb
CHANGED
@@ -117,27 +117,21 @@ module Test
|
|
117
117
|
if File.exist?(config_file)
|
118
118
|
load_config(config_file)
|
119
119
|
else
|
120
|
-
|
121
|
-
load_config(global_config_file) if File.exist?(global_config_file)
|
120
|
+
load_global_config
|
122
121
|
end
|
123
122
|
yield(self) if block_given?
|
124
123
|
end
|
125
124
|
|
126
125
|
def process_args(args = ARGV)
|
127
|
-
default_arguments = @default_arguments.dup
|
128
126
|
begin
|
129
|
-
|
130
|
-
options.order!(
|
127
|
+
args.unshift(*@default_arguments)
|
128
|
+
options.order!(args) {|arg| @to_run << arg}
|
131
129
|
rescue OptionParser::ParseError => e
|
132
130
|
puts e
|
133
131
|
puts options
|
134
132
|
exit(false)
|
135
|
-
else
|
136
|
-
@filters << proc{false} unless(@filters.empty?)
|
137
133
|
end
|
138
134
|
not @to_run.empty?
|
139
|
-
ensure
|
140
|
-
@default_arguments = default_arguments
|
141
135
|
end
|
142
136
|
|
143
137
|
def options
|
@@ -186,9 +180,9 @@ module Test
|
|
186
180
|
n = (%r{\A/(.*)/\Z} =~ n ? Regexp.new($1) : n)
|
187
181
|
case n
|
188
182
|
when Regexp
|
189
|
-
@filters << proc{|t| n =~ t.method_name ? true :
|
183
|
+
@filters << proc{|t| n =~ t.method_name ? true : false}
|
190
184
|
else
|
191
|
-
@filters << proc{|t| n == t.method_name
|
185
|
+
@filters << proc{|t| n == t.method_name}
|
192
186
|
end
|
193
187
|
end
|
194
188
|
|
@@ -198,17 +192,17 @@ module Test
|
|
198
192
|
n = (%r{\A/(.*)/\Z} =~ n ? Regexp.new($1) : n)
|
199
193
|
case n
|
200
194
|
when Regexp
|
201
|
-
@filters << proc{|t| n =~ t.class.name ? true :
|
195
|
+
@filters << proc{|t| n =~ t.class.name ? true : false}
|
202
196
|
else
|
203
|
-
@filters << proc{|t| n == t.class.name
|
197
|
+
@filters << proc{|t| n == t.class.name}
|
204
198
|
end
|
205
199
|
end
|
206
200
|
|
207
201
|
priority_filter = Proc.new do |test|
|
208
|
-
if @filters
|
209
|
-
|
202
|
+
if @filters == [priority_filter]
|
203
|
+
Priority::Checker.new(test).need_to_run?
|
210
204
|
else
|
211
|
-
|
205
|
+
nil
|
212
206
|
end
|
213
207
|
end
|
214
208
|
o.on("--[no-]priority-mode",
|
@@ -346,6 +340,17 @@ module Test
|
|
346
340
|
def default_collector
|
347
341
|
self.class.collector(@standalone ? :load : :descendant)
|
348
342
|
end
|
343
|
+
|
344
|
+
def global_config_file
|
345
|
+
File.expand_path("~/.test-unit.xml")
|
346
|
+
rescue ArgumentError
|
347
|
+
nil
|
348
|
+
end
|
349
|
+
|
350
|
+
def load_global_config
|
351
|
+
file = global_config_file
|
352
|
+
load_config(file) if file and File.exist?(file)
|
353
|
+
end
|
349
354
|
end
|
350
355
|
end
|
351
356
|
end
|
data/lib/test/unit/collector.rb
CHANGED
@@ -23,14 +23,7 @@ module Test
|
|
23
23
|
def include?(test)
|
24
24
|
return true if(@filters.empty?)
|
25
25
|
@filters.each do |filter|
|
26
|
-
|
27
|
-
if(result.nil?)
|
28
|
-
next
|
29
|
-
elsif(!result)
|
30
|
-
return false
|
31
|
-
else
|
32
|
-
return true
|
33
|
-
end
|
26
|
+
return false if filter[test] == false
|
34
27
|
end
|
35
28
|
true
|
36
29
|
end
|
@@ -60,7 +60,7 @@ module Test
|
|
60
60
|
next if(e == '.' || e == '..')
|
61
61
|
e_name = dir_name ? @file.join(dir_name, e) : e
|
62
62
|
if @file.directory?(realdir(e_name))
|
63
|
-
next if /\A(?:CVS|\.svn)\z/ =~ e
|
63
|
+
next if /\A(?:CVS|\.svn|\.git)\z/ =~ e
|
64
64
|
sub_suite = recursive_collect(e_name, already_gathered)
|
65
65
|
sub_suites << sub_suite unless(sub_suite.empty?)
|
66
66
|
else
|
@@ -14,7 +14,7 @@ module Test
|
|
14
14
|
def initialize
|
15
15
|
super
|
16
16
|
@system_excludes = [/~\z/, /\A\.\#/]
|
17
|
-
@system_directory_excludes = [/\A(?:CVS|\.svn)\z/]
|
17
|
+
@system_directory_excludes = [/\A(?:CVS|\.svn|\.git)\z/]
|
18
18
|
@patterns = [/\Atest[_\-].+\.rb\z/m]
|
19
19
|
@excludes = []
|
20
20
|
@base = nil
|
data/lib/test/unit/error.rb
CHANGED
data/lib/test/unit/failure.rb
CHANGED
@@ -41,6 +41,10 @@ module Test
|
|
41
41
|
def to_s
|
42
42
|
long_display
|
43
43
|
end
|
44
|
+
|
45
|
+
def critical?
|
46
|
+
false
|
47
|
+
end
|
44
48
|
end
|
45
49
|
|
46
50
|
class NotifiedError < StandardError
|
@@ -79,16 +83,16 @@ module Test
|
|
79
83
|
module NotificationHandler
|
80
84
|
class << self
|
81
85
|
def included(base)
|
82
|
-
base.exception_handler(:
|
86
|
+
base.exception_handler(:handle_notified_error)
|
83
87
|
end
|
84
88
|
end
|
85
89
|
|
86
90
|
private
|
87
|
-
def
|
91
|
+
def handle_notified_error(exception)
|
88
92
|
return false unless exception.is_a?(NotifiedError)
|
89
93
|
notification = Notification.new(name,
|
90
|
-
|
91
|
-
|
94
|
+
filter_backtrace(exception.backtrace),
|
95
|
+
exception.message)
|
92
96
|
add_notification(notification)
|
93
97
|
true
|
94
98
|
end
|
data/lib/test/unit/omission.rb
CHANGED
data/lib/test/unit/pending.rb
CHANGED
data/lib/test/unit/priority.rb
CHANGED
data/lib/test/unit/testcase.rb
CHANGED
@@ -94,10 +94,15 @@ module Test
|
|
94
94
|
DESCENDANTS << sub_class
|
95
95
|
end
|
96
96
|
|
97
|
-
@@added_methods =
|
97
|
+
@@added_methods = {}
|
98
98
|
def method_added(name) # :nodoc:
|
99
99
|
super
|
100
|
-
@@added_methods
|
100
|
+
added_methods = (@@added_methods[self] ||= [])
|
101
|
+
stringified_name = name.to_s
|
102
|
+
if added_methods.include?(stringified_name)
|
103
|
+
attribute(:redefined, true, {}, stringified_name)
|
104
|
+
end
|
105
|
+
added_methods << stringified_name
|
101
106
|
end
|
102
107
|
|
103
108
|
# Rolls up all of the test* methods in the fixture into
|
@@ -191,12 +196,12 @@ module Test
|
|
191
196
|
def shutdown
|
192
197
|
end
|
193
198
|
|
194
|
-
@@
|
199
|
+
@@test_orders = {}
|
195
200
|
|
196
201
|
# Returns the current test order. This returns
|
197
202
|
# +:alphabetic+ by default.
|
198
203
|
def test_order
|
199
|
-
@@
|
204
|
+
@@test_orders[self] || AVAILABLE_ORDERS.first
|
200
205
|
end
|
201
206
|
|
202
207
|
# Sets the current test order.
|
@@ -209,7 +214,7 @@ module Test
|
|
209
214
|
# [:defined]
|
210
215
|
# Tests are sorted in defined order.
|
211
216
|
def test_order=(order)
|
212
|
-
@@
|
217
|
+
@@test_orders[self] = order
|
213
218
|
end
|
214
219
|
|
215
220
|
# Defines a test in declarative syntax.
|
@@ -266,9 +271,10 @@ module Test
|
|
266
271
|
end
|
267
272
|
|
268
273
|
def sort_test_names_in_defined_order(test_names)
|
274
|
+
added_methods = @@added_methods[self]
|
269
275
|
test_names.sort do |test1, test2|
|
270
|
-
test1_defined_order =
|
271
|
-
test2_defined_order =
|
276
|
+
test1_defined_order = added_methods.index(test1)
|
277
|
+
test2_defined_order = added_methods.index(test2)
|
272
278
|
if test1_defined_order and test2_defined_order
|
273
279
|
test1_defined_order <=> test2_defined_order
|
274
280
|
elsif test1_defined_order
|
@@ -438,6 +444,9 @@ module Test
|
|
438
444
|
end
|
439
445
|
|
440
446
|
def run_test
|
447
|
+
if self.class.get_attribute(@method_name, :redefined)
|
448
|
+
notify("#{self.class}\##{@method_name} was redefined")
|
449
|
+
end
|
441
450
|
__send__(@method_name)
|
442
451
|
end
|
443
452
|
|
@@ -39,6 +39,7 @@ module Test
|
|
39
39
|
@progress_row_max ||= guess_progress_row_max
|
40
40
|
@already_outputted = false
|
41
41
|
@n_successes = 0
|
42
|
+
@n_omissions = 0
|
42
43
|
@indent = 0
|
43
44
|
@top_level = true
|
44
45
|
@faults = []
|
@@ -84,7 +85,8 @@ module Test
|
|
84
85
|
def add_fault(fault)
|
85
86
|
@faults << fault
|
86
87
|
output_progress(fault.single_character_display, fault_color(fault))
|
87
|
-
@
|
88
|
+
@n_omissions += 1 if fault.is_a?(Omission)
|
89
|
+
@already_outputted = true if fault.critical?
|
88
90
|
end
|
89
91
|
|
90
92
|
def started(result)
|
@@ -107,7 +109,7 @@ module Test
|
|
107
109
|
output("Finished in #{elapsed_time} seconds.")
|
108
110
|
nl
|
109
111
|
output(@result, result_color)
|
110
|
-
n_tests = @result.run_count
|
112
|
+
n_tests = @result.run_count - @n_omissions
|
111
113
|
if n_tests.zero?
|
112
114
|
pass_percentage = 0
|
113
115
|
else
|
data/lib/test/unit/version.rb
CHANGED
@@ -66,7 +66,7 @@ class TestUnitCollectorDescendant < Test::Unit::TestCase
|
|
66
66
|
collector.filter = [Proc.new {false}, Proc.new {true}]
|
67
67
|
end
|
68
68
|
|
69
|
-
assert_collect(
|
69
|
+
assert_collect(empty_suite) do |collector|
|
70
70
|
collector.filter = [Proc.new {true}, Proc.new {false}]
|
71
71
|
end
|
72
72
|
|
@@ -90,13 +90,11 @@ class TestUnitCollectorDescendant < Test::Unit::TestCase
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
expected = empty_suite
|
94
93
|
suite1 = Test::Unit::TestSuite.new(@test_case1.name)
|
95
94
|
suite1 << @test_case1.new("test_1")
|
96
95
|
suite2 = Test::Unit::TestSuite.new(@test_case2.name)
|
97
96
|
suite2 << @test_case2.new("test_0")
|
98
|
-
|
99
|
-
assert_collect(expected) do |collector|
|
97
|
+
assert_collect(empty_suite) do |collector|
|
100
98
|
filters = [Proc.new {|test| test.method_name == 'test_1' ? true : nil},
|
101
99
|
Proc.new {|test| test.method_name == 'test_0' ? true : nil},
|
102
100
|
Proc.new {false}]
|
data/test/collector/test-load.rb
CHANGED
@@ -196,6 +196,25 @@ EOT
|
|
196
196
|
end
|
197
197
|
end
|
198
198
|
|
199
|
+
setup
|
200
|
+
def setup_sub_git_test_cases
|
201
|
+
@sub_git_test_dir = @sub_test_dir + ".git"
|
202
|
+
@sub_git_test_dir.mkpath
|
203
|
+
|
204
|
+
@sub_git_test_case11 = @sub_git_test_dir + "test_case11.rb"
|
205
|
+
|
206
|
+
@sub_git_test_case11.open("w") do |test_case|
|
207
|
+
test_case.puts(<<-EOT)
|
208
|
+
module #{@temporary_test_cases_module_name}
|
209
|
+
class SubGitTestCase11 < Test::Unit::TestCase
|
210
|
+
def test11
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
EOT
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
199
218
|
def teardown
|
200
219
|
@test_dir.rmtree if @test_dir.exist?
|
201
220
|
::Object.send(:remove_const, @temporary_test_cases_module_name)
|
@@ -72,7 +72,7 @@ module Test
|
|
72
72
|
assert_equal(empty_suite, @c.collect)
|
73
73
|
|
74
74
|
@c.filter = [proc{true}, proc{false}]
|
75
|
-
assert_equal(
|
75
|
+
assert_equal(empty_suite, @c.collect)
|
76
76
|
|
77
77
|
@c.filter = [proc{nil}, proc{false}]
|
78
78
|
assert_equal(empty_suite, @c.collect)
|
@@ -87,10 +87,12 @@ module Test
|
|
87
87
|
assert_equal(expected, @c.collect)
|
88
88
|
|
89
89
|
expected = TestSuite.new(ObjectSpace::NAME)
|
90
|
-
|
91
|
-
|
92
|
-
@c.filter = [proc{|t| t.method_name == 'test_1' ? true : nil},
|
93
|
-
|
90
|
+
TestSuite.new(@tc1.name) << @tc1.new('test_1')
|
91
|
+
TestSuite.new(@tc2.name) << @tc2.new('test_0')
|
92
|
+
@c.filter = [proc{|t| t.method_name == 'test_1' ? true : nil},
|
93
|
+
proc{|t| t.method_name == 'test_0' ? true : nil},
|
94
|
+
proc{false}]
|
95
|
+
assert_equal(empty_suite, @c.collect)
|
94
96
|
end
|
95
97
|
end
|
96
98
|
end
|
data/test/test-testcase.rb
CHANGED
@@ -7,6 +7,7 @@ require 'test/unit'
|
|
7
7
|
module Test
|
8
8
|
module Unit
|
9
9
|
class TestTestCase < TestCase
|
10
|
+
self.test_order = :random
|
10
11
|
def test_creation
|
11
12
|
tc = Class.new(TestCase) do
|
12
13
|
def test_with_arguments(arg1, arg2)
|
@@ -469,52 +470,68 @@ module Test
|
|
469
470
|
end
|
470
471
|
|
471
472
|
def test_defined_order
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
end
|
473
|
+
test_case = Class.new(Test::Unit::TestCase) do
|
474
|
+
def test_z
|
475
|
+
end
|
476
476
|
|
477
|
-
|
478
|
-
|
477
|
+
def test_1
|
478
|
+
end
|
479
479
|
|
480
|
-
|
481
|
-
end
|
480
|
+
def test_a
|
482
481
|
end
|
482
|
+
end
|
483
483
|
|
484
|
-
|
485
|
-
|
484
|
+
assert_equal(["test_1", "test_a", "test_z"],
|
485
|
+
test_case.suite.tests.collect {|test| test.method_name})
|
486
486
|
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
end
|
487
|
+
test_case.test_order = :defined
|
488
|
+
assert_equal(["test_z", "test_1", "test_a"],
|
489
|
+
test_case.suite.tests.collect {|test| test.method_name})
|
491
490
|
end
|
492
491
|
|
493
492
|
def test_declarative_style
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
end
|
493
|
+
test_case = Class.new(Test::Unit::TestCase) do
|
494
|
+
test "declarative style test definition" do
|
495
|
+
end
|
498
496
|
|
499
|
-
|
500
|
-
|
497
|
+
test "include parenthesis" do
|
498
|
+
end
|
501
499
|
|
502
|
-
|
503
|
-
end
|
500
|
+
test "1 + 2 = 3" do
|
504
501
|
end
|
502
|
+
end
|
505
503
|
|
506
|
-
|
504
|
+
test_case.test_order = :defined
|
507
505
|
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
506
|
+
assert_equal(["test_declarative_style_test_definition",
|
507
|
+
"test_include_parenthesis",
|
508
|
+
"test_1_2_3"],
|
509
|
+
test_case.suite.tests.collect {|test| test.method_name})
|
510
|
+
|
511
|
+
assert_equal(["declarative style test definition",
|
512
|
+
"include parenthesis",
|
513
|
+
"1 + 2 = 3"],
|
514
|
+
test_case.suite.tests.collect {|test| test.description})
|
515
|
+
end
|
516
|
+
|
517
|
+
def test_redefine_method
|
518
|
+
test_case = Class.new(Test::Unit::TestCase) do
|
519
|
+
def test_name
|
520
|
+
end
|
521
|
+
alias_method :test_name2, :test_name
|
512
522
|
|
513
|
-
|
514
|
-
|
515
|
-
"1 + 2 = 3"],
|
516
|
-
test_case.suite.tests.collect {|test| test.description})
|
523
|
+
def test_name
|
524
|
+
end
|
517
525
|
end
|
526
|
+
|
527
|
+
suite = test_case.suite
|
528
|
+
assert_equal(["test_name", "test_name2"],
|
529
|
+
suite.tests.collect {|test| test.method_name})
|
530
|
+
result = TestResult.new
|
531
|
+
suite.run(result) {}
|
532
|
+
assert_equal("2 tests, 0 assertions, 0 failures, " +
|
533
|
+
"0 errors, 0 pendings, 0 omissions, 1 notifications",
|
534
|
+
result.summary)
|
518
535
|
end
|
519
536
|
|
520
537
|
private
|
@@ -522,13 +539,6 @@ module Test
|
|
522
539
|
add_assertion
|
523
540
|
raise AssertionFailedError.new(message) unless passed
|
524
541
|
end
|
525
|
-
|
526
|
-
def keep_test_order
|
527
|
-
order = TestCase.test_order
|
528
|
-
yield
|
529
|
-
ensure
|
530
|
-
TestCase.test_order = order
|
531
|
-
end
|
532
542
|
end
|
533
543
|
end
|
534
544
|
end
|
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: 2.0.
|
4
|
+
version: 2.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
@@ -10,9 +10,29 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2010-
|
13
|
+
date: 2010-03-09 00:00:00 +09:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rubyforge
|
18
|
+
type: :development
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 2.0.4
|
25
|
+
version:
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: gemcutter
|
28
|
+
type: :development
|
29
|
+
version_requirement:
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.5.0
|
35
|
+
version:
|
16
36
|
- !ruby/object:Gem::Dependency
|
17
37
|
name: hoe
|
18
38
|
type: :development
|
@@ -21,7 +41,7 @@ dependencies:
|
|
21
41
|
requirements:
|
22
42
|
- - ">="
|
23
43
|
- !ruby/object:Gem::Version
|
24
|
-
version: 2.
|
44
|
+
version: 2.5.0
|
25
45
|
version:
|
26
46
|
description: |-
|
27
47
|
Test::Unit 2.x - Improved version of Test::Unit bundled in
|