test-unit 3.4.5 → 3.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/text/news.md +10 -0
- data/lib/test/unit/assertion-failed-error.rb +35 -0
- data/lib/test/unit/autorunner.rb +13 -1
- data/lib/test/unit/collector/descendant.rb +1 -0
- data/lib/test/unit/collector/dir.rb +4 -2
- data/lib/test/unit/collector/load.rb +2 -0
- data/lib/test/unit/collector/objectspace.rb +1 -0
- data/lib/test/unit/collector.rb +31 -0
- data/lib/test/unit/testcase.rb +30 -0
- data/lib/test/unit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f8ed035b9be7e1b2a3c92d767c8007d46e867131d7385e54b2096170d658226
|
4
|
+
data.tar.gz: 426871e1614d48c08de963123fb36654da1abf611d1b3ca005a952fc4c4dd66b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ee530d7c01b91eee8ca71c62f6086ea3875c4fcf057ef5cd514896d633d4331f24ca5964a338622f7a80c747358cb85d4ae3996d30687b4f5f37d657d93f658
|
7
|
+
data.tar.gz: f0707e81dd0fa2f368759d0a61f1fae9dd764aeeb12e7e8c2cfd5b5f5fc0de76b13821154353fa1045b441a2a58f1d689a9530032c130ede1d3058d29f6d760b
|
data/doc/text/news.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 3.4.6 - 2021-09-11 {#version-3-4-6}
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* Added support for tests that use Ractor. Use
|
8
|
+
`Test::Unit::TestCase.ractor` to declare that these tests use
|
9
|
+
Ractor.
|
10
|
+
|
11
|
+
* Added `--debug-on-failure` option.
|
12
|
+
|
3
13
|
## 3.4.5 - 2021-09-04 {#version-3-4-5}
|
4
14
|
|
5
15
|
### Improvements
|
@@ -9,6 +9,17 @@ module Test
|
|
9
9
|
|
10
10
|
# Thrown by Test::Unit::Assertions when an assertion fails.
|
11
11
|
class AssertionFailedError < StandardError
|
12
|
+
class << self
|
13
|
+
@debug_on_failure = false
|
14
|
+
def debug_on_failure=(boolean)
|
15
|
+
@debug_on_failure = boolean
|
16
|
+
end
|
17
|
+
|
18
|
+
def debug_on_failure?
|
19
|
+
@debug_on_failure
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
12
23
|
attr_accessor :expected, :actual, :user_message
|
13
24
|
attr_accessor :inspected_expected, :inspected_actual
|
14
25
|
def initialize(message=nil, options=nil)
|
@@ -19,6 +30,30 @@ module Test
|
|
19
30
|
@inspected_actual = options[:inspected_actual]
|
20
31
|
@user_message = options[:user_message]
|
21
32
|
super(message)
|
33
|
+
debug_on_failure
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
def debug_on_failure
|
38
|
+
return unless self.class.debug_on_failure?
|
39
|
+
|
40
|
+
begin
|
41
|
+
require "debug"
|
42
|
+
rescue LoadError
|
43
|
+
return
|
44
|
+
end
|
45
|
+
|
46
|
+
return unless binding.respond_to?(:break)
|
47
|
+
|
48
|
+
frames = caller(0)
|
49
|
+
pre = nil
|
50
|
+
Util::BacktraceFilter.filter_backtrace(frames).each do |location|
|
51
|
+
frame_index = frames.index(location)
|
52
|
+
next if frame_index.nil?
|
53
|
+
pre = "frame #{frame_index}"
|
54
|
+
break
|
55
|
+
end
|
56
|
+
binding.break(pre: pre)
|
22
57
|
end
|
23
58
|
end
|
24
59
|
end
|
data/lib/test/unit/autorunner.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require "English"
|
2
|
+
require "optparse"
|
2
3
|
|
3
4
|
require "test/unit/color-scheme"
|
4
5
|
require "test/unit/priority"
|
5
6
|
require "test/unit/attribute-matcher"
|
6
7
|
require "test/unit/testcase"
|
7
|
-
require "optparse"
|
8
8
|
|
9
9
|
module Test
|
10
10
|
module Unit
|
@@ -144,6 +144,7 @@ module Test
|
|
144
144
|
attr_accessor :pattern, :exclude, :base, :workdir
|
145
145
|
attr_accessor :color_scheme, :listeners
|
146
146
|
attr_writer :stop_on_failure
|
147
|
+
attr_writer :debug_on_failure
|
147
148
|
attr_writer :runner, :collector
|
148
149
|
|
149
150
|
def initialize(standalone)
|
@@ -159,6 +160,7 @@ module Test
|
|
159
160
|
@workdir = nil
|
160
161
|
@listeners = []
|
161
162
|
@stop_on_failure = false
|
163
|
+
@debug_on_failure = false
|
162
164
|
config_file = "test-unit.yml"
|
163
165
|
if File.exist?(config_file)
|
164
166
|
load_config(config_file)
|
@@ -172,6 +174,10 @@ module Test
|
|
172
174
|
@stop_on_failure
|
173
175
|
end
|
174
176
|
|
177
|
+
def debug_on_failure?
|
178
|
+
@debug_on_failure
|
179
|
+
end
|
180
|
+
|
175
181
|
def prepare
|
176
182
|
PREPARE_HOOKS.each do |handler|
|
177
183
|
handler.call(self)
|
@@ -381,6 +387,12 @@ module Test
|
|
381
387
|
@stop_on_failure = boolean
|
382
388
|
end
|
383
389
|
|
390
|
+
o.on("--[no-]debug-on-failure",
|
391
|
+
"Run debugger if available on failure",
|
392
|
+
"(#{AssertionFailedError.debug_on_failure?})") do |boolean|
|
393
|
+
AssertionFailedError.debug_on_failure = boolean
|
394
|
+
end
|
395
|
+
|
384
396
|
ADDITIONAL_OPTIONS.each do |option_builder|
|
385
397
|
option_builder.call(self, o)
|
386
398
|
end
|
@@ -25,9 +25,9 @@ module Test
|
|
25
25
|
basedir = @base
|
26
26
|
$:.push(basedir) if basedir
|
27
27
|
if(from.empty?)
|
28
|
-
recursive_collect('.', find_test_cases)
|
28
|
+
suite = recursive_collect('.', find_test_cases)
|
29
29
|
elsif(from.size == 1)
|
30
|
-
recursive_collect(from.first, find_test_cases)
|
30
|
+
suite = recursive_collect(from.first, find_test_cases)
|
31
31
|
else
|
32
32
|
suites = []
|
33
33
|
from.each do |f|
|
@@ -38,6 +38,8 @@ module Test
|
|
38
38
|
sort(suites).each{|s| suite << s}
|
39
39
|
suite
|
40
40
|
end
|
41
|
+
adjust_ractor_tests(suite)
|
42
|
+
suite
|
41
43
|
ensure
|
42
44
|
$:.delete_at($:.rindex(basedir)) if basedir
|
43
45
|
end
|
data/lib/test/unit/collector.rb
CHANGED
@@ -68,6 +68,37 @@ module Test
|
|
68
68
|
suite << sub_suite
|
69
69
|
end
|
70
70
|
end
|
71
|
+
|
72
|
+
def adjust_ractor_tests(suite)
|
73
|
+
return if suite.nil?
|
74
|
+
ractor_suites = extract_ractor_tests(suite)
|
75
|
+
ractor_suites.each do |ractor_suite|
|
76
|
+
suite << ractor_suite
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def extract_ractor_tests(suite)
|
81
|
+
ractor_suites = []
|
82
|
+
ractor_tests = []
|
83
|
+
suite.tests.each do |test|
|
84
|
+
case test
|
85
|
+
when TestSuite
|
86
|
+
ractor_suites.concat(extract_ractor_tests(test))
|
87
|
+
else
|
88
|
+
next unless test[:ractor]
|
89
|
+
ractor_tests << test
|
90
|
+
end
|
91
|
+
end
|
92
|
+
unless ractor_tests.empty?
|
93
|
+
suite.delete_tests(ractor_tests)
|
94
|
+
ractor_suite = TestSuite.new(suite.name, suite.test_case)
|
95
|
+
ractor_tests.each do |ractor_test|
|
96
|
+
ractor_suite << ractor_test
|
97
|
+
end
|
98
|
+
ractor_suites << ractor_suite
|
99
|
+
end
|
100
|
+
ractor_suites
|
101
|
+
end
|
71
102
|
end
|
72
103
|
end
|
73
104
|
end
|
data/lib/test/unit/testcase.rb
CHANGED
@@ -351,6 +351,36 @@ module Test
|
|
351
351
|
attribute(:description, value, {}, *targets)
|
352
352
|
end
|
353
353
|
|
354
|
+
# Declares that the following test uses Ractor.
|
355
|
+
#
|
356
|
+
# Tests that use Ractor are executed at the end. Because multi
|
357
|
+
# Ractor mode is enabled in the current process and it's not
|
358
|
+
# disabled even when only one Ractor is running after running
|
359
|
+
# a test that uses Ractor on Ruby 3.0. It will be solved in
|
360
|
+
# Ruby 3.1.
|
361
|
+
#
|
362
|
+
# This is implemented by setting the `:ractor` attribute of
|
363
|
+
# the test to `true`.
|
364
|
+
#
|
365
|
+
# @param options [Hash] See {Attribute::ClassMethods#attribute}
|
366
|
+
# for details.
|
367
|
+
#
|
368
|
+
# @return [void]
|
369
|
+
#
|
370
|
+
# @example Declares that test_do_something_with_ractor uses Ractor
|
371
|
+
#
|
372
|
+
# ractor
|
373
|
+
# def test_do_something_with_ractor
|
374
|
+
# Ractor.new do
|
375
|
+
# # ...
|
376
|
+
# end
|
377
|
+
# end
|
378
|
+
#
|
379
|
+
# @since 3.4.6
|
380
|
+
def ractor(options={})
|
381
|
+
attribute(:ractor, true, options)
|
382
|
+
end
|
383
|
+
|
354
384
|
# Defines a sub test case.
|
355
385
|
#
|
356
386
|
# This is a syntax sugar. The both of the following codes are
|
data/lib/test/unit/version.rb
CHANGED
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.4.
|
4
|
+
version: 3.4.6
|
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: 2021-09-
|
12
|
+
date: 2021-09-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: power_assert
|