test-unit 3.7.8 → 3.8.0
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 +147 -0
- data/lib/test/unit/assertions.rb +75 -2
- data/lib/test/unit/attribute.rb +8 -5
- data/lib/test/unit/autorunner.rb +10 -0
- 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/fault-location-detector.rb +1 -3
- data/lib/test/unit/fixture.rb +9 -0
- 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 +10 -3
- data/lib/test/unit/ractor-helper.rb +46 -0
- data/lib/test/unit/ractor-test-result.rb +60 -0
- data/lib/test/unit/sub-test-result.rb +6 -0
- data/lib/test/unit/test-finder.rb +44 -0
- data/lib/test/unit/test-ractor-run-context.rb +23 -0
- data/lib/test/unit/test-suite-creator.rb +3 -2
- data/lib/test/unit/test-suite-process-runner.rb +5 -2
- data/lib/test/unit/test-suite-ractor-runner.rb +189 -0
- data/lib/test/unit/test-suite-runner.rb +4 -0
- data/lib/test/unit/test-suite-thread-runner.rb +20 -8
- data/lib/test/unit/testcase.rb +149 -22
- data/lib/test/unit/testresult.rb +11 -4
- data/lib/test/unit/testsuite.rb +25 -12
- data/lib/test/unit/ui/testrunnermediator.rb +3 -3
- data/lib/test/unit/util/backtracefilter.rb +7 -0
- 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 +7 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 15b7580df55aec5b009ea7ce6db96a9200f5b34b1d6becb6737d9229c86507b2
|
|
4
|
+
data.tar.gz: ee9afd7eeba80b6db2a91fbb3b9841065bd4e86eab2806259b51786658c2b62d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b8e7c95ff2894200a66dc94c99bc6452e94bdb26f84f7062697f71ff6733c615c1b33cd2b4ac26ec98379cfe8809c1a251bd97ea9bb573e2fa389f38bd56751c
|
|
7
|
+
data.tar.gz: 14f92f0a235ce321f6d8bfe661f654f2192ca90303fb1f9afaf4e1e2e3b5864a143ef79c589d1a1bbd72d4c68fcf414862f0b759ba199cb924341d0e01c4e83a
|
data/doc/text/news.md
CHANGED
|
@@ -1,5 +1,152 @@
|
|
|
1
1
|
# News
|
|
2
2
|
|
|
3
|
+
## 3.8.0 - 2026-12-07 {#version-3-8-0}
|
|
4
|
+
|
|
5
|
+
### Improvements
|
|
6
|
+
|
|
7
|
+
* Added support for Ractor based parallel test running. You can use
|
|
8
|
+
it by the `--parallel=ractor` option. You need Ruby 4.1 or later.
|
|
9
|
+
Tests run in non-main Ractors. If the tests pass, the tested code
|
|
10
|
+
works in a non-main Ractor. You can disable parallel test running
|
|
11
|
+
per test case by defining `parallel_safe?` class method that
|
|
12
|
+
returns `false`. The test case runs in the main Ractor.
|
|
13
|
+
* GH-235
|
|
14
|
+
* GH-411
|
|
15
|
+
* GH-414
|
|
16
|
+
* GH-415
|
|
17
|
+
* GH-416
|
|
18
|
+
* GH-417
|
|
19
|
+
* GH-418
|
|
20
|
+
* GH-419
|
|
21
|
+
* GH-420
|
|
22
|
+
* GH-423
|
|
23
|
+
* GH-424
|
|
24
|
+
* GH-425
|
|
25
|
+
* GH-426
|
|
26
|
+
* GH-427
|
|
27
|
+
* GH-428
|
|
28
|
+
* GH-431
|
|
29
|
+
* GH-433
|
|
30
|
+
* GH-434
|
|
31
|
+
* Co authored by Naoto Ono
|
|
32
|
+
|
|
33
|
+
### Fixes
|
|
34
|
+
|
|
35
|
+
* Suppressed method redefined warnings with the
|
|
36
|
+
`--notify-no-assertions` option.
|
|
37
|
+
* GH-427
|
|
38
|
+
|
|
39
|
+
* parallel: thread: Fixed a bug that tests in a sub test case don't
|
|
40
|
+
run when the parent test case has startup/shutdown (test case level
|
|
41
|
+
setup/teardown).
|
|
42
|
+
* GH-429
|
|
43
|
+
* GH-430
|
|
44
|
+
|
|
45
|
+
* parallel: thread: Fixed a bug that `parallel_safe?` is ignored
|
|
46
|
+
when the test case has startup/shutdown.
|
|
47
|
+
* GH-432
|
|
48
|
+
|
|
49
|
+
* parallel: process: Fixed a bug that filters such as the `-n`
|
|
50
|
+
option are ignored when the test case has startup/shutdown.
|
|
51
|
+
* GH-434
|
|
52
|
+
|
|
53
|
+
* parallel: process: Fixed a bug that tests declared with
|
|
54
|
+
`Test::Unit::TestCase.ractor` don't run when the test case has
|
|
55
|
+
startup/shutdown.
|
|
56
|
+
* GH-434
|
|
57
|
+
|
|
58
|
+
### Thanks
|
|
59
|
+
|
|
60
|
+
* Naoto Ono
|
|
61
|
+
|
|
62
|
+
## 3.7.9 - 2026-11-24 {#version-3-7-9}
|
|
63
|
+
|
|
64
|
+
### Improvements
|
|
65
|
+
|
|
66
|
+
* Added support for running test files in Ruby::Box. test-unit
|
|
67
|
+
loads each test file with suffix `.box.rb` (e.g.
|
|
68
|
+
`test_xxx.box.rb`) in its own Ruby::Box. So monkey patches in the
|
|
69
|
+
file don't affect other test files. You need Ruby 4.1 or later
|
|
70
|
+
with `RUBY_BOX=1`. The `--parallel` option isn't supported for
|
|
71
|
+
these files yet.
|
|
72
|
+
* GH-382
|
|
73
|
+
* GH-384
|
|
74
|
+
* GH-385
|
|
75
|
+
* GH-386
|
|
76
|
+
* GH-388
|
|
77
|
+
* GH-389
|
|
78
|
+
* Patch by Satoshi Tagomori
|
|
79
|
+
|
|
80
|
+
* Added Minitest compatible methods. You can use them when you
|
|
81
|
+
migrate your tests from Minitest. They also make test-unit easier
|
|
82
|
+
to use with Active Support.
|
|
83
|
+
* `skip`: Omits the rest of the test like `omit`.
|
|
84
|
+
* `assertions` and `assertions=`: Reads and writes the number of
|
|
85
|
+
assertions in the test.
|
|
86
|
+
* `capture_io`: Same as `capture_output`.
|
|
87
|
+
* `assert_output`: Asserts the output to `$stdout` and `$stderr`
|
|
88
|
+
in the block.
|
|
89
|
+
* `skipped?`: Returns whether the test is omitted.
|
|
90
|
+
* `error?`: Returns whether an error occurred in the test.
|
|
91
|
+
* `assert_silent`: Asserts no output to `$stdout` and `$stderr`
|
|
92
|
+
in the block.
|
|
93
|
+
* GH-390
|
|
94
|
+
* GH-392
|
|
95
|
+
* GH-394
|
|
96
|
+
* GH-395
|
|
97
|
+
* GH-396
|
|
98
|
+
* GH-397
|
|
99
|
+
* GH-399
|
|
100
|
+
* GH-400
|
|
101
|
+
* Suggested by Akira Matsuda
|
|
102
|
+
|
|
103
|
+
* `capture_output`: Improved thread safety. Calls from multiple
|
|
104
|
+
threads now run one by one.
|
|
105
|
+
* GH-390
|
|
106
|
+
* GH-391
|
|
107
|
+
|
|
108
|
+
* testcase: `Test::Unit::TestCase::FINISHED_OBJECT` listeners can't
|
|
109
|
+
read instance variables added during the test run now. This is a
|
|
110
|
+
preparation for the Ractor based runner.
|
|
111
|
+
* GH-235
|
|
112
|
+
* GH-405
|
|
113
|
+
* Co authored by Naoto Ono
|
|
114
|
+
|
|
115
|
+
* priority: The priority mode now reads `$0` when
|
|
116
|
+
`test/unit/priority.rb` is loaded. It doesn't use a new value
|
|
117
|
+
assigned to `$0` after that. This is a preparation for the Ractor
|
|
118
|
+
based runner.
|
|
119
|
+
* GH-235
|
|
120
|
+
* GH-406
|
|
121
|
+
* Co authored by Naoto Ono
|
|
122
|
+
|
|
123
|
+
* color-scheme: `Test::Unit::ColorScheme.default` now returns a new
|
|
124
|
+
object every time. If you change the returned object, the next
|
|
125
|
+
call doesn't return your change. This is a preparation for the
|
|
126
|
+
Ractor based runner.
|
|
127
|
+
* GH-235
|
|
128
|
+
* GH-408
|
|
129
|
+
* Co authored by Naoto Ono
|
|
130
|
+
|
|
131
|
+
* Added the `--notify-no-assertions` option. It notifies you of
|
|
132
|
+
passed tests without assertions. Such tests may verify nothing.
|
|
133
|
+
This is disabled by default. You can also enable it per test case
|
|
134
|
+
by `self.notify_no_assertions = true`.
|
|
135
|
+
* GH-390
|
|
136
|
+
* GH-403
|
|
137
|
+
|
|
138
|
+
* parallel: Added `ractor` to the `--parallel` option. This is a
|
|
139
|
+
preparation. The Ractor based runner isn't available yet.
|
|
140
|
+
* GH-235
|
|
141
|
+
* GH-410
|
|
142
|
+
* Co authored by Naoto Ono
|
|
143
|
+
|
|
144
|
+
### Thanks
|
|
145
|
+
|
|
146
|
+
* Satoshi Tagomori
|
|
147
|
+
* Akira Matsuda
|
|
148
|
+
* Naoto Ono
|
|
149
|
+
|
|
3
150
|
## 3.7.8 - 2026-06-05 {#version-3-7-8}
|
|
4
151
|
|
|
5
152
|
### Improvements
|
data/lib/test/unit/assertions.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
# Copyright (c) 2009-2013 Kouhei Sutou. All rights reserved.
|
|
4
4
|
# License:: Ruby license.
|
|
5
5
|
|
|
6
|
+
require_relative 'ractor-helper'
|
|
6
7
|
require_relative 'assertion-failed-error'
|
|
7
8
|
require_relative 'util/backtracefilter'
|
|
8
9
|
require_relative 'util/memory-usage'
|
|
@@ -36,6 +37,11 @@ module Test
|
|
|
36
37
|
# end
|
|
37
38
|
|
|
38
39
|
module Assertions
|
|
40
|
+
class << self
|
|
41
|
+
def on_ractor_start
|
|
42
|
+
Ractor.make_shareable(AssertionMessage::Inspector.inspector_classes)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
39
45
|
|
|
40
46
|
##
|
|
41
47
|
# The assertion upon which all other assertions are based. Passes if the
|
|
@@ -58,7 +64,7 @@ module Test
|
|
|
58
64
|
end
|
|
59
65
|
|
|
60
66
|
# @private
|
|
61
|
-
NOT_SPECIFIED = Object.new
|
|
67
|
+
NOT_SPECIFIED = Object.new.freeze
|
|
62
68
|
|
|
63
69
|
# @overload assert(object, message=nil)
|
|
64
70
|
#
|
|
@@ -131,7 +137,7 @@ module Test
|
|
|
131
137
|
have_object = !NOT_SPECIFIED.equal?(object)
|
|
132
138
|
if block
|
|
133
139
|
message = object if have_object
|
|
134
|
-
if defined?(PowerAssert)
|
|
140
|
+
if defined?(PowerAssert) and not Unit.non_main_ractor?
|
|
135
141
|
PowerAssert.start(block, :assertion_method => __callee__) do |pa|
|
|
136
142
|
pa_message = AssertionMessage.delayed_literal(&pa.message_proc)
|
|
137
143
|
assertion_message = build_message(message, "?", pa_message)
|
|
@@ -1892,6 +1898,63 @@ EOT
|
|
|
1892
1898
|
end
|
|
1893
1899
|
end
|
|
1894
1900
|
|
|
1901
|
+
# Asserts that the block writes the expected output to
|
|
1902
|
+
# `$stdout` and `$stderr`. This is for Minitest compatibility.
|
|
1903
|
+
#
|
|
1904
|
+
# Each expected output is checked by its type:
|
|
1905
|
+
#
|
|
1906
|
+
# * `nil`: It's not checked.
|
|
1907
|
+
# * `Regexp`: It must match the output.
|
|
1908
|
+
# * Others: It must be equal to the output. Use `""` to assert
|
|
1909
|
+
# no output.
|
|
1910
|
+
#
|
|
1911
|
+
# @example Pass patterns
|
|
1912
|
+
# assert_output("Hello\n") {puts("Hello")} # => pass
|
|
1913
|
+
# assert_output(/ell/) {puts("Hello")} # => pass
|
|
1914
|
+
# assert_output(nil, "Error\n") {warn("Error")} # => pass
|
|
1915
|
+
# assert_output("", "") {} # => pass
|
|
1916
|
+
#
|
|
1917
|
+
# @example Failure patterns
|
|
1918
|
+
# assert_output("Hell") {puts("Hello")} # => failure
|
|
1919
|
+
# assert_output(nil, "") {warn("Error")} # => failure
|
|
1920
|
+
#
|
|
1921
|
+
# @param [String, Regexp, nil] stdout The expected output to
|
|
1922
|
+
# `$stdout`.
|
|
1923
|
+
# @param [String, Regexp, nil] stderr The expected output to
|
|
1924
|
+
# `$stderr`.
|
|
1925
|
+
# @yield [] The block that writes output.
|
|
1926
|
+
# @return [void]
|
|
1927
|
+
#
|
|
1928
|
+
# @since 3.7.9
|
|
1929
|
+
def assert_output(stdout=nil, stderr=nil)
|
|
1930
|
+
unless block_given?
|
|
1931
|
+
flunk("assert_output requires a block to capture output.")
|
|
1932
|
+
end
|
|
1933
|
+
_wrap_assertion do
|
|
1934
|
+
actual_stdout, actual_stderr = capture_output do
|
|
1935
|
+
yield
|
|
1936
|
+
end
|
|
1937
|
+
_assert_captured_output(stderr, actual_stderr, "In stderr")
|
|
1938
|
+
_assert_captured_output(stdout, actual_stdout, "In stdout")
|
|
1939
|
+
end
|
|
1940
|
+
end
|
|
1941
|
+
|
|
1942
|
+
# Asserts that the block writes nothing to `$stdout` and
|
|
1943
|
+
# `$stderr`. This is the same as `assert_output("", "")`. This
|
|
1944
|
+
# is for Minitest compatibility.
|
|
1945
|
+
#
|
|
1946
|
+
# @example
|
|
1947
|
+
# assert_silent {} # => pass
|
|
1948
|
+
# assert_silent {puts("Hello")} # => failure
|
|
1949
|
+
#
|
|
1950
|
+
# @yield [] The block that should write nothing.
|
|
1951
|
+
# @return [void]
|
|
1952
|
+
#
|
|
1953
|
+
# @since 3.7.9
|
|
1954
|
+
def assert_silent(&block)
|
|
1955
|
+
assert_output("", "", &block)
|
|
1956
|
+
end
|
|
1957
|
+
|
|
1895
1958
|
##
|
|
1896
1959
|
# Builds a failure message. `user_message` is added before the
|
|
1897
1960
|
# `template` and `arguments` replaces the '?'s positionally in
|
|
@@ -1917,6 +1980,16 @@ EOT
|
|
|
1917
1980
|
end
|
|
1918
1981
|
end
|
|
1919
1982
|
|
|
1983
|
+
def _assert_captured_output(expected, actual, message)
|
|
1984
|
+
case expected
|
|
1985
|
+
when nil
|
|
1986
|
+
when Regexp
|
|
1987
|
+
assert_match(expected, actual, message)
|
|
1988
|
+
else
|
|
1989
|
+
assert_equal(expected, actual, message)
|
|
1990
|
+
end
|
|
1991
|
+
end
|
|
1992
|
+
|
|
1920
1993
|
public
|
|
1921
1994
|
# Called whenever an assertion is made. Define this in classes
|
|
1922
1995
|
# that include Test::Unit::Assertions to record assertion
|
data/lib/test/unit/attribute.rb
CHANGED
|
@@ -183,8 +183,7 @@ module Test
|
|
|
183
183
|
recursive_p = options[:recursive]
|
|
184
184
|
recursive_p = true if recursive_p.nil?
|
|
185
185
|
|
|
186
|
-
@attributes_table
|
|
187
|
-
if @attributes_table.key?(method_name)
|
|
186
|
+
if defined?(@attributes_table) and @attributes_table.key?(method_name)
|
|
188
187
|
attributes = @attributes_table[method_name]
|
|
189
188
|
if attributes.key?(name)
|
|
190
189
|
return attributes[name]
|
|
@@ -194,14 +193,18 @@ module Test
|
|
|
194
193
|
return nil unless recursive_p
|
|
195
194
|
return nil if self == TestCase
|
|
196
195
|
|
|
196
|
+
parent_test_case = find_parent_test_case
|
|
197
|
+
return nil if parent_test_case.nil?
|
|
198
|
+
|
|
199
|
+
parent_test_case.find_attribute(method_name, name, options)
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def find_parent_test_case # :nodoc:
|
|
197
203
|
@cached_parent_test_case ||= ancestors.find do |ancestor|
|
|
198
204
|
ancestor != self and
|
|
199
205
|
ancestor.is_a?(Class) and
|
|
200
206
|
ancestor < Test::Unit::Attribute
|
|
201
207
|
end
|
|
202
|
-
return nil if @cached_parent_test_case.nil?
|
|
203
|
-
|
|
204
|
-
@cached_parent_test_case.find_attribute(method_name, name, options)
|
|
205
208
|
end
|
|
206
209
|
|
|
207
210
|
@@attribute_observers = StringifyKeyHash.new
|
data/lib/test/unit/autorunner.rb
CHANGED
|
@@ -7,6 +7,7 @@ require_relative "attribute-matcher"
|
|
|
7
7
|
require_relative "testcase"
|
|
8
8
|
require_relative "test-suite-thread-runner"
|
|
9
9
|
require_relative "test-suite-process-runner"
|
|
10
|
+
require_relative "test-suite-ractor-runner"
|
|
10
11
|
require_relative "version"
|
|
11
12
|
|
|
12
13
|
module Test
|
|
@@ -407,6 +408,12 @@ module Test
|
|
|
407
408
|
AssertionFailedError.debug_on_failure = boolean
|
|
408
409
|
end
|
|
409
410
|
|
|
411
|
+
o.on("--[no-]notify-no-assertions",
|
|
412
|
+
"Notify tests without assertions",
|
|
413
|
+
"(#{TestCase.notify_no_assertions?})") do |boolean|
|
|
414
|
+
TestCase.notify_no_assertions = boolean
|
|
415
|
+
end
|
|
416
|
+
|
|
410
417
|
o.on("--[no-]gc-stress",
|
|
411
418
|
"Enable GC.stress only while each test is running",
|
|
412
419
|
"(#{@gc_stress})") do |boolean|
|
|
@@ -416,6 +423,7 @@ module Test
|
|
|
416
423
|
parallel_options = [
|
|
417
424
|
:thread,
|
|
418
425
|
:process,
|
|
426
|
+
:ractor,
|
|
419
427
|
]
|
|
420
428
|
o.on("--[no-]parallel=[PARALLEL]", parallel_options,
|
|
421
429
|
"Runs tests in parallel: #{parallel_options.join(", ")}",
|
|
@@ -425,6 +433,8 @@ module Test
|
|
|
425
433
|
@test_suite_runner_class = TestSuiteThreadRunner
|
|
426
434
|
when :process
|
|
427
435
|
@test_suite_runner_class = TestSuiteProcessRunner
|
|
436
|
+
when :ractor
|
|
437
|
+
@test_suite_runner_class = TestSuiteRactorRunner
|
|
428
438
|
else
|
|
429
439
|
@test_suite_runner_class = TestSuiteRunner
|
|
430
440
|
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
|