test-unit 3.7.7 → 3.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/doc/text/news.md +111 -0
- data/lib/test/unit/assertions.rb +68 -1
- data/lib/test/unit/autorunner.rb +14 -6
- data/lib/test/unit/collector/descendant.rb +2 -2
- data/lib/test/unit/collector/load.rb +53 -7
- data/lib/test/unit/collector.rb +2 -3
- data/lib/test/unit/color-scheme.rb +70 -66
- data/lib/test/unit/color.rb +3 -1
- data/lib/test/unit/diff.rb +2 -2
- data/lib/test/unit/error.rb +15 -4
- data/lib/test/unit/failure.rb +1 -1
- data/lib/test/unit/fixture.rb +2 -2
- data/lib/test/unit/omission.rb +22 -0
- data/lib/test/unit/priority.rb +2 -1
- data/lib/test/unit/process-test-result.rb +6 -0
- data/lib/test/unit/process-worker.rb +11 -2
- data/lib/test/unit/sub-test-result.rb +6 -0
- data/lib/test/unit/test-suite-creator.rb +3 -2
- data/lib/test/unit/test-suite-process-runner.rb +14 -3
- data/lib/test/unit/test-suite-runner.rb +4 -4
- data/lib/test/unit/test-suite-thread-runner.rb +1 -1
- data/lib/test/unit/testcase.rb +117 -13
- data/lib/test/unit/testresult.rb +11 -4
- data/lib/test/unit/testsuite.rb +15 -5
- data/lib/test/unit/ui/testrunnermediator.rb +3 -3
- data/lib/test/unit/util/observable.rb +1 -1
- data/lib/test/unit/util/output.rb +41 -10
- data/lib/test/unit/version.rb +1 -1
- data/lib/test/unit/worker-context.rb +7 -0
- data/lib/test/unit.rb +25 -0
- 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: 8c454878748e3087410a9aad9bdccd9593c464b63d8bc2810940ec6450195506
|
|
4
|
+
data.tar.gz: 5ec26989d0935c9780f5934c071e60e0bc5b26b071ea0908c2f0cd10d4adccef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 71f9fc947de550dd376fc8cc33e452948c04aa9f19a6c53f6cfd274fd0a2c795d9fd82fc34916d4e4830d9fc3e052f7eacf692e2b6a77bf02c5665df339e3f8d
|
|
7
|
+
data.tar.gz: 2b834726482fbe9b49b3ba5c32e9953b370fe9714c93186054f588c797bfd40aa0e1cb0009eca6781063a251bd480af9a03f386121096333a0d80fa862b31a76
|
data/doc/text/news.md
CHANGED
|
@@ -1,5 +1,116 @@
|
|
|
1
1
|
# News
|
|
2
2
|
|
|
3
|
+
## 3.7.9 - 2026-11-24 {#version-3-7-9}
|
|
4
|
+
|
|
5
|
+
### Improvements
|
|
6
|
+
|
|
7
|
+
* Added support for running test files in Ruby::Box. test-unit
|
|
8
|
+
loads each test file with suffix `.box.rb` (e.g.
|
|
9
|
+
`test_xxx.box.rb`) in its own Ruby::Box. So monkey patches in the
|
|
10
|
+
file don't affect other test files. You need Ruby 4.1 or later
|
|
11
|
+
with `RUBY_BOX=1`. The `--parallel` option isn't supported for
|
|
12
|
+
these files yet.
|
|
13
|
+
* GH-382
|
|
14
|
+
* GH-384
|
|
15
|
+
* GH-385
|
|
16
|
+
* GH-386
|
|
17
|
+
* GH-388
|
|
18
|
+
* GH-389
|
|
19
|
+
* Patch by Satoshi Tagomori
|
|
20
|
+
|
|
21
|
+
* Added Minitest compatible methods. You can use them when you
|
|
22
|
+
migrate your tests from Minitest. They also make test-unit easier
|
|
23
|
+
to use with Active Support.
|
|
24
|
+
* `skip`: Omits the rest of the test like `omit`.
|
|
25
|
+
* `assertions` and `assertions=`: Reads and writes the number of
|
|
26
|
+
assertions in the test.
|
|
27
|
+
* `capture_io`: Same as `capture_output`.
|
|
28
|
+
* `assert_output`: Asserts the output to `$stdout` and `$stderr`
|
|
29
|
+
in the block.
|
|
30
|
+
* `skipped?`: Returns whether the test is omitted.
|
|
31
|
+
* `error?`: Returns whether an error occurred in the test.
|
|
32
|
+
* `assert_silent`: Asserts no output to `$stdout` and `$stderr`
|
|
33
|
+
in the block.
|
|
34
|
+
* GH-390
|
|
35
|
+
* GH-392
|
|
36
|
+
* GH-394
|
|
37
|
+
* GH-395
|
|
38
|
+
* GH-396
|
|
39
|
+
* GH-397
|
|
40
|
+
* GH-399
|
|
41
|
+
* GH-400
|
|
42
|
+
* Suggested by Akira Matsuda
|
|
43
|
+
|
|
44
|
+
* `capture_output`: Improved thread safety. Calls from multiple
|
|
45
|
+
threads now run one by one.
|
|
46
|
+
* GH-390
|
|
47
|
+
* GH-391
|
|
48
|
+
|
|
49
|
+
* testcase: `Test::Unit::TestCase::FINISHED_OBJECT` listeners can't
|
|
50
|
+
read instance variables added during the test run now. This is a
|
|
51
|
+
preparation for the Ractor based runner.
|
|
52
|
+
* GH-235
|
|
53
|
+
* GH-405
|
|
54
|
+
* Co authored by Naoto Ono
|
|
55
|
+
|
|
56
|
+
* priority: The priority mode now reads `$0` when
|
|
57
|
+
`test/unit/priority.rb` is loaded. It doesn't use a new value
|
|
58
|
+
assigned to `$0` after that. This is a preparation for the Ractor
|
|
59
|
+
based runner.
|
|
60
|
+
* GH-235
|
|
61
|
+
* GH-406
|
|
62
|
+
* Co authored by Naoto Ono
|
|
63
|
+
|
|
64
|
+
* color-scheme: `Test::Unit::ColorScheme.default` now returns a new
|
|
65
|
+
object every time. If you change the returned object, the next
|
|
66
|
+
call doesn't return your change. This is a preparation for the
|
|
67
|
+
Ractor based runner.
|
|
68
|
+
* GH-235
|
|
69
|
+
* GH-408
|
|
70
|
+
* Co authored by Naoto Ono
|
|
71
|
+
|
|
72
|
+
* Added the `--notify-no-assertions` option. It notifies you of
|
|
73
|
+
passed tests without assertions. Such tests may verify nothing.
|
|
74
|
+
This is disabled by default. You can also enable it per test case
|
|
75
|
+
by `self.notify_no_assertions = true`.
|
|
76
|
+
* GH-390
|
|
77
|
+
* GH-403
|
|
78
|
+
|
|
79
|
+
* parallel: Added `ractor` to the `--parallel` option. This is a
|
|
80
|
+
preparation. The Ractor based runner isn't available yet.
|
|
81
|
+
* GH-235
|
|
82
|
+
* GH-410
|
|
83
|
+
* Co authored by Naoto Ono
|
|
84
|
+
|
|
85
|
+
### Thanks
|
|
86
|
+
|
|
87
|
+
* Satoshi Tagomori
|
|
88
|
+
* Akira Matsuda
|
|
89
|
+
* Naoto Ono
|
|
90
|
+
|
|
91
|
+
## 3.7.8 - 2026-06-05 {#version-3-7-8}
|
|
92
|
+
|
|
93
|
+
### Improvements
|
|
94
|
+
|
|
95
|
+
* parallel: process: Improved performance on Windows.
|
|
96
|
+
* GH-368
|
|
97
|
+
|
|
98
|
+
* Improved compatibility with Ruby::Box on `$!`.
|
|
99
|
+
* GH-370
|
|
100
|
+
* Patch by MATSUMOTO Katsuyoshi
|
|
101
|
+
|
|
102
|
+
* doc: Added a process option in parallel options.
|
|
103
|
+
* GH-373
|
|
104
|
+
|
|
105
|
+
* Improved the `-I` option. You can prepend load paths to prioritize
|
|
106
|
+
your development library over the system library.
|
|
107
|
+
* ruby/rubygems#9572
|
|
108
|
+
* GH-375
|
|
109
|
+
|
|
110
|
+
### Thanks
|
|
111
|
+
|
|
112
|
+
* MATSUMOTO Katsuyoshi
|
|
113
|
+
|
|
3
114
|
## 3.7.7 - 2026-01-01 {#version-3-7-7}
|
|
4
115
|
|
|
5
116
|
### Fixes
|
data/lib/test/unit/assertions.rb
CHANGED
|
@@ -58,7 +58,7 @@ module Test
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
# @private
|
|
61
|
-
NOT_SPECIFIED = Object.new
|
|
61
|
+
NOT_SPECIFIED = Object.new.freeze
|
|
62
62
|
|
|
63
63
|
# @overload assert(object, message=nil)
|
|
64
64
|
#
|
|
@@ -1892,6 +1892,63 @@ EOT
|
|
|
1892
1892
|
end
|
|
1893
1893
|
end
|
|
1894
1894
|
|
|
1895
|
+
# Asserts that the block writes the expected output to
|
|
1896
|
+
# `$stdout` and `$stderr`. This is for Minitest compatibility.
|
|
1897
|
+
#
|
|
1898
|
+
# Each expected output is checked by its type:
|
|
1899
|
+
#
|
|
1900
|
+
# * `nil`: It's not checked.
|
|
1901
|
+
# * `Regexp`: It must match the output.
|
|
1902
|
+
# * Others: It must be equal to the output. Use `""` to assert
|
|
1903
|
+
# no output.
|
|
1904
|
+
#
|
|
1905
|
+
# @example Pass patterns
|
|
1906
|
+
# assert_output("Hello\n") {puts("Hello")} # => pass
|
|
1907
|
+
# assert_output(/ell/) {puts("Hello")} # => pass
|
|
1908
|
+
# assert_output(nil, "Error\n") {warn("Error")} # => pass
|
|
1909
|
+
# assert_output("", "") {} # => pass
|
|
1910
|
+
#
|
|
1911
|
+
# @example Failure patterns
|
|
1912
|
+
# assert_output("Hell") {puts("Hello")} # => failure
|
|
1913
|
+
# assert_output(nil, "") {warn("Error")} # => failure
|
|
1914
|
+
#
|
|
1915
|
+
# @param [String, Regexp, nil] stdout The expected output to
|
|
1916
|
+
# `$stdout`.
|
|
1917
|
+
# @param [String, Regexp, nil] stderr The expected output to
|
|
1918
|
+
# `$stderr`.
|
|
1919
|
+
# @yield [] The block that writes output.
|
|
1920
|
+
# @return [void]
|
|
1921
|
+
#
|
|
1922
|
+
# @since 3.7.9
|
|
1923
|
+
def assert_output(stdout=nil, stderr=nil)
|
|
1924
|
+
unless block_given?
|
|
1925
|
+
flunk("assert_output requires a block to capture output.")
|
|
1926
|
+
end
|
|
1927
|
+
_wrap_assertion do
|
|
1928
|
+
actual_stdout, actual_stderr = capture_output do
|
|
1929
|
+
yield
|
|
1930
|
+
end
|
|
1931
|
+
_assert_captured_output(stderr, actual_stderr, "In stderr")
|
|
1932
|
+
_assert_captured_output(stdout, actual_stdout, "In stdout")
|
|
1933
|
+
end
|
|
1934
|
+
end
|
|
1935
|
+
|
|
1936
|
+
# Asserts that the block writes nothing to `$stdout` and
|
|
1937
|
+
# `$stderr`. This is the same as `assert_output("", "")`. This
|
|
1938
|
+
# is for Minitest compatibility.
|
|
1939
|
+
#
|
|
1940
|
+
# @example
|
|
1941
|
+
# assert_silent {} # => pass
|
|
1942
|
+
# assert_silent {puts("Hello")} # => failure
|
|
1943
|
+
#
|
|
1944
|
+
# @yield [] The block that should write nothing.
|
|
1945
|
+
# @return [void]
|
|
1946
|
+
#
|
|
1947
|
+
# @since 3.7.9
|
|
1948
|
+
def assert_silent(&block)
|
|
1949
|
+
assert_output("", "", &block)
|
|
1950
|
+
end
|
|
1951
|
+
|
|
1895
1952
|
##
|
|
1896
1953
|
# Builds a failure message. `user_message` is added before the
|
|
1897
1954
|
# `template` and `arguments` replaces the '?'s positionally in
|
|
@@ -1917,6 +1974,16 @@ EOT
|
|
|
1917
1974
|
end
|
|
1918
1975
|
end
|
|
1919
1976
|
|
|
1977
|
+
def _assert_captured_output(expected, actual, message)
|
|
1978
|
+
case expected
|
|
1979
|
+
when nil
|
|
1980
|
+
when Regexp
|
|
1981
|
+
assert_match(expected, actual, message)
|
|
1982
|
+
else
|
|
1983
|
+
assert_equal(expected, actual, message)
|
|
1984
|
+
end
|
|
1985
|
+
end
|
|
1986
|
+
|
|
1920
1987
|
public
|
|
1921
1988
|
# Called whenever an assertion is made. Define this in classes
|
|
1922
1989
|
# that include Test::Unit::Assertions to record assertion
|
data/lib/test/unit/autorunner.rb
CHANGED
|
@@ -199,6 +199,7 @@ module Test
|
|
|
199
199
|
begin
|
|
200
200
|
args.unshift(*@default_arguments)
|
|
201
201
|
options.order!(args) {|arg| add_test_path(arg)}
|
|
202
|
+
$LOAD_PATH.unshift(*@load_paths)
|
|
202
203
|
rescue OptionParser::ParseError => e
|
|
203
204
|
puts e
|
|
204
205
|
puts options
|
|
@@ -363,10 +364,8 @@ module Test
|
|
|
363
364
|
end
|
|
364
365
|
|
|
365
366
|
o.on("-I", "--load-path=DIR[#{File::PATH_SEPARATOR}DIR...]",
|
|
366
|
-
"
|
|
367
|
-
load_paths
|
|
368
|
-
$LOAD_PATH.concat(load_paths)
|
|
369
|
-
@load_paths.concat(load_paths)
|
|
367
|
+
"Prepends directory list to $LOAD_PATH.") do |dirs|
|
|
368
|
+
@load_paths.concat(dirs.split(File::PATH_SEPARATOR))
|
|
370
369
|
end
|
|
371
370
|
|
|
372
371
|
color_schemes = ColorScheme.all
|
|
@@ -408,6 +407,12 @@ module Test
|
|
|
408
407
|
AssertionFailedError.debug_on_failure = boolean
|
|
409
408
|
end
|
|
410
409
|
|
|
410
|
+
o.on("--[no-]notify-no-assertions",
|
|
411
|
+
"Notify tests without assertions",
|
|
412
|
+
"(#{TestCase.notify_no_assertions?})") do |boolean|
|
|
413
|
+
TestCase.notify_no_assertions = boolean
|
|
414
|
+
end
|
|
415
|
+
|
|
411
416
|
o.on("--[no-]gc-stress",
|
|
412
417
|
"Enable GC.stress only while each test is running",
|
|
413
418
|
"(#{@gc_stress})") do |boolean|
|
|
@@ -417,15 +422,18 @@ module Test
|
|
|
417
422
|
parallel_options = [
|
|
418
423
|
:thread,
|
|
419
424
|
:process,
|
|
425
|
+
:ractor,
|
|
420
426
|
]
|
|
421
|
-
o.on("--[no-]parallel=[
|
|
422
|
-
"Runs tests in parallel",
|
|
427
|
+
o.on("--[no-]parallel=[PARALLEL]", parallel_options,
|
|
428
|
+
"Runs tests in parallel: #{parallel_options.join(", ")}",
|
|
423
429
|
"(#{parallel_options.first})") do |parallel|
|
|
424
430
|
case parallel
|
|
425
431
|
when nil, :thread
|
|
426
432
|
@test_suite_runner_class = TestSuiteThreadRunner
|
|
427
433
|
when :process
|
|
428
434
|
@test_suite_runner_class = TestSuiteProcessRunner
|
|
435
|
+
when :ractor
|
|
436
|
+
@test_suite_runner_class = TestSuiteRactorRunner
|
|
429
437
|
else
|
|
430
438
|
@test_suite_runner_class = TestSuiteRunner
|
|
431
439
|
end
|
|
@@ -8,9 +8,9 @@ module Test
|
|
|
8
8
|
|
|
9
9
|
NAME = 'collected from the subclasses of TestCase'
|
|
10
10
|
|
|
11
|
-
def collect(name=NAME)
|
|
11
|
+
def collect(name=NAME, descendants=TestCase::DESCENDANTS)
|
|
12
12
|
suite = TestSuite.new(name)
|
|
13
|
-
add_test_cases(suite,
|
|
13
|
+
add_test_cases(suite, descendants)
|
|
14
14
|
adjust_ractor_tests(suite)
|
|
15
15
|
suite
|
|
16
16
|
end
|
|
@@ -16,7 +16,13 @@ module Test
|
|
|
16
16
|
super
|
|
17
17
|
@system_excludes = [/~\z/, /\A\.\#/]
|
|
18
18
|
@system_directory_excludes = [/\A(?:CVS|\.svn|\.git)\z/]
|
|
19
|
-
@patterns = [
|
|
19
|
+
@patterns = [
|
|
20
|
+
/\Atest[_\-].+\.rb\z/m,
|
|
21
|
+
# The test prefix pattern (test*.box.rb) is covered by the pattern above
|
|
22
|
+
# /\Atest[_\-].+\.box\.rb\z/m,
|
|
23
|
+
/[_\-]test\.rb\z/,
|
|
24
|
+
/[_\-]test\.box\.rb\z/
|
|
25
|
+
]
|
|
20
26
|
@excludes = []
|
|
21
27
|
@base = nil
|
|
22
28
|
@default_test_paths = []
|
|
@@ -67,9 +73,9 @@ module Test
|
|
|
67
73
|
end
|
|
68
74
|
end
|
|
69
75
|
|
|
70
|
-
def find_test_cases(already_gathered)
|
|
76
|
+
def find_test_cases(already_gathered, descendants=TestCase::DESCENDANTS)
|
|
71
77
|
test_cases = []
|
|
72
|
-
|
|
78
|
+
descendants.each do |test_case|
|
|
73
79
|
next if already_gathered.key?(test_case)
|
|
74
80
|
test_cases << test_case
|
|
75
81
|
already_gathered[test_case] = true
|
|
@@ -113,6 +119,10 @@ module Test
|
|
|
113
119
|
@program_file ||= File.expand_path($0)
|
|
114
120
|
expanded_path = path.expand_path
|
|
115
121
|
return if @program_file == expanded_path.to_s
|
|
122
|
+
if box_file?(expanded_path)
|
|
123
|
+
collect_box_file(expanded_path, test_suites, already_gathered)
|
|
124
|
+
return
|
|
125
|
+
end
|
|
116
126
|
add_load_path(expanded_path.dirname) do
|
|
117
127
|
begin
|
|
118
128
|
require(expanded_path.to_s)
|
|
@@ -123,6 +133,35 @@ module Test
|
|
|
123
133
|
end
|
|
124
134
|
end
|
|
125
135
|
|
|
136
|
+
def box_file?(path)
|
|
137
|
+
path.to_s.end_with?(".box.rb")
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def collect_box_file(expanded_path, test_suites, already_gathered)
|
|
141
|
+
unless Test::Unit.box_available?
|
|
142
|
+
errmsg = "Ruby::Box is unavailable while loading <#{expanded_path}>" +
|
|
143
|
+
" Use Ruby 4.1 or later with RUBY_BOX=1"
|
|
144
|
+
@require_failed_infos << {:path => expanded_path, :message => errmsg}
|
|
145
|
+
return
|
|
146
|
+
end
|
|
147
|
+
box = Ruby::Box.new
|
|
148
|
+
# The box must resolve require("test/unit") to the same
|
|
149
|
+
# test-unit as the current box's one.
|
|
150
|
+
test_unit_lib_path = File.expand_path("../../../", __dir__)
|
|
151
|
+
box.load_path.unshift(expanded_path.dirname.to_s, test_unit_lib_path)
|
|
152
|
+
begin
|
|
153
|
+
box.require(expanded_path.to_s)
|
|
154
|
+
rescue LoadError
|
|
155
|
+
@require_failed_infos << {:path => expanded_path, :exception => $!}
|
|
156
|
+
return
|
|
157
|
+
end
|
|
158
|
+
return unless defined?(box::Test::Unit::TestCase)
|
|
159
|
+
box::Test::Unit::AutoRunner.need_auto_run = false
|
|
160
|
+
test_cases = find_test_cases(already_gathered,
|
|
161
|
+
box::Test::Unit::TestCase::DESCENDANTS)
|
|
162
|
+
add_test_cases(test_suites, test_cases)
|
|
163
|
+
end
|
|
164
|
+
|
|
126
165
|
def resolve_path(path)
|
|
127
166
|
if @base
|
|
128
167
|
@base + path
|
|
@@ -181,10 +220,17 @@ module Test
|
|
|
181
220
|
normalized_path = path.to_s.gsub(/[^a-z0-9\_]+/i, '_')
|
|
182
221
|
normalized_path = normalized_path.gsub(/\A_+/, '')
|
|
183
222
|
exception = info[:exception]
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
223
|
+
if exception
|
|
224
|
+
define_method("test_require_#{normalized_path}") do
|
|
225
|
+
raise(exception.class,
|
|
226
|
+
"failed to load <#{path}>: #{exception.message}",
|
|
227
|
+
exception.backtrace)
|
|
228
|
+
end
|
|
229
|
+
else
|
|
230
|
+
message = info[:message]
|
|
231
|
+
define_method("test_require_#{normalized_path}") do
|
|
232
|
+
raise("failed to load <#{path}>: #{message}")
|
|
233
|
+
end
|
|
188
234
|
end
|
|
189
235
|
end
|
|
190
236
|
|
data/lib/test/unit/collector.rb
CHANGED
|
@@ -16,7 +16,7 @@ module Test
|
|
|
16
16
|
|
|
17
17
|
def add_suite(destination, suite)
|
|
18
18
|
to_delete = suite.tests.find_all do |test|
|
|
19
|
-
test.
|
|
19
|
+
!test.class.test_suite? and !include?(test)
|
|
20
20
|
end
|
|
21
21
|
suite.delete_tests(to_delete)
|
|
22
22
|
destination << suite unless suite.empty?
|
|
@@ -81,8 +81,7 @@ module Test
|
|
|
81
81
|
ractor_suites = []
|
|
82
82
|
ractor_tests = []
|
|
83
83
|
suite.tests.each do |test|
|
|
84
|
-
|
|
85
|
-
when TestSuite
|
|
84
|
+
if test.class.test_suite?
|
|
86
85
|
ractor_suites.concat(extract_ractor_tests(test))
|
|
87
86
|
else
|
|
88
87
|
next unless test[:ractor]
|
|
@@ -30,78 +30,74 @@ module Test
|
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
@@default_for_8_colors = nil
|
|
34
33
|
def default_for_8_colors
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"failure" => Color.new("red", :background => true) +
|
|
40
|
-
Color.new("white", :bold => true),
|
|
41
|
-
"failure-marker" => Color.new("red"),
|
|
42
|
-
"pending" => Color.new("magenta", :background => true) +
|
|
43
|
-
Color.new("white", :bold => true),
|
|
44
|
-
"pending-marker" => Color.new("magenta"),
|
|
45
|
-
"omission" => Color.new("blue", :background => true) +
|
|
46
|
-
Color.new("white", :bold => true),
|
|
47
|
-
"omission-marker" => Color.new("blue"),
|
|
48
|
-
"notification" => Color.new("cyan", :background => true) +
|
|
49
|
-
Color.new("white", :bold => true),
|
|
50
|
-
"notification-marker" => Color.new("cyan"),
|
|
51
|
-
"error" => Color.new("black", :background => true) +
|
|
52
|
-
Color.new("yellow", :bold => true),
|
|
53
|
-
"error-marker" => Color.new("yellow"),
|
|
54
|
-
"case" => Color.new("blue", :background => true) +
|
|
55
|
-
Color.new("white", :bold => true),
|
|
56
|
-
"suite" => Color.new("green", :background => true) +
|
|
34
|
+
new("pass" => Color.new("green", :background => true) +
|
|
35
|
+
Color.new("white", :bold => true),
|
|
36
|
+
"pass-marker" => Color.new("green", :bold => true),
|
|
37
|
+
"failure" => Color.new("red", :background => true) +
|
|
57
38
|
Color.new("white", :bold => true),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
39
|
+
"failure-marker" => Color.new("red"),
|
|
40
|
+
"pending" => Color.new("magenta", :background => true) +
|
|
41
|
+
Color.new("white", :bold => true),
|
|
42
|
+
"pending-marker" => Color.new("magenta"),
|
|
43
|
+
"omission" => Color.new("blue", :background => true) +
|
|
44
|
+
Color.new("white", :bold => true),
|
|
45
|
+
"omission-marker" => Color.new("blue"),
|
|
46
|
+
"notification" => Color.new("cyan", :background => true) +
|
|
47
|
+
Color.new("white", :bold => true),
|
|
48
|
+
"notification-marker" => Color.new("cyan"),
|
|
49
|
+
"error" => Color.new("black", :background => true) +
|
|
50
|
+
Color.new("yellow", :bold => true),
|
|
51
|
+
"error-marker" => Color.new("yellow"),
|
|
52
|
+
"case" => Color.new("blue", :background => true) +
|
|
53
|
+
Color.new("white", :bold => true),
|
|
54
|
+
"suite" => Color.new("green", :background => true) +
|
|
55
|
+
Color.new("white", :bold => true),
|
|
56
|
+
"diff-inserted-tag" => Color.new("red", :background => true) +
|
|
57
|
+
Color.new("black", :bold => true),
|
|
58
|
+
"diff-deleted-tag" => Color.new("green", :background => true) +
|
|
59
|
+
Color.new("black", :bold => true),
|
|
60
|
+
"diff-difference-tag" => Color.new("cyan", :background => true) +
|
|
61
|
+
Color.new("white", :bold => true),
|
|
62
|
+
"diff-inserted" => Color.new("red", :background => true) +
|
|
63
|
+
Color.new("white", :bold => true),
|
|
64
|
+
"diff-deleted" => Color.new("green", :background => true) +
|
|
65
|
+
Color.new("white", :bold => true))
|
|
68
66
|
end
|
|
69
67
|
|
|
70
|
-
@@default_for_256_colors = nil
|
|
71
68
|
def default_for_256_colors
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"pending" => Color.new("303", :background => true) +
|
|
80
|
-
Color.new("555", :bold => true),
|
|
81
|
-
"pending-marker" => Color.new("303"),
|
|
82
|
-
"omission" => Color.new("001", :background => true) +
|
|
83
|
-
Color.new("555", :bold => true),
|
|
84
|
-
"omission-marker" => Color.new("001"),
|
|
85
|
-
"notification" => Color.new("011", :background => true) +
|
|
86
|
-
Color.new("555", :bold => true),
|
|
87
|
-
"notification-marker" => Color.new("011"),
|
|
88
|
-
"error" => Color.new("000", :background => true) +
|
|
89
|
-
Color.new("550", :bold => true),
|
|
90
|
-
"error-marker" => Color.new("550"),
|
|
91
|
-
"case" => Color.new("220", :background => true) +
|
|
92
|
-
Color.new("555", :bold => true),
|
|
93
|
-
"suite" => Color.new("110", :background => true) +
|
|
69
|
+
new("pass" => Color.new("030", :background => true) +
|
|
70
|
+
Color.new("555", :bold => true),
|
|
71
|
+
"pass-marker" => Color.new("050", :bold => true),
|
|
72
|
+
"failure" => Color.new("300", :background => true) +
|
|
73
|
+
Color.new("555", :bold => true),
|
|
74
|
+
"failure-marker" => Color.new("500"),
|
|
75
|
+
"pending" => Color.new("303", :background => true) +
|
|
94
76
|
Color.new("555", :bold => true),
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
77
|
+
"pending-marker" => Color.new("303"),
|
|
78
|
+
"omission" => Color.new("001", :background => true) +
|
|
79
|
+
Color.new("555", :bold => true),
|
|
80
|
+
"omission-marker" => Color.new("001"),
|
|
81
|
+
"notification" => Color.new("011", :background => true) +
|
|
82
|
+
Color.new("555", :bold => true),
|
|
83
|
+
"notification-marker" => Color.new("011"),
|
|
84
|
+
"error" => Color.new("000", :background => true) +
|
|
85
|
+
Color.new("550", :bold => true),
|
|
86
|
+
"error-marker" => Color.new("550"),
|
|
87
|
+
"case" => Color.new("220", :background => true) +
|
|
88
|
+
Color.new("555", :bold => true),
|
|
89
|
+
"suite" => Color.new("110", :background => true) +
|
|
90
|
+
Color.new("555", :bold => true),
|
|
91
|
+
"diff-inserted-tag" => Color.new("500", :background => true) +
|
|
92
|
+
Color.new("000", :bold => true),
|
|
93
|
+
"diff-deleted-tag" => Color.new("050", :background => true) +
|
|
94
|
+
Color.new("000", :bold => true),
|
|
95
|
+
"diff-difference-tag" => Color.new("005", :background => true) +
|
|
96
|
+
Color.new("555", :bold => true),
|
|
97
|
+
"diff-inserted" => Color.new("300", :background => true) +
|
|
98
|
+
Color.new("555", :bold => true),
|
|
99
|
+
"diff-deleted" => Color.new("030", :background => true) +
|
|
100
|
+
Color.new("555", :bold => true))
|
|
105
101
|
end
|
|
106
102
|
|
|
107
103
|
@@schemes = {}
|
|
@@ -202,6 +198,14 @@ module Test
|
|
|
202
198
|
hash
|
|
203
199
|
end
|
|
204
200
|
|
|
201
|
+
def ==(other)
|
|
202
|
+
self.class === other and
|
|
203
|
+
@scheme == other.scheme
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
protected
|
|
207
|
+
attr_reader :scheme
|
|
208
|
+
|
|
205
209
|
private
|
|
206
210
|
def make_color(color_spec)
|
|
207
211
|
if color_spec.is_a?(Color) or color_spec.is_a?(MixColor)
|
data/lib/test/unit/color.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Test
|
|
2
4
|
module Unit
|
|
3
5
|
class Color
|
|
@@ -22,7 +24,7 @@ module Test
|
|
|
22
24
|
end
|
|
23
25
|
|
|
24
26
|
NAMES = ["black", "red", "green", "yellow",
|
|
25
|
-
"blue", "magenta", "cyan", "white"]
|
|
27
|
+
"blue", "magenta", "cyan", "white"].freeze
|
|
26
28
|
|
|
27
29
|
attr_reader :name
|
|
28
30
|
def initialize(name, options={})
|
data/lib/test/unit/diff.rb
CHANGED
|
@@ -287,7 +287,7 @@ module Test
|
|
|
287
287
|
0xFA70..0xFAD9, 0xFE10..0xFE19, 0xFE30..0xFE52,
|
|
288
288
|
0xFE54..0xFE66, 0xFE68..0xFE6B, 0xFF01..0xFF60,
|
|
289
289
|
0xFFE0..0xFFE6, 0x20000..0x2FFFD, 0x30000..0x3FFFD,
|
|
290
|
-
]
|
|
290
|
+
].freeze
|
|
291
291
|
|
|
292
292
|
AMBIGUOUS =
|
|
293
293
|
[0x00A1..0x00A1, 0x00A4..0x00A4, 0x00A7..0x00A8,
|
|
@@ -343,7 +343,7 @@ module Test
|
|
|
343
343
|
0x266F..0x266F, 0x273D..0x273D, 0x2776..0x277F,
|
|
344
344
|
0xE000..0xF8FF, 0xFE00..0xFE0F, 0xFFFD..0xFFFD,
|
|
345
345
|
0xE0100..0xE01EF, 0xF0000..0xFFFFD, 0x100000..0x10FFFD,
|
|
346
|
-
]
|
|
346
|
+
].freeze
|
|
347
347
|
|
|
348
348
|
def wide_character?(character)
|
|
349
349
|
binary_search_ranges(character, WIDE_CHARACTERS) or
|
data/lib/test/unit/error.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
#--
|
|
2
3
|
#
|
|
3
4
|
# Author:: Nathaniel Talbott.
|
|
@@ -76,15 +77,24 @@ module Test
|
|
|
76
77
|
end
|
|
77
78
|
end
|
|
78
79
|
|
|
79
|
-
NOT_PASS_THROUGH_EXCEPTIONS = []
|
|
80
|
-
NOT_PASS_THROUGH_EXCEPTION_NAMES = ["Timeout::Error"]
|
|
80
|
+
NOT_PASS_THROUGH_EXCEPTIONS = [].freeze
|
|
81
|
+
NOT_PASS_THROUGH_EXCEPTION_NAMES = ["Timeout::Error"].freeze
|
|
81
82
|
PASS_THROUGH_EXCEPTIONS = [
|
|
82
83
|
NoMemoryError,
|
|
83
84
|
SignalException,
|
|
84
85
|
Interrupt,
|
|
85
86
|
SystemExit,
|
|
86
|
-
]
|
|
87
|
-
PASS_THROUGH_EXCEPTION_NAMES = []
|
|
87
|
+
].freeze
|
|
88
|
+
PASS_THROUGH_EXCEPTION_NAMES = [].freeze
|
|
89
|
+
|
|
90
|
+
# Returns whether an error occurred in the test. This is for
|
|
91
|
+
# Minitest compatibility.
|
|
92
|
+
#
|
|
93
|
+
# @return [Boolean]
|
|
94
|
+
def error?
|
|
95
|
+
@internal_data.errored?
|
|
96
|
+
end
|
|
97
|
+
|
|
88
98
|
private
|
|
89
99
|
def handle_all_exception(exception)
|
|
90
100
|
return false if pass_through_exception?(exception)
|
|
@@ -117,6 +127,7 @@ module Test
|
|
|
117
127
|
end
|
|
118
128
|
|
|
119
129
|
def add_error(exception)
|
|
130
|
+
@internal_data.errored
|
|
120
131
|
error = Error.new(name, exception, :method_name => @method_name)
|
|
121
132
|
current_result.add_error(error)
|
|
122
133
|
end
|
data/lib/test/unit/failure.rb
CHANGED
data/lib/test/unit/fixture.rb
CHANGED
|
@@ -282,9 +282,9 @@ module Test
|
|
|
282
282
|
return unless respond_to?(method_name, true)
|
|
283
283
|
begin
|
|
284
284
|
__send__(method_name, &block)
|
|
285
|
-
rescue Exception
|
|
285
|
+
rescue Exception => e
|
|
286
286
|
raise unless options[:handle_exception]
|
|
287
|
-
raise unless handle_exception(
|
|
287
|
+
raise unless handle_exception(e)
|
|
288
288
|
end
|
|
289
289
|
end
|
|
290
290
|
|