Skip to content

Commit 12ca50e

Browse files
committed
isolate fiddle test under RUBY_BOX mode
1 parent 02f81f4 commit 12ca50e

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ jobs:
3131
run: bundle exec rake steep:check
3232
- name: Run the default task
3333
run: bundle exec rake
34+
- name: Run test using Ruby::Box
35+
run: RUBY_BOX=1 bundle exec rake test

Rakefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ require "steep/cli"
77

88
task default: %i[test]
99

10+
def supported_ruby_box? = RUBY_VERSION >= "4.0.0" && ENV["RUBY_BOX"] == "1" && defined?(Ruby::Box)
11+
1012
Rake::TestTask.new do |t|
1113
t.test_files = FileList['test/**/*_test.rb']
14+
if supported_ruby_box?
15+
t.test_files = FileList['test/caotral/linker/fiddle_test.rb']
16+
end
1217
end
1318

1419
namespace :steep do

test/caotral/linker/fiddle_test.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
require_relative "../../test_suite"
2+
3+
class Caotral::Linker::FiddleMethodTest < Test::Unit::TestCase
4+
include TestProcessHelper
5+
def setup
6+
@generated = []
7+
omit("Ruby::Box is not supported in this environment") unless supported_ruby_box?
8+
end
9+
10+
def teardown
11+
@generated.each do |file|
12+
File.delete(file) if File.exist?(file)
13+
end
14+
end
15+
16+
def test_sample_call_add_method
17+
@generated = ["libtmp.so", "libtmp.so.o"]
18+
@file = "sample/C/add.c"
19+
IO.popen(["gcc", "-fPIC", "-c", "-o", "libtmp.so.o", "%s" % @file]).close
20+
linker = Caotral::Linker.link!(inputs: ["libtmp.so.o"], output: "libtmp.so", linker: "self", shared: true, executable: false)
21+
box = Ruby::Box.new
22+
box.require("./sample/fiddle_add.rb")
23+
assert_equal(10, box::X.add(3, 7))
24+
end
25+
26+
private def supported_ruby_box? = RUBY_VERSION >= "4.0.0" && ENV["RUBY_BOX"] == "1" && defined?(Ruby::Box)
27+
end

0 commit comments

Comments
 (0)