Skip to content

Commit 27efd1d

Browse files
committed
Remove warning from Ractor spec
Ractors are experimental, thus Ruby warns when using them. We don't need to be reminded every time we run the tests though, so let's silence the experimental warning when running those tests. Also remove the check for Ruby version since all versions we support now have Ractors.
1 parent ba87587 commit 27efd1d

2 files changed

Lines changed: 44 additions & 38 deletions

File tree

spec/integration/ractor_spec.rb

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,48 @@
1-
if RUBY_VERSION.start_with?("3.")
2-
RSpec.describe "Ractor" do
3-
let(:wat) { <<~WAT }
4-
(module
5-
(func $module/hello (result i32 i64 f32 f64)
6-
i32.const 1
7-
i64.const 2
8-
f32.const 3.0
9-
f64.const 4.0
10-
)
11-
12-
(export "hello" (func $module/hello))
1+
RSpec.describe "Ractor", ractor: true do
2+
let(:wat) { <<~WAT }
3+
(module
4+
(func $module/hello (result i32 i64 f32 f64)
5+
i32.const 1
6+
i64.const 2
7+
f32.const 3.0
8+
f64.const 4.0
139
)
14-
WAT
15-
16-
it "supports running inside Ractors" do
17-
r = Ractor.new(wat) do |wat|
18-
engine = Wasmtime::Engine.new
19-
mod = Wasmtime::Module.new(engine, wat)
20-
store_data = Object.new
21-
store = Wasmtime::Store.new(engine, store_data)
22-
Wasmtime::Instance.new(store, mod).invoke("hello")
23-
end
2410
25-
result = r.take
26-
expect(result).to eq([1, 2, 3.0, 4.0])
27-
end
11+
(export "hello" (func $module/hello))
12+
)
13+
WAT
2814

29-
it "supports sharing Engine & Module with Ractors" do
15+
it "supports running inside Ractors" do
16+
r = Ractor.new(wat) do |wat|
3017
engine = Wasmtime::Engine.new
3118
mod = Wasmtime::Module.new(engine, wat)
19+
store_data = Object.new
20+
store = Wasmtime::Store.new(engine, store_data)
21+
Wasmtime::Instance.new(store, mod).invoke("hello")
22+
end
3223

33-
Ractor.make_shareable(engine)
34-
Ractor.make_shareable(mod)
24+
result = r.take
25+
expect(result).to eq([1, 2, 3.0, 4.0])
26+
end
3527

36-
ractors = []
37-
3.times do
38-
ractors << Ractor.new(engine, mod) do |engine, mod|
39-
store_data = Object.new
40-
store = Wasmtime::Store.new(engine, store_data)
41-
Wasmtime::Instance.new(store, mod).invoke("hello")
42-
end
43-
end
28+
it "supports sharing Engine & Module with Ractors" do
29+
engine = Wasmtime::Engine.new
30+
mod = Wasmtime::Module.new(engine, wat)
4431

45-
ractors.each do |ractor|
46-
expect(ractor.take).to eq([1, 2, 3.0, 4.0])
32+
Ractor.make_shareable(engine)
33+
Ractor.make_shareable(mod)
34+
35+
ractors = []
36+
3.times do
37+
ractors << Ractor.new(engine, mod) do |engine, mod|
38+
store_data = Object.new
39+
store = Wasmtime::Store.new(engine, store_data)
40+
Wasmtime::Instance.new(store, mod).invoke("hello")
4741
end
4842
end
43+
44+
ractors.each do |ractor|
45+
expect(ractor.take).to eq([1, 2, 3.0, 4.0])
46+
end
4947
end
5048
end

spec/spec_helper.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ def with_gc_stress
9191
with_gc_stress { ex.run }
9292
end
9393
end
94+
95+
config.around(:each, :ractor) do |example|
96+
was = Warning[:experimental]
97+
Warning[:experimental] = false
98+
example.run
99+
ensure
100+
Warning[:experimental] = was
101+
end
94102
end
95103

96104
at_exit { GC.start(full_mark: true) } if ENV["GC_AT_EXIT"] == "1"

0 commit comments

Comments
 (0)