test-unit-ruby-core 1.0.12 → 1.0.13

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/core_assertions.rb +30 -11
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b51defeffab8a8111b63992bba7cbfc691dd8c81e76bf6138420f474843ff90
4
- data.tar.gz: 0f496d18c7a8c60d193b6cb9cb0f417370175deed875438de07f8768d44ead5d
3
+ metadata.gz: 29365462eba565b84ef3473c3ac7a3bf2411c0b537a292eaf28a33329e69d746
4
+ data.tar.gz: ffa994c78613ee85efc4b35e8c3b418b5fe8e9258204d57f787068fade7ec7b8
5
5
  SHA512:
6
- metadata.gz: bf2c70e298e5ea94ee95bb0982e9e2f4ecae515995e98be08c72568e55576e0c0e1654593c414544030b632d087de80b47c7892e964c9e0f636d24447369a7b5
7
- data.tar.gz: 13897b2f3a02a3628945c07f51894358ecacd6e33ed892a38cb2fbbed7ed9aadd7d1b2dbfafa8a36bbf2ff85aa72b1e6f29601b09d798c0246c9fce0bee92e61
6
+ metadata.gz: cc85ccee8dfefe70ea01e6167d8e73b4d4ef0dced1239e5d066812052f9f468a451fedc3cf26ae1289d147d96cd4e2c57c536c8b0661bbf915863882758a953e
7
+ data.tar.gz: 83f4fb10dd0c64bae14aafc5f700f36fce22d39ea6cc152a8dec15fa8b673a6704863dd607cc103175f0ec8bf41ef6e16b28ba6351886c2a7cd5131345109ae3
@@ -75,9 +75,18 @@ module Test
75
75
  require_relative 'envutil'
76
76
  require 'pp'
77
77
  begin
78
- require '-test-/asan'
78
+ require '-test-/sanitizers'
79
79
  rescue LoadError
80
+ # in test-unit-ruby-core gem
81
+ def sanitizers
82
+ nil
83
+ end
84
+ else
85
+ def sanitizers
86
+ Test::Sanitizers
87
+ end
80
88
  end
89
+ module_function :sanitizers
81
90
 
82
91
  nil.pretty_inspect
83
92
 
@@ -97,9 +106,11 @@ module Test
97
106
  end
98
107
 
99
108
  def assert_in_out_err(args, test_stdin = "", test_stdout = [], test_stderr = [], message = nil,
100
- success: nil, failed: nil, **opt)
109
+ success: nil, failed: nil, gems: false, **opt)
101
110
  args = Array(args).dup
102
- args.insert((Hash === args[0] ? 1 : 0), '--disable=gems')
111
+ unless gems.nil?
112
+ args.insert((Hash === args[0] ? 1 : 0), "--#{gems ? 'enable' : 'disable'}=gems")
113
+ end
103
114
  stdout, stderr, status = EnvUtil.invoke_ruby(args, test_stdin, true, true, **opt)
104
115
  desc = failed[status, message, stderr] if failed
105
116
  desc ||= FailDesc[status, message, stderr]
@@ -160,7 +171,7 @@ module Test
160
171
  pend 'assert_no_memory_leak may consider MJIT memory usage as leak' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled?
161
172
  # ASAN has the same problem - its shadow memory greatly increases memory usage
162
173
  # (plus asan has better ways to detect memory leaks than this assertion)
163
- pend 'assert_no_memory_leak may consider ASAN memory usage as leak' if defined?(Test::ASAN) && Test::ASAN.enabled?
174
+ pend 'assert_no_memory_leak may consider ASAN memory usage as leak' if sanitizers&.asan_enabled?
164
175
 
165
176
  require_relative 'memory_status'
166
177
  raise Test::Unit::PendedError, "unsupported platform" unless defined?(Memory::Status)
@@ -331,6 +342,13 @@ eom
331
342
  # power_assert 3 requires ruby 3.1 or later
332
343
  args << "-W:no-experimental" if RUBY_VERSION < "3.1."
333
344
  stdout, stderr, status = EnvUtil.invoke_ruby(args, src, capture_stdout, true, **opt)
345
+
346
+ if sanitizers&.lsan_enabled?
347
+ # LSAN may output messages like the following line into stderr. We should ignore it.
348
+ # ==276855==Running thread 276851 was not suspended. False leaks are possible.
349
+ # See https://github.com/google/sanitizers/issues/1479
350
+ stderr.gsub!(/==\d+==Running thread \d+ was not suspended\. False leaks are possible\.\n/, "")
351
+ end
334
352
  ensure
335
353
  if res_c
336
354
  res_c.close
@@ -378,7 +396,11 @@ eom
378
396
  shim_value = "class Ractor; alias value take; end" unless Ractor.method_defined?(:value)
379
397
  shim_join = "class Ractor; alias join take; end" unless Ractor.method_defined?(:join)
380
398
 
381
- require = "require #{require.inspect}" if require
399
+ if require
400
+ require = [require] unless require.is_a?(Array)
401
+ require = require.map {|r| "require #{r.inspect}"}.join("\n")
402
+ end
403
+
382
404
  if require_relative
383
405
  dir = File.dirname(caller_locations[0,1][0].absolute_path)
384
406
  full_path = File.expand_path(require_relative, dir)
@@ -503,13 +525,10 @@ eom
503
525
  assert = :assert_match
504
526
  end
505
527
 
506
- ex = m = nil
507
- EnvUtil.with_default_internal(of: expected) do
508
- ex = assert_raise(exception, msg || proc {"Exception(#{exception}) with message matches to #{expected.inspect}"}) do
509
- yield
510
- end
511
- m = ex.message
528
+ ex = assert_raise(exception, msg || proc {"Exception(#{exception}) with message matches to #{expected.inspect}"}) do
529
+ yield
512
530
  end
531
+ m = ex.message
513
532
  msg = message(msg, "") {"Expected Exception(#{exception}) was raised, but the message doesn't match"}
514
533
 
515
534
  if assert == :assert_equal
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-unit-ruby-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.12
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi SHIBATA
8
8
  - Nobu Nakada
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-11-10 00:00:00.000000000 Z
11
+ date: 2025-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-unit