Skip to content

Commit e8b8824

Browse files
test: Add a smoke test
1 parent 86e2bff commit e8b8824

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

test/test_build_smoke.rb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
require "test-unit"
2+
require "tmpdir"
3+
require "bundler"
4+
5+
class TestBuildSmoke < Test::Unit::TestCase
6+
def run_rbwasm(*args)
7+
rbwasm_path = File.expand_path("../../exe/rbwasm", __FILE__)
8+
system("bundle", "exec", rbwasm_path, *args, exception: true)
9+
end
10+
11+
def run_wasmtime(*args)
12+
IO.popen(["wasmtime", *args], &:read)
13+
end
14+
15+
def test_build_rack
16+
Dir.mktmpdir do |dir|
17+
gemfile_path = File.join(dir, "Gemfile")
18+
output_path = File.join(dir, "output.wasm")
19+
20+
File.write(gemfile_path, <<-GEMFILE)
21+
source "https://rubygems.org"
22+
gem "rack", "3.0.8"
23+
GEMFILE
24+
Bundler.with_unbundled_env do
25+
ENV["RUBY_WASM_ROOT"] = File.expand_path("../../", __FILE__)
26+
ENV["BUNDLE_GEMFILE"] = gemfile_path
27+
assert system("bundle", "install")
28+
run_rbwasm("build", "-o", output_path)
29+
assert_equal "Rack::RELEASE=3.0.8\n",
30+
run_wasmtime(
31+
output_path,
32+
"-r/bundle/setup.rb",
33+
"-rrack",
34+
"-e",
35+
"puts \"Rack::RELEASE=\#{Rack::RELEASE}\""
36+
)
37+
end
38+
end
39+
end
40+
end

0 commit comments

Comments
 (0)