summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorMarc-Andre Lafortune <github@marc-andre.ca>2020-12-20 21:51:11 -0500
committerMarc-Andre Lafortune <github@marc-andre.ca>2020-12-20 22:00:05 -0500
commit1ecac8e4d031c244df711d573fa73ce339ffa2f5 (patch)
treea87d67c8699df849541b8d804b90d1139dec9b77 /tool
parenteee93bc9330cb069abb679a0a0d48a49b10f6a4e (diff)
Add `require_relative` option to `assert_ractor`
Diffstat (limited to 'tool')
-rw-r--r--tool/lib/test/unit/core_assertions.rb7
1 files changed, 6 insertions, 1 deletions
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}