test-unit 3.6.7 → 3.6.8
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/README.md +1 -1
- data/Rakefile +1 -1
- data/bin/test-unit +5 -0
- data/doc/text/getting-started.md +24 -150
- data/doc/text/how-to.md +4 -4
- data/doc/text/news.md +42 -0
- data/lib/test/unit/autorunner.rb +13 -0
- data/lib/test/unit/test-run-context.rb +16 -0
- data/lib/test/unit/test-suite-runner.rb +9 -7
- data/lib/test/unit/test-suite-thread-runner.rb +31 -16
- data/lib/test/unit/test-thread-run-context.rb +20 -0
- data/lib/test/unit/testcase.rb +13 -1
- data/lib/test/unit/testresult.rb +1 -1
- data/lib/test/unit/testsuite.rb +7 -3
- data/lib/test/unit/ui/testrunnermediator.rb +4 -4
- data/lib/test/unit/version.rb +1 -1
- data/lib/test/unit.rb +3 -3
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bde71a96227f24a82f006152344801538ecd9ff4cb21cbbc8ce52e28b53d997
|
4
|
+
data.tar.gz: 575aadde532cc7b3c89d35bbf73ae0a01b616656b3ae31e671854cdcfa4f6518
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17edcd04d2ba7688110a108e0fc4b2381e066082deb77523cf14e38bbce04ab79fc46e6821d312791b67b038f3d5d2c8989cc85680a40bc3cdf6fad604c0f38d
|
7
|
+
data.tar.gz: 26516f87e2e53c5830f992b313f474b1b61f79bcc5343a5f1f300c90134ffd3ef2d2b1a3bba509968af85b0e28da2a82f9aa21293769db886e4c6027ca4d3406
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
[](http://badge.fury.io/rb/test-unit)
|
4
4
|
[](https://github.com/test-unit/test-unit/actions/workflows/test.yml?query=branch%3Amaster+)
|
5
5
|
|
6
|
-
*
|
6
|
+
* https://test-unit.github.io/
|
7
7
|
* https://github.com/test-unit/test-unit
|
8
8
|
|
9
9
|
## Description
|
data/Rakefile
CHANGED
data/bin/test-unit
ADDED
data/doc/text/getting-started.md
CHANGED
@@ -22,178 +22,52 @@ You will find the following lines.
|
|
22
22
|
!!!plain
|
23
23
|
gem list
|
24
24
|
...
|
25
|
-
bundler (
|
25
|
+
bundler (2.6.3, default: 2.6.2)
|
26
26
|
...
|
27
|
-
test-unit (3.
|
27
|
+
test-unit (3.6.8, 3.6.7)
|
28
28
|
~~~
|
29
29
|
|
30
30
|
## 3. Create gem template.
|
31
31
|
|
32
32
|
Next, create a gem template using `bundler` command.
|
33
33
|
This command generates package skeleton with a testing framework.
|
34
|
-
However, this command can't generate test templates for `test-unit`.
|
35
34
|
|
36
|
-
|
37
|
-
(It's similar to `unit-test`).
|
38
|
-
After that, replace some files for `test-unit`.
|
35
|
+
The `bundle gem -t test-unit sample` command will generate a gem template with the `test-unit` testing framework.
|
39
36
|
|
40
|
-
|
41
|
-
|
42
|
-
~~~
|
43
|
-
!!!plain
|
44
|
-
.
|
45
|
-
|-- Gemfile
|
46
|
-
|-- README.md
|
47
|
-
|-- Rakefile
|
48
|
-
|-- bin
|
49
|
-
| |-- console
|
50
|
-
| `-- setup
|
51
|
-
|-- lib
|
52
|
-
| |-- sample
|
53
|
-
| | `-- version.rb
|
54
|
-
| `-- sample.rb
|
55
|
-
|-- sample.gemspec # <- Modify
|
56
|
-
`-- test
|
57
|
-
|-- sample_test.rb # <- Modify
|
58
|
-
`-- test_helper.rb # <- Modify
|
59
|
-
~~~
|
60
|
-
|
61
|
-
## 4. Edit files for `test-unit`
|
62
|
-
|
63
|
-
### 4.1. Edit gemspec
|
64
|
-
|
65
|
-
Edit `sample.gemspec` like the below.
|
66
|
-
Replace `minitest` line to `test-unit`.
|
67
|
-
|
68
|
-
Before
|
69
|
-
|
70
|
-
~~~
|
71
|
-
!!!ruby
|
72
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
73
|
-
~~~
|
74
|
-
|
75
|
-
After
|
76
|
-
|
77
|
-
~~~
|
78
|
-
!!!ruby
|
79
|
-
spec.add_development_dependency "test-unit", "~> 3.2.3"
|
80
|
-
~~~
|
81
|
-
|
82
|
-
### 4.2. Edit `test/test_helper.rb`
|
83
|
-
|
84
|
-
Next, edit the `test/test_helper.rb` file.
|
85
|
-
|
86
|
-
Before
|
87
|
-
|
88
|
-
~~~
|
89
|
-
!!!ruby
|
90
|
-
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
91
|
-
require 'sample'
|
92
|
-
|
93
|
-
require 'minitest/autorun' # <-- Modify this line.
|
94
|
-
~~~
|
95
|
-
|
96
|
-
After
|
97
|
-
|
98
|
-
~~~
|
99
|
-
!!!ruby
|
100
|
-
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
101
|
-
require 'sample'
|
102
|
-
|
103
|
-
require 'test/unit' # <-- After modification.
|
104
|
-
~~~
|
105
|
-
|
106
|
-
### 4.3 Rakefile (No edit)
|
107
|
-
|
108
|
-
This file doesn't need to modify.
|
109
|
-
The output is the below.
|
110
|
-
|
111
|
-
~~~
|
112
|
-
!!!ruby
|
113
|
-
require "bundler/gem_tasks"
|
114
|
-
require "rake/testtask"
|
115
|
-
|
116
|
-
Rake::TestTask.new(:test) do |t|
|
117
|
-
t.libs << "test"
|
118
|
-
t.libs << "lib"
|
119
|
-
t.test_files = FileList['test/**/*_test.rb']
|
120
|
-
end
|
121
|
-
|
122
|
-
task :default => :test
|
123
|
-
~~~
|
124
|
-
|
125
|
-
### 4.4 Edit `test/sample_test.rb`
|
126
|
-
|
127
|
-
The bundler generate the file `test/sample_test.rb`.
|
128
|
-
This file originally templates for `minitest`.
|
129
|
-
|
130
|
-
Let's modify this file for `test-unit`
|
131
|
-
|
132
|
-
before
|
133
|
-
|
134
|
-
~~~
|
135
|
-
!!!ruby
|
136
|
-
require 'test_helper'
|
137
|
-
|
138
|
-
class SampleTest < Minitest::Test # <- Modify here
|
139
|
-
def test_that_it_has_a_version_number
|
140
|
-
refute_nil ::Sample::VERSION
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_it_does_something_useful
|
144
|
-
assert false
|
145
|
-
end
|
146
|
-
end
|
147
|
-
~~~
|
148
|
-
|
149
|
-
After
|
150
|
-
|
151
|
-
~~~
|
152
|
-
!!!ruby
|
153
|
-
require 'test_helper'
|
154
|
-
|
155
|
-
class SampleTest < Test::Unit::TestCase # <- After modification
|
156
|
-
def test_that_it_has_a_version_number
|
157
|
-
refute_nil ::Sample::VERSION
|
158
|
-
end
|
159
|
-
|
160
|
-
def test_it_does_something_useful
|
161
|
-
assert false
|
162
|
-
end
|
163
|
-
end
|
164
|
-
~~~
|
165
|
-
|
166
|
-
## 5. Execute test.
|
37
|
+
## 4. Execute test.
|
167
38
|
|
168
39
|
The `rake test` command execute test scenarios in the `test` directory.
|
169
40
|
Now it tries to two tests. One will success the other one fails.
|
170
41
|
|
171
42
|
~~~
|
172
43
|
!!!plain
|
173
|
-
rake test
|
174
|
-
Loaded suite
|
175
|
-
/path/to/ruby/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/rake_test_loader
|
44
|
+
$ rake test
|
45
|
+
Loaded suite /path/to/ruby/lib/ruby/gems/3.4.0/gems/rake-13.2.1/lib/rake/rake_test_loader
|
176
46
|
Started
|
177
47
|
F
|
178
48
|
================================================================================
|
179
|
-
Failure:
|
180
|
-
|
181
|
-
/path/to/sample/test/sample_test.rb:9:in `test_it_does_something_useful'
|
182
|
-
6: end
|
183
|
-
7:
|
184
|
-
8: def test_it_does_something_useful
|
185
|
-
=> 9: assert false
|
49
|
+
Failure: test: something useful(SampleTest)
|
50
|
+
/path/to/sample/test/sample_test.rb:13:in 'block in <class:SampleTest>'
|
186
51
|
10: end
|
187
|
-
11:
|
52
|
+
11:
|
53
|
+
12: test "something useful" do
|
54
|
+
=> 13: assert_equal("expected", "actual")
|
55
|
+
14: end
|
56
|
+
15: end
|
57
|
+
<"expected"> expected but was
|
58
|
+
<"actual">
|
59
|
+
|
60
|
+
diff:
|
61
|
+
? expected
|
62
|
+
? a ual
|
63
|
+
? ???? ??
|
188
64
|
================================================================================
|
189
|
-
.
|
190
|
-
|
191
|
-
Finished in 0.011521 seconds.
|
65
|
+
Finished in 0.013737 seconds.
|
192
66
|
--------------------------------------------------------------------------------
|
193
67
|
2 tests, 2 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
|
194
68
|
50% passed
|
195
69
|
--------------------------------------------------------------------------------
|
196
|
-
|
70
|
+
145.59 tests/s, 145.59 assertions/s
|
197
71
|
rake aborted!
|
198
72
|
Command failed with status (1)
|
199
73
|
|
@@ -201,7 +75,7 @@ Tasks: TOP => test
|
|
201
75
|
(See full trace by running task with --trace)
|
202
76
|
~~~
|
203
77
|
|
204
|
-
##
|
78
|
+
## 5. Create original tests.
|
205
79
|
|
206
80
|
Let's create your original tests with the following rules.
|
207
81
|
|
@@ -239,7 +113,7 @@ module Sub
|
|
239
113
|
end
|
240
114
|
~~~
|
241
115
|
|
242
|
-
##
|
116
|
+
## 6. For more information
|
243
117
|
|
244
118
|
Let's read the official document.
|
245
119
|
|
data/doc/text/how-to.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
## Run all tests
|
4
4
|
|
5
|
-
To make it easy to run all your tests, you can add a `
|
5
|
+
To make it easy to run all your tests, you can add a `run.rb` script
|
6
6
|
to your `test` directory. A simple example might look like:
|
7
7
|
|
8
8
|
base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
@@ -17,19 +17,19 @@ to your `test` directory. A simple example might look like:
|
|
17
17
|
|
18
18
|
Then it's easy to run tests via the command line with,
|
19
19
|
|
20
|
-
$ ruby test/
|
20
|
+
$ ruby test/run.rb
|
21
21
|
|
22
22
|
## Change test runner via the command line
|
23
23
|
|
24
24
|
The output format can be changed via the command line with
|
25
25
|
the `--runner` option. Simply tack it to the end:
|
26
26
|
|
27
|
-
ruby test/
|
27
|
+
ruby test/run.rb --runner emacs
|
28
28
|
|
29
29
|
|
30
30
|
## Configure test-unit per-project
|
31
31
|
|
32
|
-
Test::Unit reads
|
32
|
+
Test::Unit reads `~/.test-unit.yml` or `test-unit.yml` in the current working
|
33
33
|
directory as Test::Unit's configuration file. It can contain the following
|
34
34
|
settings:
|
35
35
|
|
data/doc/text/news.md
CHANGED
@@ -1,5 +1,47 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 3.6.8 - 2025-04-05 {#version-3-6-8}
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* `test-unit`: Added. You can use this instead of creating a custom
|
8
|
+
test run script.
|
9
|
+
* GH-288
|
10
|
+
* GH-289
|
11
|
+
* GH-291
|
12
|
+
* Suggested by gemmaro
|
13
|
+
|
14
|
+
* Updated the "how to" document.
|
15
|
+
* GH-292
|
16
|
+
* GH-293
|
17
|
+
* GH-294
|
18
|
+
|
19
|
+
* Updated the "getting started" document.
|
20
|
+
* GH-295
|
21
|
+
* GH-296
|
22
|
+
|
23
|
+
* Added support for `.test-unit` configuration file. It's useful for
|
24
|
+
specifying default options, and is handier than using `.test-unit.yml`.
|
25
|
+
* GH-300
|
26
|
+
* GH-302
|
27
|
+
|
28
|
+
### Fixes
|
29
|
+
|
30
|
+
* parallel: thread: Fixed shutdown execution order.
|
31
|
+
* GH-282
|
32
|
+
|
33
|
+
* testcase: Fixed a bug that instance variables added during the test
|
34
|
+
runs are not garbage collected after each test run.
|
35
|
+
* GH-235
|
36
|
+
* GH-303
|
37
|
+
* Reported by akira yamada
|
38
|
+
|
39
|
+
### Thanks
|
40
|
+
|
41
|
+
* gemmaro
|
42
|
+
|
43
|
+
* akira yamada
|
44
|
+
|
3
45
|
## 3.6.7 - 2024-12-17 {#version-3-6-7}
|
4
46
|
|
5
47
|
### Fixes
|
data/lib/test/unit/autorunner.rb
CHANGED
@@ -171,6 +171,10 @@ module Test
|
|
171
171
|
else
|
172
172
|
load_global_config
|
173
173
|
end
|
174
|
+
plain_text_config_file = ".test-unit"
|
175
|
+
if File.exist?(plain_text_config_file)
|
176
|
+
load_plain_text_config(plain_text_config_file)
|
177
|
+
end
|
174
178
|
yield(self) if block_given?
|
175
179
|
end
|
176
180
|
|
@@ -515,6 +519,15 @@ module Test
|
|
515
519
|
@runner_options = @runner_options.merge(runner_options)
|
516
520
|
end
|
517
521
|
|
522
|
+
def load_plain_text_config(file)
|
523
|
+
require "shellwords"
|
524
|
+
File.readlines(file, chomp: true).each do |line|
|
525
|
+
next if line.empty?
|
526
|
+
args = Shellwords.shellsplit(line)
|
527
|
+
@default_arguments.concat(args)
|
528
|
+
end
|
529
|
+
end
|
530
|
+
|
518
531
|
private
|
519
532
|
def default_runner
|
520
533
|
runner = self.class.default_runner
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#--
|
2
|
+
#
|
3
|
+
# Author:: Tsutomu Katsube.
|
4
|
+
# Copyright:: Copyright (c) 2025 Tsutomu Katsube. All rights reserved.
|
5
|
+
# License:: Ruby license.
|
6
|
+
|
7
|
+
module Test
|
8
|
+
module Unit
|
9
|
+
class TestRunContext
|
10
|
+
attr_reader :runner_class
|
11
|
+
def initialize(runner_class)
|
12
|
+
@runner_class = runner_class
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -8,13 +8,15 @@
|
|
8
8
|
|
9
9
|
require "etc"
|
10
10
|
|
11
|
+
require_relative "test-run-context"
|
12
|
+
|
11
13
|
module Test
|
12
14
|
module Unit
|
13
15
|
class TestSuiteRunner
|
14
16
|
@n_workers = Etc.respond_to?(:nprocessors) ? Etc.nprocessors : 1
|
15
17
|
class << self
|
16
18
|
def run_all_tests
|
17
|
-
yield
|
19
|
+
yield(TestRunContext.new(self))
|
18
20
|
end
|
19
21
|
|
20
22
|
def n_workers
|
@@ -30,11 +32,11 @@ module Test
|
|
30
32
|
@test_suite = test_suite
|
31
33
|
end
|
32
34
|
|
33
|
-
def run(result, &progress_block)
|
35
|
+
def run(result, run_context: nil, &progress_block)
|
34
36
|
yield(TestSuite::STARTED, @test_suite.name)
|
35
37
|
yield(TestSuite::STARTED_OBJECT, @test_suite)
|
36
38
|
run_startup(result)
|
37
|
-
run_tests(result, &progress_block)
|
39
|
+
run_tests(result, run_context: run_context, &progress_block)
|
38
40
|
ensure
|
39
41
|
begin
|
40
42
|
run_shutdown(result)
|
@@ -55,13 +57,13 @@ module Test
|
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
58
|
-
def run_tests(result, &progress_block)
|
60
|
+
def run_tests(result, run_context: nil, &progress_block)
|
59
61
|
@test_suite.tests.each do |test|
|
60
|
-
run_test(test, result, &progress_block)
|
62
|
+
run_test(test, result, run_context: run_context, &progress_block)
|
61
63
|
end
|
62
64
|
end
|
63
65
|
|
64
|
-
def run_test(test, result)
|
66
|
+
def run_test(test, result, run_context: nil)
|
65
67
|
finished_is_yielded = false
|
66
68
|
finished_object_is_yielded = false
|
67
69
|
previous_event_name = nil
|
@@ -91,7 +93,7 @@ module Test
|
|
91
93
|
end
|
92
94
|
|
93
95
|
if test.method(:run).arity == -2
|
94
|
-
test.run(result,
|
96
|
+
test.run(result, run_context: run_context, &event_listener)
|
95
97
|
else
|
96
98
|
# For backward compatibility. There are scripts that overrides
|
97
99
|
# Test::Unit::TestCase#run without keyword arguments.
|
@@ -6,26 +6,29 @@
|
|
6
6
|
|
7
7
|
require_relative "sub-test-result"
|
8
8
|
require_relative "test-suite-runner"
|
9
|
+
require_relative "test-thread-run-context"
|
9
10
|
|
10
11
|
module Test
|
11
12
|
module Unit
|
12
13
|
class TestSuiteThreadRunner < TestSuiteRunner
|
13
|
-
@task_queue = Thread::Queue.new
|
14
14
|
class << self
|
15
|
-
def task_queue
|
16
|
-
@task_queue
|
17
|
-
end
|
18
|
-
|
19
15
|
def run_all_tests
|
20
16
|
n_workers = TestSuiteRunner.n_workers
|
21
17
|
|
18
|
+
queue = Thread::Queue.new
|
19
|
+
shutdowns = []
|
20
|
+
yield(TestThreadRunContext.new(self, queue, shutdowns))
|
21
|
+
n_workers.times do
|
22
|
+
queue << nil
|
23
|
+
end
|
24
|
+
|
22
25
|
workers = []
|
23
26
|
sub_exceptions = []
|
24
27
|
n_workers.times do |i|
|
25
28
|
workers << Thread.new(i) do |worker_id|
|
26
29
|
begin
|
27
30
|
loop do
|
28
|
-
task =
|
31
|
+
task = queue.pop
|
29
32
|
break if task.nil?
|
30
33
|
catch do |stop_tag|
|
31
34
|
task.call(stop_tag)
|
@@ -36,31 +39,43 @@ module Test
|
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
39
|
-
|
40
|
-
yield
|
41
|
-
|
42
|
-
n_workers.times do
|
43
|
-
@task_queue << nil
|
44
|
-
end
|
45
42
|
workers.each(&:join)
|
43
|
+
|
44
|
+
shutdowns.each(&:call)
|
46
45
|
sub_exceptions.each do |exception|
|
47
46
|
raise exception
|
48
47
|
end
|
49
48
|
end
|
50
49
|
end
|
51
50
|
|
51
|
+
def run(result, run_context: nil, &progress_block)
|
52
|
+
yield(TestSuite::STARTED, @test_suite.name)
|
53
|
+
yield(TestSuite::STARTED_OBJECT, @test_suite)
|
54
|
+
run_startup(result)
|
55
|
+
run_tests(result, run_context: run_context, &progress_block)
|
56
|
+
ensure
|
57
|
+
run_context.shutdowns << lambda do
|
58
|
+
begin
|
59
|
+
run_shutdown(result)
|
60
|
+
ensure
|
61
|
+
yield(TestSuite::FINISHED, @test_suite.name)
|
62
|
+
yield(TestSuite::FINISHED_OBJECT, @test_suite)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
52
67
|
private
|
53
|
-
def run_tests(result, &progress_block)
|
68
|
+
def run_tests(result, run_context: nil, &progress_block)
|
54
69
|
@test_suite.tests.each do |test|
|
55
70
|
if test.is_a?(TestSuite) or not @test_suite.parallel_safe?
|
56
|
-
run_test(test, result, &progress_block)
|
71
|
+
run_test(test, result, run_context: run_context, &progress_block)
|
57
72
|
else
|
58
73
|
task = lambda do |stop_tag|
|
59
74
|
sub_result = SubTestResult.new(result)
|
60
75
|
sub_result.stop_tag = stop_tag
|
61
|
-
run_test(test, sub_result, &progress_block)
|
76
|
+
run_test(test, sub_result, run_context: run_context, &progress_block)
|
62
77
|
end
|
63
|
-
|
78
|
+
run_context.queue << task
|
64
79
|
end
|
65
80
|
end
|
66
81
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#--
|
2
|
+
#
|
3
|
+
# Author:: Tsutomu Katsube.
|
4
|
+
# Copyright:: Copyright (c) 2025 Tsutomu Katsube. All rights reserved.
|
5
|
+
# License:: Ruby license.
|
6
|
+
|
7
|
+
require_relative "test-run-context"
|
8
|
+
|
9
|
+
module Test
|
10
|
+
module Unit
|
11
|
+
class TestThreadRunContext < TestRunContext
|
12
|
+
attr_reader :queue, :shutdowns
|
13
|
+
def initialize(runner_class, queue, shutdowns)
|
14
|
+
super(runner_class)
|
15
|
+
@queue = queue
|
16
|
+
@shutdowns = shutdowns
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/test/unit/testcase.rb
CHANGED
@@ -577,9 +577,11 @@ module Test
|
|
577
577
|
# Runs the individual test method represented by this
|
578
578
|
# instance of the fixture, collecting statistics, failures
|
579
579
|
# and errors in result.
|
580
|
-
def run(result,
|
580
|
+
def run(result, run_context: nil)
|
581
581
|
begin
|
582
582
|
@_result = result
|
583
|
+
instance_variables_before = instance_variables
|
584
|
+
@internal_data.run_context = run_context
|
583
585
|
@internal_data.test_started
|
584
586
|
yield(STARTED, name)
|
585
587
|
yield(STARTED_OBJECT, self)
|
@@ -621,6 +623,9 @@ module Test
|
|
621
623
|
yield(FINISHED_OBJECT, self)
|
622
624
|
ensure
|
623
625
|
# @_result = nil # For test-spec's after_all :<
|
626
|
+
(instance_variables - instance_variables_before).each do |name|
|
627
|
+
remove_instance_variable(name)
|
628
|
+
end
|
624
629
|
end
|
625
630
|
end
|
626
631
|
|
@@ -856,6 +861,11 @@ module Test
|
|
856
861
|
@internal_data.problem_occurred
|
857
862
|
end
|
858
863
|
|
864
|
+
# Returns test suite runner class for easy to test.
|
865
|
+
def runner_class
|
866
|
+
@internal_data.run_context.runner_class
|
867
|
+
end
|
868
|
+
|
859
869
|
# Notify that the test is passed. Normally, it is not needed
|
860
870
|
# because #run calls it automatically. If you want to override
|
861
871
|
# #run, it is not a good idea. Please contact test-unit
|
@@ -916,6 +926,7 @@ module Test
|
|
916
926
|
class InternalData
|
917
927
|
attr_reader :start_time, :elapsed_time
|
918
928
|
attr_reader :test_data_label, :test_data
|
929
|
+
attr_accessor :run_context
|
919
930
|
def initialize
|
920
931
|
@start_time = nil
|
921
932
|
@elapsed_time = nil
|
@@ -923,6 +934,7 @@ module Test
|
|
923
934
|
@interrupted = false
|
924
935
|
@test_data_label = nil
|
925
936
|
@test_data = nil
|
937
|
+
@run_context = nil
|
926
938
|
end
|
927
939
|
|
928
940
|
def passed?
|
data/lib/test/unit/testresult.rb
CHANGED
data/lib/test/unit/testsuite.rb
CHANGED
@@ -47,9 +47,13 @@ module Test
|
|
47
47
|
|
48
48
|
# Runs the tests and/or suites contained in this
|
49
49
|
# TestSuite.
|
50
|
-
def run(result,
|
51
|
-
|
52
|
-
|
50
|
+
def run(result, run_context: nil, &progress_block)
|
51
|
+
if run_context
|
52
|
+
runner_class = run_context.runner_class
|
53
|
+
else
|
54
|
+
runner_class = TestSuiteRunner
|
55
|
+
end
|
56
|
+
runner_class.new(self).run(result, run_context: run_context) do |event, *args|
|
53
57
|
case event
|
54
58
|
when STARTED
|
55
59
|
@start_time = Time.now
|
@@ -40,13 +40,13 @@ module Test
|
|
40
40
|
start_time = Time.now
|
41
41
|
begin
|
42
42
|
with_listener(result) do
|
43
|
-
@test_suite_runner_class.run_all_tests do
|
43
|
+
@test_suite_runner_class.run_all_tests do |run_context|
|
44
44
|
catch do |stop_tag|
|
45
45
|
result.stop_tag = stop_tag
|
46
46
|
notify_listeners(RESET, @suite.size)
|
47
47
|
notify_listeners(STARTED, result)
|
48
48
|
|
49
|
-
run_suite(result)
|
49
|
+
run_suite(result, run_context)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -65,11 +65,11 @@ module Test
|
|
65
65
|
#
|
66
66
|
# See GitHub#38
|
67
67
|
# https://github.com/test-unit/test-unit/issues/38
|
68
|
-
def run_suite(result=nil)
|
68
|
+
def run_suite(result=nil, run_context=nil)
|
69
69
|
if result.nil?
|
70
70
|
run
|
71
71
|
else
|
72
|
-
@suite.run(result,
|
72
|
+
@suite.run(result, run_context: run_context) do |channel, value|
|
73
73
|
notify_listeners(channel, value)
|
74
74
|
end
|
75
75
|
end
|
data/lib/test/unit/version.rb
CHANGED
data/lib/test/unit.rb
CHANGED
@@ -28,7 +28,7 @@ module Test # :nodoc:
|
|
28
28
|
#
|
29
29
|
# ## Notes
|
30
30
|
#
|
31
|
-
# Test::Unit has grown out of and
|
31
|
+
# Test::Unit has grown out of and superseded Lapidary.
|
32
32
|
#
|
33
33
|
#
|
34
34
|
# ## Feedback
|
@@ -69,7 +69,7 @@ module Test # :nodoc:
|
|
69
69
|
# Masaki Suketa, for his work on RubyUnit, which filled a vital need in
|
70
70
|
# the Ruby world for a very long time. I'm also grateful for his help in
|
71
71
|
# polishing Test::Unit and getting the RubyUnit compatibility layer
|
72
|
-
# right. His graciousness in allowing Test::Unit to
|
72
|
+
# right. His graciousness in allowing Test::Unit to supersede RubyUnit
|
73
73
|
# continues to be a challenge to me to be more willing to defer my own
|
74
74
|
# rights.
|
75
75
|
#
|
@@ -109,7 +109,7 @@ module Test # :nodoc:
|
|
109
109
|
#
|
110
110
|
# This software is provided "as is" and without any express or
|
111
111
|
# implied warranties, including, without limitation, the implied
|
112
|
-
# warranties of
|
112
|
+
# warranties of merchantability and fitness for a particular
|
113
113
|
# purpose.
|
114
114
|
#
|
115
115
|
#
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-unit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.6.
|
4
|
+
version: 3.6.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
8
8
|
- Haruka Yoshihara
|
9
|
-
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2025-04-05 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: power_assert
|
@@ -33,7 +32,8 @@ description: |-
|
|
33
32
|
email:
|
34
33
|
- kou@cozmixng.org
|
35
34
|
- yoshihara@clear-code.com
|
36
|
-
executables:
|
35
|
+
executables:
|
36
|
+
- test-unit
|
37
37
|
extensions: []
|
38
38
|
extra_rdoc_files: []
|
39
39
|
files:
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- PSFL
|
43
43
|
- README.md
|
44
44
|
- Rakefile
|
45
|
+
- bin/test-unit
|
45
46
|
- doc/text/getting-started.md
|
46
47
|
- doc/text/how-to.md
|
47
48
|
- doc/text/news.md
|
@@ -78,9 +79,11 @@ files:
|
|
78
79
|
- lib/test/unit/runner/emacs.rb
|
79
80
|
- lib/test/unit/runner/xml.rb
|
80
81
|
- lib/test/unit/sub-test-result.rb
|
82
|
+
- lib/test/unit/test-run-context.rb
|
81
83
|
- lib/test/unit/test-suite-creator.rb
|
82
84
|
- lib/test/unit/test-suite-runner.rb
|
83
85
|
- lib/test/unit/test-suite-thread-runner.rb
|
86
|
+
- lib/test/unit/test-thread-run-context.rb
|
84
87
|
- lib/test/unit/testcase.rb
|
85
88
|
- lib/test/unit/testresult.rb
|
86
89
|
- lib/test/unit/testsuite.rb
|
@@ -113,7 +116,6 @@ metadata:
|
|
113
116
|
source_code_uri: https://github.com/test-unit/test-unit
|
114
117
|
documentation_uri: https://test-unit.github.io/test-unit/en/
|
115
118
|
bug_tracker_uri: https://github.com/test-unit/test-unit/issues
|
116
|
-
post_install_message:
|
117
119
|
rdoc_options: []
|
118
120
|
require_paths:
|
119
121
|
- lib
|
@@ -128,8 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
130
|
- !ruby/object:Gem::Version
|
129
131
|
version: '0'
|
130
132
|
requirements: []
|
131
|
-
rubygems_version: 3.
|
132
|
-
signing_key:
|
133
|
+
rubygems_version: 3.6.2
|
133
134
|
specification_version: 4
|
134
135
|
summary: An xUnit family unit testing framework for Ruby.
|
135
136
|
test_files: []
|