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