Skip to content

Commit 581ee4e

Browse files
build: Run executable tests with WasmKit when available
This patch allows running executable tests with WasmKit. If WasmKit is not built, fall back to running only non-executable tests. Also add stdlib and Concurrency executable tests to run.
1 parent 2b11604 commit 581ee4e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

utils/swift_build_support/swift_build_support/products/wasmstdlib.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from . import llvm
1717
from . import swift
1818
from . import wasisysroot
19+
from . import wasmkit
1920

2021

2122
class WasmStdlib(cmake_product.CMakeProduct):
@@ -100,7 +101,7 @@ def build(self, host_target):
100101
# Test configuration
101102
self.cmake_options.define('SWIFT_INCLUDE_TESTS:BOOL', 'TRUE')
102103
self.cmake_options.define('SWIFT_ENABLE_SOURCEKIT_TESTS:BOOL', 'FALSE')
103-
lit_test_paths = ['IRGen']
104+
lit_test_paths = ['IRGen', 'stdlib', 'Concurrency/Runtime']
104105
lit_test_paths = [os.path.join(
105106
self.build_dir, 'test-wasi-wasm32', path) for path in lit_test_paths]
106107
self.cmake_options.define('SWIFT_LIT_TEST_PATHS:STRING',
@@ -119,13 +120,22 @@ def build(self, host_target):
119120
prefer_just_built_toolchain=True)
120121

121122
def test(self, host_target):
123+
build_root = os.path.dirname(self.build_dir)
122124
bin_paths = [
123125
os.path.join(self._host_swift_build_dir(host_target), 'bin'),
124126
os.path.join(self._host_llvm_build_dir(host_target), 'bin'),
125127
os.environ['PATH']
126128
]
129+
wasmkit_build_path = os.path.join(
130+
build_root, '%s-%s' % ('wasmkit', host_target))
131+
wasmkit_bin_path = wasmkit.WasmKit.cli_file_path(wasmkit_build_path)
132+
if not os.path.exists(wasmkit_bin_path):
133+
test_target = "check-swift-only_non_executable-wasi-wasm32-custom"
134+
else:
135+
test_target = "check-swift-wasi-wasm32-custom"
136+
bin_paths = [os.path.dirname(wasmkit_bin_path)] + bin_paths
137+
127138
env = {'PATH': os.path.pathsep.join(bin_paths)}
128-
test_target = "check-swift-only_non_executable-wasi-wasm32-custom"
129139
self.test_with_cmake(None, [test_target], self._build_variant, [], test_env=env)
130140

131141
@property
@@ -153,4 +163,5 @@ def get_dependencies(cls):
153163
return [llvm.LLVM,
154164
wasisysroot.WASILibc,
155165
wasisysroot.WasmLLVMRuntimeLibs,
166+
wasmkit.WasmKit,
156167
swift.Swift]

utils/wasm-run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def run(self, args):
2424
subprocess.check_call(command)
2525

2626
def invocation(self, args):
27-
command = ["wasmtime", "run"]
27+
command = ["wasmkit-cli", "run"]
2828
envs = collect_wasm_env()
2929
for key in envs:
3030
command.append("--env")

0 commit comments

Comments
 (0)