test-unit 3.7.8 → 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 +88 -0
- data/lib/test/unit/assertions.rb +68 -1
- data/lib/test/unit/autorunner.rb +9 -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/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 +6 -1
- 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 +4 -1
- data/lib/test/unit/test-suite-thread-runner.rb +1 -1
- data/lib/test/unit/testcase.rb +111 -7
- 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,93 @@
|
|
|
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
|
+
|
|
3
91
|
## 3.7.8 - 2026-06-05 {#version-3-7-8}
|
|
4
92
|
|
|
5
93
|
### Improvements
|
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
|
@@ -407,6 +407,12 @@ module Test
|
|
|
407
407
|
AssertionFailedError.debug_on_failure = boolean
|
|
408
408
|
end
|
|
409
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
|
+
|
|
410
416
|
o.on("--[no-]gc-stress",
|
|
411
417
|
"Enable GC.stress only while each test is running",
|
|
412
418
|
"(#{@gc_stress})") do |boolean|
|
|
@@ -416,6 +422,7 @@ module Test
|
|
|
416
422
|
parallel_options = [
|
|
417
423
|
:thread,
|
|
418
424
|
:process,
|
|
425
|
+
:ractor,
|
|
419
426
|
]
|
|
420
427
|
o.on("--[no-]parallel=[PARALLEL]", parallel_options,
|
|
421
428
|
"Runs tests in parallel: #{parallel_options.join(", ")}",
|
|
@@ -425,6 +432,8 @@ module Test
|
|
|
425
432
|
@test_suite_runner_class = TestSuiteThreadRunner
|
|
426
433
|
when :process
|
|
427
434
|
@test_suite_runner_class = TestSuiteProcessRunner
|
|
435
|
+
when :ractor
|
|
436
|
+
@test_suite_runner_class = TestSuiteRactorRunner
|
|
428
437
|
else
|
|
429
438
|
@test_suite_runner_class = TestSuiteRunner
|
|
430
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/omission.rb
CHANGED
|
@@ -142,8 +142,30 @@ module Test
|
|
|
142
142
|
end
|
|
143
143
|
end
|
|
144
144
|
|
|
145
|
+
# Omit the rest of the test. This is for Minitest
|
|
146
|
+
# compatibility. Use #omit in new tests.
|
|
147
|
+
#
|
|
148
|
+
# Example:
|
|
149
|
+
#
|
|
150
|
+
# def test_skip
|
|
151
|
+
# skip("Not supported yet")
|
|
152
|
+
# # Not reached here
|
|
153
|
+
# end
|
|
154
|
+
def skip(message=nil, _ignored=nil)
|
|
155
|
+
omit(message || "skipped.")
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Returns whether the test is omitted. This is for Minitest
|
|
159
|
+
# compatibility.
|
|
160
|
+
#
|
|
161
|
+
# @return [Boolean]
|
|
162
|
+
def skipped?
|
|
163
|
+
@internal_data.omitted?
|
|
164
|
+
end
|
|
165
|
+
|
|
145
166
|
private
|
|
146
167
|
def add_omission(omission)
|
|
168
|
+
@internal_data.omitted
|
|
147
169
|
current_result.add_omission(omission)
|
|
148
170
|
end
|
|
149
171
|
end
|
data/lib/test/unit/priority.rb
CHANGED
|
@@ -119,13 +119,14 @@ module Test
|
|
|
119
119
|
File.exist?(passed_file)
|
|
120
120
|
end
|
|
121
121
|
|
|
122
|
+
BASE_DIR = File.dirname($0).freeze
|
|
122
123
|
def result_dir
|
|
123
124
|
components = [
|
|
124
125
|
".test-result",
|
|
125
126
|
escape_class_name(@test.class.name || "AnonymousTestCase"),
|
|
126
127
|
escaped_method_name,
|
|
127
128
|
]
|
|
128
|
-
parent_directories = [
|
|
129
|
+
parent_directories = [BASE_DIR, Dir.pwd]
|
|
129
130
|
if Process.respond_to?(:uid)
|
|
130
131
|
parent_directories << File.join(Dir.tmpdir, Process.uid.to_s)
|
|
131
132
|
end
|
|
@@ -28,10 +28,15 @@ remote_ip_port = nil
|
|
|
28
28
|
parser.on("--ip-port=PORT", Integer) do |port|
|
|
29
29
|
remote_ip_port = port
|
|
30
30
|
end
|
|
31
|
+
notify_no_assertions = false
|
|
32
|
+
parser.on("--notify-no-assertions") do
|
|
33
|
+
notify_no_assertions = true
|
|
34
|
+
end
|
|
31
35
|
test_paths = parser.parse!
|
|
32
36
|
$LOAD_PATH.unshift(*load_paths)
|
|
33
37
|
|
|
34
38
|
require_relative "../unit"
|
|
39
|
+
Test::Unit::TestCase.notify_no_assertions = true if notify_no_assertions
|
|
35
40
|
require_relative "collector/load"
|
|
36
41
|
require_relative "process-test-result"
|
|
37
42
|
require_relative "worker-context"
|
|
@@ -70,7 +75,7 @@ io_open.call do |data_input, data_output|
|
|
|
70
75
|
Marshal.dump({status: :event, event_name: event_name, args: args}, data_output)
|
|
71
76
|
data_output.flush
|
|
72
77
|
end
|
|
73
|
-
if test.
|
|
78
|
+
if test.class.test_suite?
|
|
74
79
|
test_suite = test
|
|
75
80
|
else
|
|
76
81
|
test_suite = Test::Unit::TestSuite.new(test.class.name, test.class)
|
|
@@ -17,8 +17,9 @@ module Test
|
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
def initialize(test_case)
|
|
20
|
+
def initialize(test_case, skip_valid_check: false)
|
|
21
21
|
@test_case = test_case
|
|
22
|
+
@skip_valid_check = skip_valid_check
|
|
22
23
|
end
|
|
23
24
|
|
|
24
25
|
def create
|
|
@@ -59,7 +60,7 @@ module Test
|
|
|
59
60
|
def append_test(suite, test_name)
|
|
60
61
|
test = @test_case.new(test_name)
|
|
61
62
|
yield(test) if block_given?
|
|
62
|
-
suite << test if test.valid?
|
|
63
|
+
suite << test if @skip_valid_check or test.valid?
|
|
63
64
|
end
|
|
64
65
|
|
|
65
66
|
def collect_test_names
|
|
@@ -67,6 +67,9 @@ module Test
|
|
|
67
67
|
command_line << "--base-directory" << base_directory
|
|
68
68
|
end
|
|
69
69
|
command_line << "--worker-id" << (i + 1).to_s
|
|
70
|
+
if TestCase.notify_no_assertions?
|
|
71
|
+
command_line << "--notify-no-assertions"
|
|
72
|
+
end
|
|
70
73
|
if Gem.win_platform?
|
|
71
74
|
local_address = tcp_server.local_address
|
|
72
75
|
command_line << "--ip-address" << local_address.ip_address
|
|
@@ -192,7 +195,7 @@ module Test
|
|
|
192
195
|
run_context.test_names << test_suite.name
|
|
193
196
|
else
|
|
194
197
|
test_suite.tests.each do |test|
|
|
195
|
-
if test.
|
|
198
|
+
if test.class.test_suite?
|
|
196
199
|
run_tests_recursive(test, worker_context, &progress_block)
|
|
197
200
|
else
|
|
198
201
|
run_context.test_names << test.name
|
|
@@ -73,7 +73,7 @@ module Test
|
|
|
73
73
|
run_context.queue << task
|
|
74
74
|
else
|
|
75
75
|
test_suite.tests.each do |test|
|
|
76
|
-
if test.
|
|
76
|
+
if test.class.test_suite?
|
|
77
77
|
run_tests_recursive(test, worker_context, &progress_block)
|
|
78
78
|
elsif test_suite.parallel_safe?
|
|
79
79
|
task = lambda do |stop_tag, worker_id|
|
data/lib/test/unit/testcase.rb
CHANGED
|
@@ -21,6 +21,7 @@ require_relative 'testsuite'
|
|
|
21
21
|
require_relative 'test-suite-creator'
|
|
22
22
|
require_relative 'assertion-failed-error'
|
|
23
23
|
require_relative 'auto-runner-loader'
|
|
24
|
+
require_relative 'worker-context'
|
|
24
25
|
require_relative 'util/backtracefilter'
|
|
25
26
|
require_relative 'util/output'
|
|
26
27
|
require_relative 'util/method-owner-finder'
|
|
@@ -116,13 +117,13 @@ module Test
|
|
|
116
117
|
include Util::BacktraceFilter
|
|
117
118
|
include Util::Output
|
|
118
119
|
|
|
119
|
-
STARTED = name + "::STARTED" # :nodoc:
|
|
120
|
-
FINISHED = name + "::FINISHED" # :nodoc:
|
|
121
|
-
STARTED_OBJECT = name + "::STARTED::OBJECT" # :nodoc:
|
|
122
|
-
FINISHED_OBJECT = name + "::FINISHED::OBJECT" # :nodoc:
|
|
120
|
+
STARTED = (name + "::STARTED").freeze # :nodoc:
|
|
121
|
+
FINISHED = (name + "::FINISHED").freeze # :nodoc:
|
|
122
|
+
STARTED_OBJECT = (name + "::STARTED::OBJECT").freeze # :nodoc:
|
|
123
|
+
FINISHED_OBJECT = (name + "::FINISHED::OBJECT").freeze # :nodoc:
|
|
123
124
|
|
|
124
125
|
DESCENDANTS = [] # :nodoc:
|
|
125
|
-
AVAILABLE_ORDERS = [:alphabetic, :random, :defined] # :nodoc:
|
|
126
|
+
AVAILABLE_ORDERS = [:alphabetic, :random, :defined].freeze # :nodoc:
|
|
126
127
|
|
|
127
128
|
class << self
|
|
128
129
|
# Indicates whether the test is parallel safe.
|
|
@@ -150,6 +151,48 @@ module Test
|
|
|
150
151
|
true
|
|
151
152
|
end
|
|
152
153
|
|
|
154
|
+
# Indicates whether tests without assertions are notified.
|
|
155
|
+
# This returns `false` by default. Use
|
|
156
|
+
# {.notify_no_assertions=} to change it. The default can also
|
|
157
|
+
# be changed by `--notify-no-assertions`.
|
|
158
|
+
#
|
|
159
|
+
# @return [Boolean]
|
|
160
|
+
#
|
|
161
|
+
# @since 3.7.9
|
|
162
|
+
def notify_no_assertions?
|
|
163
|
+
false
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Sets whether tests without assertions are notified. Sub
|
|
167
|
+
# test cases inherit it.
|
|
168
|
+
#
|
|
169
|
+
# @example Notify tests without assertions
|
|
170
|
+
# class TestMyClass < Test::Unit::TestCase
|
|
171
|
+
# self.notify_no_assertions = true
|
|
172
|
+
#
|
|
173
|
+
# def test_no_assertions
|
|
174
|
+
# # This is notified.
|
|
175
|
+
# end
|
|
176
|
+
# end
|
|
177
|
+
#
|
|
178
|
+
# @param boolean [Boolean]
|
|
179
|
+
# @return [void]
|
|
180
|
+
#
|
|
181
|
+
# @since 3.7.9
|
|
182
|
+
def notify_no_assertions=(boolean)
|
|
183
|
+
define_singleton_method(:notify_no_assertions?) do
|
|
184
|
+
boolean
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def test_suite?
|
|
189
|
+
false
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def test_case?
|
|
193
|
+
true
|
|
194
|
+
end
|
|
195
|
+
|
|
153
196
|
def inherited(sub_class) # :nodoc:
|
|
154
197
|
DESCENDANTS << sub_class
|
|
155
198
|
super
|
|
@@ -614,7 +657,7 @@ module Test
|
|
|
614
657
|
# and errors in result.
|
|
615
658
|
def run(worker_context)
|
|
616
659
|
begin
|
|
617
|
-
|
|
660
|
+
if worker_context.class.test_result?
|
|
618
661
|
result = worker_context
|
|
619
662
|
worker_context = WorkerContext.new(nil, nil, result)
|
|
620
663
|
end
|
|
@@ -658,16 +701,17 @@ module Test
|
|
|
658
701
|
raise unless handle_exception(e)
|
|
659
702
|
end
|
|
660
703
|
end
|
|
704
|
+
notify_no_assertions
|
|
661
705
|
@internal_data.test_finished
|
|
662
706
|
result.add_run
|
|
663
707
|
yield(FINISHED, name)
|
|
664
|
-
yield(FINISHED_OBJECT, self)
|
|
665
708
|
ensure
|
|
666
709
|
# @_result = nil # For test-spec's after_all :<
|
|
667
710
|
(instance_variables - instance_variables_before).each do |name|
|
|
668
711
|
remove_instance_variable(name)
|
|
669
712
|
end
|
|
670
713
|
end
|
|
714
|
+
yield(FINISHED_OBJECT, self)
|
|
671
715
|
end
|
|
672
716
|
|
|
673
717
|
# Called before every test method runs. Can be used
|
|
@@ -901,6 +945,29 @@ module Test
|
|
|
901
945
|
@internal_data.passed?
|
|
902
946
|
end
|
|
903
947
|
|
|
948
|
+
# Returns the number of assertions in this test. This is for
|
|
949
|
+
# Minitest compatibility.
|
|
950
|
+
#
|
|
951
|
+
# @return [Integer]
|
|
952
|
+
def assertions
|
|
953
|
+
@internal_data.n_assertions
|
|
954
|
+
end
|
|
955
|
+
|
|
956
|
+
# Sets the number of assertions in this test. Increased
|
|
957
|
+
# assertions are also added to the current result. Decreasing
|
|
958
|
+
# is ignored. This is for Minitest compatibility.
|
|
959
|
+
#
|
|
960
|
+
# @example Add an assertion without an assertion method
|
|
961
|
+
# self.assertions += 1
|
|
962
|
+
#
|
|
963
|
+
# @param n_assertions [Integer]
|
|
964
|
+
# @return [void]
|
|
965
|
+
def assertions=(n_assertions)
|
|
966
|
+
(n_assertions - assertions).times do
|
|
967
|
+
add_assertion
|
|
968
|
+
end
|
|
969
|
+
end
|
|
970
|
+
|
|
904
971
|
# Notify that a problem is occurred in the test. It means that
|
|
905
972
|
# the test is a failed test. If any failed tests exist in test
|
|
906
973
|
# suites, the test process exits with failure exit status.
|
|
@@ -970,6 +1037,16 @@ module Test
|
|
|
970
1037
|
end
|
|
971
1038
|
end
|
|
972
1039
|
|
|
1040
|
+
def notify_no_assertions
|
|
1041
|
+
return unless self.class.notify_no_assertions?
|
|
1042
|
+
return unless passed?
|
|
1043
|
+
return if skipped?
|
|
1044
|
+
return unless assertions.zero?
|
|
1045
|
+
path, line = self.class.instance_method(@method_name).source_location
|
|
1046
|
+
notify("<#{self.class}\##{@method_name}> has no assertions",
|
|
1047
|
+
:backtrace => ["#{path}:#{line}"])
|
|
1048
|
+
end
|
|
1049
|
+
|
|
973
1050
|
def handle_exception(exception)
|
|
974
1051
|
self.class.exception_handlers.each do |handler|
|
|
975
1052
|
if handler.respond_to?(:call)
|
|
@@ -983,6 +1060,7 @@ module Test
|
|
|
983
1060
|
end
|
|
984
1061
|
|
|
985
1062
|
def add_assertion
|
|
1063
|
+
@internal_data.n_assertions += 1
|
|
986
1064
|
current_result.add_assertion
|
|
987
1065
|
end
|
|
988
1066
|
|
|
@@ -991,15 +1069,19 @@ module Test
|
|
|
991
1069
|
attr_reader :test_data_label, :test_data
|
|
992
1070
|
attr_accessor :run_context
|
|
993
1071
|
attr_accessor :worker_id
|
|
1072
|
+
attr_accessor :n_assertions
|
|
994
1073
|
def initialize
|
|
995
1074
|
@start_time = nil
|
|
996
1075
|
@elapsed_time = nil
|
|
997
1076
|
@passed = true
|
|
998
1077
|
@interrupted = false
|
|
1078
|
+
@omitted = false
|
|
1079
|
+
@errored = false
|
|
999
1080
|
@test_data_label = nil
|
|
1000
1081
|
@test_data = nil
|
|
1001
1082
|
@run_context = nil
|
|
1002
1083
|
@worker_id = nil
|
|
1084
|
+
@n_assertions = 0
|
|
1003
1085
|
end
|
|
1004
1086
|
|
|
1005
1087
|
def passed?
|
|
@@ -1010,6 +1092,14 @@ module Test
|
|
|
1010
1092
|
@interrupted
|
|
1011
1093
|
end
|
|
1012
1094
|
|
|
1095
|
+
def omitted?
|
|
1096
|
+
@omitted
|
|
1097
|
+
end
|
|
1098
|
+
|
|
1099
|
+
def errored?
|
|
1100
|
+
@errored
|
|
1101
|
+
end
|
|
1102
|
+
|
|
1013
1103
|
def assign_test_data(label, data)
|
|
1014
1104
|
@test_data_label = label
|
|
1015
1105
|
@test_data = data
|
|
@@ -1035,13 +1125,24 @@ module Test
|
|
|
1035
1125
|
@interrupted = true
|
|
1036
1126
|
end
|
|
1037
1127
|
|
|
1128
|
+
def omitted
|
|
1129
|
+
@omitted = true
|
|
1130
|
+
end
|
|
1131
|
+
|
|
1132
|
+
def errored
|
|
1133
|
+
@errored = true
|
|
1134
|
+
end
|
|
1135
|
+
|
|
1038
1136
|
def marshal_dump
|
|
1039
1137
|
{
|
|
1040
1138
|
start_time: @start_time,
|
|
1041
1139
|
elapsed_time: @elapsed_time,
|
|
1042
1140
|
passed: @passed,
|
|
1043
1141
|
interrupted: @interrupted,
|
|
1142
|
+
omitted: @omitted,
|
|
1143
|
+
errored: @errored,
|
|
1044
1144
|
test_data_label: @test_data_label,
|
|
1145
|
+
n_assertions: @n_assertions,
|
|
1045
1146
|
}
|
|
1046
1147
|
end
|
|
1047
1148
|
|
|
@@ -1050,7 +1151,10 @@ module Test
|
|
|
1050
1151
|
@elapsed_time = data[:elapsed_time]
|
|
1051
1152
|
@passed = data[:passed]
|
|
1052
1153
|
@interrupted = data[:interrupted]
|
|
1154
|
+
@omitted = data[:omitted]
|
|
1155
|
+
@errored = data[:errored]
|
|
1053
1156
|
@test_data_label = data[:test_data_label]
|
|
1157
|
+
@n_assertions = data[:n_assertions]
|
|
1054
1158
|
end
|
|
1055
1159
|
end
|
|
1056
1160
|
end
|
data/lib/test/unit/testresult.rb
CHANGED
|
@@ -31,10 +31,17 @@ module Test
|
|
|
31
31
|
include TestResultOmissionSupport
|
|
32
32
|
include TestResultNotificationSupport
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
class << self
|
|
35
|
+
# Returns true if it should be wrapped by WorkerContext
|
|
36
|
+
def test_result?
|
|
37
|
+
true
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
FINISHED = (name + "::FINISHED").freeze
|
|
42
|
+
CHANGED = (name + "::CHANGED").freeze
|
|
43
|
+
PASS_ASSERTION = (name + "::PASS_ASSERTION").freeze
|
|
44
|
+
FAULT = (name + "::FAULT").freeze
|
|
38
45
|
|
|
39
46
|
attr_reader :run_count, :pass_count, :assertion_count, :faults
|
|
40
47
|
|
data/lib/test/unit/testsuite.rb
CHANGED
|
@@ -19,16 +19,26 @@ module Test
|
|
|
19
19
|
# has a suite method as simply providing a way to get a
|
|
20
20
|
# meaningful TestSuite instance.
|
|
21
21
|
class TestSuite
|
|
22
|
+
class << self
|
|
23
|
+
def test_suite?
|
|
24
|
+
true
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_case?
|
|
28
|
+
false
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
22
32
|
attr_reader :name, :tests, :test_case, :start_time, :elapsed_time
|
|
23
33
|
|
|
24
34
|
# Test suite that has higher priority is ran prior to
|
|
25
35
|
# test suites that have lower priority.
|
|
26
36
|
attr_accessor :priority
|
|
27
37
|
|
|
28
|
-
STARTED = name + "::STARTED"
|
|
29
|
-
STARTED_OBJECT = name + "::STARTED::OBJECT"
|
|
30
|
-
FINISHED = name + "::FINISHED"
|
|
31
|
-
FINISHED_OBJECT = name + "::FINISHED::OBJECT"
|
|
38
|
+
STARTED = (name + "::STARTED").freeze
|
|
39
|
+
STARTED_OBJECT = (name + "::STARTED::OBJECT").freeze
|
|
40
|
+
FINISHED = (name + "::FINISHED").freeze
|
|
41
|
+
FINISHED_OBJECT = (name + "::FINISHED::OBJECT").freeze
|
|
32
42
|
|
|
33
43
|
# Creates a new TestSuite with the given name.
|
|
34
44
|
def initialize(name="Unnamed TestSuite", test_case=nil)
|
|
@@ -43,7 +53,7 @@ module Test
|
|
|
43
53
|
def find(name)
|
|
44
54
|
return self if @name == name
|
|
45
55
|
@tests.each do |test|
|
|
46
|
-
if test.
|
|
56
|
+
if test.class.test_suite?
|
|
47
57
|
t = test.find(name)
|
|
48
58
|
return t if t
|
|
49
59
|
else
|
|
@@ -15,9 +15,9 @@ module Test
|
|
|
15
15
|
# Provides an interface to write any given UI against,
|
|
16
16
|
# hopefully making it easy to write new UIs.
|
|
17
17
|
class TestRunnerMediator
|
|
18
|
-
RESET = name + "::RESET"
|
|
19
|
-
STARTED = name + "::STARTED"
|
|
20
|
-
FINISHED = name + "::FINISHED"
|
|
18
|
+
RESET = (name + "::RESET").freeze
|
|
19
|
+
STARTED = (name + "::STARTED").freeze
|
|
20
|
+
FINISHED = (name + "::FINISHED").freeze
|
|
21
21
|
|
|
22
22
|
include Util::Observable
|
|
23
23
|
|
|
@@ -15,7 +15,7 @@ module Test
|
|
|
15
15
|
# events.
|
|
16
16
|
module Observable
|
|
17
17
|
# We use this for defaults since nil might mean something
|
|
18
|
-
NOTHING = "NOTHING/#{__id__}"
|
|
18
|
+
NOTHING = "NOTHING/#{__id__}".freeze
|
|
19
19
|
|
|
20
20
|
# Adds the passed proc as a listener on the
|
|
21
21
|
# channel indicated by channel_name. listener_key
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require "monitor"
|
|
2
|
+
|
|
1
3
|
module Test
|
|
2
4
|
module Unit
|
|
3
5
|
module Util
|
|
@@ -6,6 +8,12 @@ module Test
|
|
|
6
8
|
# Returns output for standard output and standard
|
|
7
9
|
# error as string.
|
|
8
10
|
#
|
|
11
|
+
# Calls from multiple threads are serialized. Note that
|
|
12
|
+
# output written by other threads while the block is
|
|
13
|
+
# running is also captured. Don't call #capture_output in
|
|
14
|
+
# another thread or fiber while the block is running. It
|
|
15
|
+
# blocks or raises ThreadError.
|
|
16
|
+
#
|
|
9
17
|
# Example:
|
|
10
18
|
#
|
|
11
19
|
# capture_output do
|
|
@@ -13,17 +21,40 @@ module Test
|
|
|
13
21
|
# warn("stderr")
|
|
14
22
|
# end # -> ["stdout\n", "stderr\n"]
|
|
15
23
|
def capture_output
|
|
16
|
-
require
|
|
24
|
+
require "stringio"
|
|
17
25
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
capture_output_monitor.synchronize do
|
|
27
|
+
output = StringIO.new
|
|
28
|
+
error = StringIO.new
|
|
29
|
+
stdout_save, stderr_save = $stdout, $stderr
|
|
30
|
+
$stdout, $stderr = output, error
|
|
31
|
+
begin
|
|
32
|
+
yield
|
|
33
|
+
[output.string, error.string]
|
|
34
|
+
ensure
|
|
35
|
+
$stdout, $stderr = stdout_save, stderr_save
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Same as #capture_output. This is for Minitest
|
|
41
|
+
# compatibility.
|
|
42
|
+
alias_method :capture_io, :capture_output
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
# Monitor, not Mutex, to allow nested #capture_output. A
|
|
46
|
+
# monitor per Ractor because $stdout/$stderr are Ractor
|
|
47
|
+
# local.
|
|
48
|
+
if defined?(Ractor.store_if_absent)
|
|
49
|
+
def capture_output_monitor
|
|
50
|
+
Ractor.store_if_absent(:test_unit_capture_output_monitor) do
|
|
51
|
+
Monitor.new
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
else
|
|
55
|
+
CAPTURE_MONITOR = Monitor.new # :nodoc:
|
|
56
|
+
def capture_output_monitor
|
|
57
|
+
CAPTURE_MONITOR
|
|
27
58
|
end
|
|
28
59
|
end
|
|
29
60
|
end
|
data/lib/test/unit/version.rb
CHANGED
data/lib/test/unit.rb
CHANGED
|
@@ -508,6 +508,31 @@ module Test # :nodoc:
|
|
|
508
508
|
hook.call
|
|
509
509
|
end
|
|
510
510
|
end
|
|
511
|
+
|
|
512
|
+
# @api private
|
|
513
|
+
@@box_available_flag = nil
|
|
514
|
+
|
|
515
|
+
# @api private
|
|
516
|
+
def disable_box_forcibly
|
|
517
|
+
v = @@box_available_flag
|
|
518
|
+
@@box_available_flag = false
|
|
519
|
+
yield
|
|
520
|
+
ensure
|
|
521
|
+
@@box_available_flag = v
|
|
522
|
+
end
|
|
523
|
+
|
|
524
|
+
# @api private
|
|
525
|
+
def box_available?
|
|
526
|
+
return @@box_available_flag unless @@box_available_flag.nil?
|
|
527
|
+
@@box_available_flag = defined?(Ruby::Box) && Ruby::Box.enabled?
|
|
528
|
+
if @@box_available_flag
|
|
529
|
+
major, minor, _ = Ruby::VERSION.split('.')
|
|
530
|
+
if major.to_i < 4 || major.to_i == 4 && minor.to_i < 1
|
|
531
|
+
@@box_available_flag = false
|
|
532
|
+
end
|
|
533
|
+
end
|
|
534
|
+
@@box_available_flag
|
|
535
|
+
end
|
|
511
536
|
end
|
|
512
537
|
end
|
|
513
538
|
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: 3.7.
|
|
4
|
+
version: 3.7.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kouhei Sutou
|
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
135
135
|
- !ruby/object:Gem::Version
|
|
136
136
|
version: '0'
|
|
137
137
|
requirements: []
|
|
138
|
-
rubygems_version: 4.0.
|
|
138
|
+
rubygems_version: 4.0.20
|
|
139
139
|
specification_version: 4
|
|
140
140
|
summary: An xUnit family unit testing framework for Ruby.
|
|
141
141
|
test_files: []
|