test-unit 3.4.5 → 3.4.7

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