test-unit 2.4.8 → 2.4.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/test-unit.rb +11 -1
- data/lib/test/unit.rb +8 -4
- data/lib/test/unit/assertions.rb +24 -1
- data/lib/test/unit/autorunner.rb +35 -17
- data/lib/test/unit/color-scheme.rb +1 -1
- data/lib/test/unit/testcase.rb +1 -0
- data/lib/test/unit/ui/console/testrunner.rb +3 -3
- data/lib/test/unit/ui/testrunner.rb +1 -1
- data/lib/test/unit/ui/testrunnermediator.rb +9 -5
- data/lib/test/unit/version.rb +1 -1
- data/test/test-assertions.rb +15 -0
- data/test/ui/test_testrunmediator.rb +1 -1
- metadata +53 -77
data/lib/test-unit.rb
CHANGED
@@ -1,3 +1,13 @@
|
|
1
1
|
module Test
|
2
|
-
|
2
|
+
module Unit
|
3
|
+
autoload :TestCase, "test/unit/testcase"
|
4
|
+
autoload :AutoRunner, "test/unit/autorunner"
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
# experimental. It is for "ruby -rtest-unit -e run test/test_*.rb".
|
9
|
+
# Is this API OK or dirty?
|
10
|
+
def run
|
11
|
+
self.class.send(:undef_method, :run)
|
12
|
+
require "test/unit"
|
3
13
|
end
|
data/lib/test/unit.rb
CHANGED
@@ -310,19 +310,23 @@ module Test # :nodoc:
|
|
310
310
|
module Unit
|
311
311
|
# Set true when Test::Unit has run. If set to true Test::Unit
|
312
312
|
# will not automatically run at exit.
|
313
|
-
|
314
|
-
|
313
|
+
#
|
314
|
+
# @deprecated Use Test::Unit::AutoRunner.need_auto_run= instead.
|
315
|
+
def self.run=(have_run)
|
316
|
+
AutoRunner.need_auto_run = (not have_run)
|
315
317
|
end
|
316
318
|
|
317
319
|
# Already tests have run?
|
320
|
+
#
|
321
|
+
# @deprecated Use Test::Unit::AutoRunner.need_auto_run? instead.
|
318
322
|
def self.run?
|
319
|
-
|
323
|
+
not AutoRunner.need_auto_run?
|
320
324
|
end
|
321
325
|
end
|
322
326
|
end
|
323
327
|
|
324
328
|
at_exit do
|
325
|
-
|
329
|
+
if $!.nil? and Test::Unit::AutoRunner.need_auto_run?
|
326
330
|
exit Test::Unit::AutoRunner.run
|
327
331
|
end
|
328
332
|
end
|
data/lib/test/unit/assertions.rb
CHANGED
@@ -1755,7 +1755,30 @@ EOT
|
|
1755
1755
|
def result(parameters)
|
1756
1756
|
raise "The number of parameters does not match the number of substitutions." if(parameters.size != count)
|
1757
1757
|
params = parameters.dup
|
1758
|
-
|
1758
|
+
expanded_template = ""
|
1759
|
+
@parts.each do |part|
|
1760
|
+
if part == '?'
|
1761
|
+
encoding_safe_concat(expanded_template, params.shift)
|
1762
|
+
else
|
1763
|
+
expanded_template << part.gsub(/\\\?/m, '?')
|
1764
|
+
end
|
1765
|
+
end
|
1766
|
+
expanded_template
|
1767
|
+
end
|
1768
|
+
|
1769
|
+
private
|
1770
|
+
if Object.const_defined?(:Encoding)
|
1771
|
+
def encoding_safe_concat(buffer, parameter)
|
1772
|
+
if Encoding.compatible?(buffer.encoding, parameter.encoding)
|
1773
|
+
buffer << parameter
|
1774
|
+
else
|
1775
|
+
buffer << parameter.dup.force_encoding(buffer.encoding)
|
1776
|
+
end
|
1777
|
+
end
|
1778
|
+
else
|
1779
|
+
def encoding_safe_concat(buffer, parameter)
|
1780
|
+
buffer << parameter
|
1781
|
+
end
|
1759
1782
|
end
|
1760
1783
|
end
|
1761
1784
|
|
data/lib/test/unit/autorunner.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'test/unit/color-scheme'
|
2
|
+
require 'test/unit/priority'
|
2
3
|
require 'optparse'
|
3
4
|
|
4
5
|
module Test
|
@@ -48,22 +49,31 @@ module Test
|
|
48
49
|
def prepare(hook=Proc.new)
|
49
50
|
PREPARE_HOOKS << hook
|
50
51
|
end
|
51
|
-
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
53
|
+
def run(force_standalone=false, default_dir=nil, argv=ARGV, &block)
|
54
|
+
r = new(force_standalone || standalone?, &block)
|
55
|
+
r.base = default_dir
|
56
|
+
r.prepare
|
57
|
+
r.process_args(argv)
|
58
|
+
r.run
|
59
|
+
end
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
61
|
+
def standalone?
|
62
|
+
return false unless("-e" == $0)
|
63
|
+
ObjectSpace.each_object(Class) do |klass|
|
64
|
+
return false if(klass < TestCase)
|
65
|
+
end
|
66
|
+
true
|
67
|
+
end
|
68
|
+
|
69
|
+
@@need_auto_run = true
|
70
|
+
def need_auto_run?
|
71
|
+
@@need_auto_run
|
72
|
+
end
|
73
|
+
|
74
|
+
def need_auto_run=(need)
|
75
|
+
@@need_auto_run = need
|
65
76
|
end
|
66
|
-
true
|
67
77
|
end
|
68
78
|
|
69
79
|
register_collector(:descendant) do |auto_runner|
|
@@ -117,7 +127,6 @@ module Test
|
|
117
127
|
attr_writer :runner, :collector
|
118
128
|
|
119
129
|
def initialize(standalone)
|
120
|
-
Unit.run = true
|
121
130
|
@standalone = standalone
|
122
131
|
@runner = default_runner
|
123
132
|
@collector = default_collector
|
@@ -144,7 +153,6 @@ module Test
|
|
144
153
|
end
|
145
154
|
|
146
155
|
def process_args(args=ARGV)
|
147
|
-
args = args.dup
|
148
156
|
begin
|
149
157
|
args.unshift(*@default_arguments)
|
150
158
|
options.order!(args) {|arg| @to_run << arg}
|
@@ -357,6 +365,7 @@ module Test
|
|
357
365
|
end
|
358
366
|
|
359
367
|
def run
|
368
|
+
self.class.need_auto_run = false
|
360
369
|
suite = @collector[self]
|
361
370
|
return false if suite.nil?
|
362
371
|
return true if suite.empty?
|
@@ -365,8 +374,9 @@ module Test
|
|
365
374
|
@runner_options[:color_scheme] ||= @color_scheme
|
366
375
|
@runner_options[:listeners] ||= []
|
367
376
|
@runner_options[:listeners].concat(@listeners)
|
368
|
-
|
369
|
-
|
377
|
+
change_work_directory do
|
378
|
+
runner.run(suite, @runner_options).passed?
|
379
|
+
end
|
370
380
|
end
|
371
381
|
|
372
382
|
def load_config(file)
|
@@ -416,6 +426,14 @@ module Test
|
|
416
426
|
file = global_config_file
|
417
427
|
load_config(file) if file and File.exist?(file)
|
418
428
|
end
|
429
|
+
|
430
|
+
def change_work_directory(&block)
|
431
|
+
if @workdir
|
432
|
+
Dir.chdir(@workdir, &block)
|
433
|
+
else
|
434
|
+
yield
|
435
|
+
end
|
436
|
+
end
|
419
437
|
end
|
420
438
|
end
|
421
439
|
end
|
data/lib/test/unit/testcase.rb
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
|
9
9
|
require 'test/unit/color-scheme'
|
10
10
|
require 'test/unit/code-snippet-fetcher'
|
11
|
+
require 'test/unit/diff'
|
11
12
|
require 'test/unit/ui/testrunner'
|
12
13
|
require 'test/unit/ui/testrunnermediator'
|
13
14
|
require 'test/unit/ui/console/outputlevel'
|
@@ -168,8 +169,7 @@ module Test
|
|
168
169
|
end
|
169
170
|
|
170
171
|
def output_fault_in_detail(fault)
|
171
|
-
if
|
172
|
-
fault.inspected_expected and fault.inspected_actual
|
172
|
+
if fault.is_a?(Failure)
|
173
173
|
output_single(fault.label, fault_color(fault))
|
174
174
|
output(":")
|
175
175
|
output(fault.test_name)
|
@@ -429,7 +429,7 @@ module Test
|
|
429
429
|
def guess_color_availability
|
430
430
|
return false unless @output.tty?
|
431
431
|
case ENV["TERM"]
|
432
|
-
when /term(?:-color)?\z/, "screen"
|
432
|
+
when /term(?:-(?:256)?color)?\z/, "screen"
|
433
433
|
true
|
434
434
|
else
|
435
435
|
return true if ENV["EMACS"] == "t"
|
@@ -29,8 +29,8 @@ module Test
|
|
29
29
|
|
30
30
|
# Runs the suite the TestRunnerMediator was created
|
31
31
|
# with.
|
32
|
-
def
|
33
|
-
|
32
|
+
def run
|
33
|
+
AutoRunner.need_auto_run = false
|
34
34
|
|
35
35
|
result = create_result
|
36
36
|
finished_listener = result.add_listener(TestResult::FINISHED) do |*args|
|
@@ -51,9 +51,7 @@ module Test
|
|
51
51
|
notify_listeners(RESET, @suite.size)
|
52
52
|
notify_listeners(STARTED, result)
|
53
53
|
|
54
|
-
|
55
|
-
notify_listeners(channel, value)
|
56
|
-
end
|
54
|
+
run_suite(result)
|
57
55
|
ensure
|
58
56
|
elapsed_time = Time.now - start_time
|
59
57
|
result.remove_listener(TestResult::FAULT, fault_listener)
|
@@ -80,6 +78,12 @@ module Test
|
|
80
78
|
yield
|
81
79
|
Time.now - begin_time
|
82
80
|
end
|
81
|
+
|
82
|
+
def run_suite(result)
|
83
|
+
@suite.run(result) do |channel, value|
|
84
|
+
notify_listeners(channel, value)
|
85
|
+
end
|
86
|
+
end
|
83
87
|
end
|
84
88
|
end
|
85
89
|
end
|
data/lib/test/unit/version.rb
CHANGED
data/test/test-assertions.rb
CHANGED
@@ -1907,5 +1907,20 @@ EOM
|
|
1907
1907
|
end
|
1908
1908
|
end
|
1909
1909
|
end
|
1910
|
+
|
1911
|
+
class TestTemplate < Test::Unit::TestCase
|
1912
|
+
def test_incompatible_encoding_by_diff
|
1913
|
+
need_encoding
|
1914
|
+
assert_raise(AssertionFailedError) do
|
1915
|
+
assert_equal("UTF-8の日本語\n" * 3,
|
1916
|
+
("Shift_JISの日本語\n" * 3).force_encoding("ASCII-8BIT"))
|
1917
|
+
end
|
1918
|
+
end
|
1919
|
+
|
1920
|
+
private
|
1921
|
+
def need_encoding
|
1922
|
+
omit("need Encoding") unless Object.const_defined?(:Encoding)
|
1923
|
+
end
|
1924
|
+
end
|
1910
1925
|
end
|
1911
1926
|
end
|
metadata
CHANGED
@@ -1,81 +1,66 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-unit
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.4.9
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 4
|
9
|
-
- 8
|
10
|
-
version: 2.4.8
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Kouhei Sutou
|
14
9
|
- Haruka Yoshihara
|
15
10
|
autorequire:
|
16
11
|
bindir: bin
|
17
12
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
- !ruby/object:Gem::Dependency
|
22
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
-
none: false
|
24
|
-
requirements:
|
25
|
-
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
hash: 3
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
version: "0"
|
13
|
+
date: 2012-06-03 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
31
16
|
name: rake
|
32
|
-
|
33
|
-
type: :development
|
34
|
-
requirement: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
version_requirements: &id002 !ruby/object:Gem::Requirement
|
17
|
+
requirement: &3359000 !ruby/object:Gem::Requirement
|
37
18
|
none: false
|
38
|
-
requirements:
|
39
|
-
- -
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
segments:
|
43
|
-
- 0
|
44
|
-
version: "0"
|
45
|
-
name: yard
|
46
|
-
prerelease: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
47
23
|
type: :development
|
48
|
-
|
49
|
-
|
50
|
-
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *3359000
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: yard
|
28
|
+
requirement: &3371220 !ruby/object:Gem::Requirement
|
51
29
|
none: false
|
52
|
-
requirements:
|
53
|
-
- -
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
|
56
|
-
|
57
|
-
- 0
|
58
|
-
version: "0"
|
59
|
-
name: jeweler
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
60
35
|
prerelease: false
|
36
|
+
version_requirements: *3371220
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: jeweler
|
39
|
+
requirement: &3367460 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
61
45
|
type: :development
|
62
|
-
|
63
|
-
|
64
|
-
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *3367460
|
48
|
+
description: ! 'Ruby 1.9.x bundles minitest not Test::Unit. Test::Unit
|
49
|
+
|
65
50
|
bundled in Ruby 1.8.x had not been improved but unbundled
|
51
|
+
|
66
52
|
Test::Unit (test-unit) is improved actively.
|
67
53
|
|
68
|
-
|
54
|
+
'
|
55
|
+
email:
|
69
56
|
- kou@cozmixng.org
|
70
57
|
- yoshihara@clear-code.com
|
71
58
|
executables: []
|
72
|
-
|
73
59
|
extensions: []
|
74
|
-
|
75
|
-
extra_rdoc_files:
|
60
|
+
extra_rdoc_files:
|
76
61
|
- README.textile
|
77
62
|
- TODO
|
78
|
-
files:
|
63
|
+
files:
|
79
64
|
- COPYING
|
80
65
|
- GPL
|
81
66
|
- PSFL
|
@@ -164,37 +149,28 @@ files:
|
|
164
149
|
- test/util/test_observable.rb
|
165
150
|
- test/util/test_procwrapper.rb
|
166
151
|
homepage: http://test-unit.rubyforge.org/
|
167
|
-
licenses:
|
152
|
+
licenses:
|
168
153
|
- Ruby's and PSFL (lib/test/unit/diff.rb)
|
169
154
|
post_install_message:
|
170
155
|
rdoc_options: []
|
171
|
-
|
172
|
-
require_paths:
|
156
|
+
require_paths:
|
173
157
|
- lib
|
174
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
175
159
|
none: false
|
176
|
-
requirements:
|
177
|
-
- -
|
178
|
-
- !ruby/object:Gem::Version
|
179
|
-
|
180
|
-
|
181
|
-
- 0
|
182
|
-
version: "0"
|
183
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - ! '>='
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
165
|
none: false
|
185
|
-
requirements:
|
186
|
-
- -
|
187
|
-
- !ruby/object:Gem::Version
|
188
|
-
|
189
|
-
segments:
|
190
|
-
- 0
|
191
|
-
version: "0"
|
166
|
+
requirements:
|
167
|
+
- - ! '>='
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
192
170
|
requirements: []
|
193
|
-
|
194
171
|
rubyforge_project: test-unit
|
195
|
-
rubygems_version: 1.8.
|
172
|
+
rubygems_version: 1.8.11
|
196
173
|
signing_key:
|
197
174
|
specification_version: 3
|
198
175
|
summary: test-unit - Improved version of Test::Unit bundled in Ruby 1.8.x.
|
199
176
|
test_files: []
|
200
|
-
|