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

ruby-changes:64400

From: Marc-Andre <ko1@a...>
Date: Mon, 21 Dec 2020 12:00:50 +0900 (JST)
Subject: [ruby-changes:64400] 1ecac8e4d0 (master): Add `require_relative` option to `assert_ractor`

https://git.ruby-lang.org/ruby.git/commit/?id=1ecac8e4d0

From 1ecac8e4d031c244df711d573fa73ce339ffa2f5 Mon Sep 17 00:00:00 2001
From: Marc-Andre Lafortune <github@m...>
Date: Sun, 20 Dec 2020 21:51:11 -0500
Subject: Add `require_relative` option to `assert_ractor`


diff --git a/tool/lib/test/unit/core_assertions.rb b/tool/lib/test/unit/core_assertions.rb
index 97b9b39..16d5e14 100644
--- a/tool/lib/test/unit/core_assertions.rb
+++ b/tool/lib/test/unit/core_assertions.rb
@@ -331,10 +331,15 @@ eom https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit/core_assertions.rb#L331
       end
 
       # Run Ractor-related test without influencing the main test suite
-      def assert_ractor(src, args: [], require: nil, file: nil, line: nil, ignore_stderr: nil, **opt)
+      def assert_ractor(src, args: [], require: nil, require_relative: nil, file: nil, line: nil, ignore_stderr: nil, **opt)
         return unless defined?(Ractor)
 
         require = "require #{require.inspect}" if require
+        if require_relative
+          dir = File.dirname(caller_locations[0,1][0].absolute_path)
+          full_path = File.expand_path(require_relative, dir)
+          require = "#{require}; require #{full_path.inspect}"
+        end
 
         assert_separately(args, file, line, <<~RUBY, ignore_stderr: ignore_stderr, **opt)
           #{require}
-- 
cgit v0.10.2


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

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