diff options
author | Marc-Andre Lafortune <github@marc-andre.ca> | 2020-12-19 12:54:07 -0500 |
---|---|---|
committer | Marc-André Lafortune <github@marc-andre.ca> | 2020-12-19 17:13:08 -0500 |
commit | 70f20234b297a7fc9940bace30101813aa9df052 (patch) | |
tree | 6185928bdecbe71c492101865465a9c8516934d9 /tool/lib | |
parent | 7f8108eeff8ffa66c93efb07d4bead1baf7153a8 (diff) |
Add `assert_ractor` [Feature #17367]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3942
Diffstat (limited to 'tool/lib')
-rw-r--r-- | tool/lib/test/unit/core_assertions.rb | 17 |
1 files changed, 17 insertions, 0 deletions
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 ) # |