From 70f20234b297a7fc9940bace30101813aa9df052 Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Sat, 19 Dec 2020 12:54:07 -0500 Subject: Add `assert_ractor` [Feature #17367] --- tool/lib/test/unit/core_assertions.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tool') diff --git a/tool/lib/test/unit/core_assertions.rb b/tool/lib/test/unit/core_assertions.rb index a5defeec75..d17e3d725a 100644 --- a/tool/lib/test/unit/core_assertions.rb +++ b/tool/lib/test/unit/core_assertions.rb @@ -330,6 +330,23 @@ eom raise marshal_error if marshal_error end + # Run Ractor-related test without influencing the main test suite + def assert_ractor(src, args: [], file: nil, line: nil, ignore_stderr: nil, **opt) + return unless defined?(Ractor) + + if (req = opt.delete(:require)) + req = "require #{req.inspect}" + end + assert_separately(args, file, line, <<~RUBY, ignore_stderr: ignore_stderr, **opt) + #{req} + previous_verbose = $VERBOSE + $VERBOSE = nil + Ractor.new {} # trigger initial warning + $VERBOSE = previous_verbose + #{src} + RUBY + end + # :call-seq: # assert_throw( tag, failure_message = nil, &block ) # -- cgit v1.2.3