From 1ecac8e4d031c244df711d573fa73ce339ffa2f5 Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Sun, 20 Dec 2020 21:51:11 -0500 Subject: [PATCH] Add `require_relative` option to `assert_ractor` --- tool/lib/test/unit/core_assertions.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tool/lib/test/unit/core_assertions.rb b/tool/lib/test/unit/core_assertions.rb index 97b9b392f9..16d5e14fb1 100644 --- a/tool/lib/test/unit/core_assertions.rb +++ b/tool/lib/test/unit/core_assertions.rb @@ -331,10 +331,15 @@ eom 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}