Skip to content

Commit 3330721

Browse files
committed
try to fix bundled gems
1 parent b989df4 commit 3330721

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

test/.excludes-ractor/TestHash.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
exclude(:test_to_s, "global variables")
55
exclude(:test_inspect, "global side effects")
66
exclude(:test_broken_hash_value, "too many objects")
7+
exclude(:test_replace_bug15358, "GC.start")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = File.expand_path("../TestString.rb", __FILE__)
2+
instance_eval File.read(path), path

tool/lib/core_assertions.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def assert_file
100100

101101
def assert_in_out_err(args, test_stdin = "", test_stdout = [], test_stderr = [], message = nil,
102102
success: nil, failed: nil, **opt)
103-
pend "#{__method__}" unless Test::Unit::TestCase.main_ractor?
103+
pend "#{__method__}" if respond_to?(:main_ractor?) && !main_ractor?
104104
args = Array(args).dup
105105
args.insert((Hash === args[0] ? 1 : 0), '--disable=gems')
106106
stdout, stderr, status = EnvUtil.invoke_ruby(args, test_stdin, true, true, **opt)
@@ -157,7 +157,7 @@ def syntax_check(code, fname, line)
157157
end
158158

159159
def assert_no_memory_leak(args, prepare, code, message=nil, limit: 2.0, rss: false, **opt)
160-
omit "separate process" unless Test::Unit::TestCase.main_ractor?
160+
omit "separate process" if respond_to?(:main_ractor?) && !main_ractor?
161161
# TODO: consider choosing some appropriate limit for RJIT and stop skipping this once it does not randomly fail
162162
pend 'assert_no_memory_leak may consider RJIT memory usage as leak' if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
163163
# For previous versions which implemented MJIT
@@ -274,7 +274,7 @@ def assert_valid_syntax(code, *args, **opt)
274274
end
275275

276276
def assert_normal_exit(testsrc, message = '', child_env: nil, **opt)
277-
pend "#{__method__}" unless Test::Unit::TestCase.main_ractor?
277+
pend "#{__method__}" if respond_to?(:main_ractor?) && !main_ractor?
278278
assert_valid_syntax(testsrc, caller_locations(1, 1)[0])
279279
if child_env
280280
child_env = [child_env]
@@ -286,7 +286,7 @@ def assert_normal_exit(testsrc, message = '', child_env: nil, **opt)
286286
end
287287

288288
def assert_ruby_status(args, test_stdin="", message=nil, **opt)
289-
pend "#{__method__}" unless Test::Unit::TestCase.main_ractor?
289+
pend "#{__method__}" if respond_to?(:main_ractor?) && !main_ractor?
290290
out, _, status = EnvUtil.invoke_ruby(args, test_stdin, true, :merge_to_stdout, **opt)
291291
desc = FailDesc[status, message, out]
292292
assert(!status.signaled?, desc)
@@ -310,7 +310,7 @@ def separated_runner(token, out = nil)
310310
end
311311

312312
def assert_separately(args, file = nil, line = nil, src, ignore_stderr: nil, **opt)
313-
pend "#{__method__}" unless Test::Unit::TestCase.main_ractor?
313+
pend "#{__method__}" if respond_to?(:main_ractor?) && !main_ractor?
314314
unless file and line
315315
loc, = caller_locations(1,1)
316316
file ||= loc.path
@@ -508,7 +508,7 @@ def assert_raise_with_message(exception, expected, msg = nil, &block)
508508
assert = :assert_match
509509
end
510510
ex = m = nil
511-
if Test::Unit::TestCase.multiple_ractors?
511+
if respond_to?(:multiple_ractors?) && multiple_ractors?
512512
ex = assert_raise(exception, msg || proc {"Exception(#{exception}) with message matches to #{expected.inspect}"}) do
513513
yield
514514
end
@@ -690,7 +690,7 @@ def assert_pattern_list(pattern_list, actual, message=nil)
690690

691691
def assert_warning(pat, msg = nil)
692692
result = nil
693-
if Test::Unit::TestCase.multiple_ractors?
693+
if respond_to?(:multiple_ractors?) && multiple_ractors?
694694
stderr = EnvUtil.verbose_warning {
695695
result = yield
696696
}
@@ -873,7 +873,7 @@ def assert_all_assertions_foreach(msg = nil, *keys, &block)
873873
# :yield: each elements of +seq+.
874874
def assert_linear_performance(seq, rehearsal: nil, pre: ->(n) {n})
875875
pend "No PERFORMANCE_CLOCK found" unless defined?(PERFORMANCE_CLOCK)
876-
pend "Timeout" unless Test::Unit::TestCase.main_ractor?
876+
pend "Timeout" if respond_to?(:main_ractor?) && !main_ractor?
877877

878878
# Timeout testing generally doesn't work when RJIT compilation happens.
879879
rjit_enabled = defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
@@ -996,7 +996,7 @@ def self.glibc?(*ver)
996996
end
997997

998998
def self.macos?(*ver)
999-
is_main_ractor = Test::Unit::TestCase.main_ractor?
999+
is_main_ractor = (!respond_to?(:main_ractor?)) || main_ractor?
10001000
# Don't cache @macos as class ivar if we're running in a ractor. That means we shell out
10011001
# each time if we're not in main ractor, but this guard isn't used often so it's fine for now.
10021002
if !is_main_ractor || !defined?(@macos)

0 commit comments

Comments
 (0)