[前][次][番号順一覧][スレッド一覧]

ruby-changes:64360

From: Marc-Andre <ko1@a...>
Date: Sun, 20 Dec 2020 07:13:28 +0900 (JST)
Subject: [ruby-changes:64360] 70f20234b2 (master): Add `assert_ractor` [Feature #17367]

https://git.ruby-lang.org/ruby.git/commit/?id=70f20234b2

From 70f20234b297a7fc9940bace30101813aa9df052 Mon Sep 17 00:00:00 2001
From: Marc-Andre Lafortune <github@m...>
Date: Sat, 19 Dec 2020 12:54:07 -0500
Subject: Add `assert_ractor` [Feature #17367]


diff --git a/tool/lib/test/unit/core_assertions.rb b/tool/lib/test/unit/core_assertions.rb
index a5defee..d17e3d7 100644
--- a/tool/lib/test/unit/core_assertions.rb
+++ b/tool/lib/test/unit/core_assertions.rb
@@ -330,6 +330,23 @@ eom https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit/core_assertions.rb#L330
         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 v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]