Skip to content

Commit cbd2074

Browse files
Support the latest nightly snapshot
1 parent 69cd8c9 commit cbd2074

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

.github/workflows/test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
- { os: ubuntu-20.04, toolchain: wasm-5.7.3-RELEASE, wasi-backend: MicroWASI }
2222
- { os: ubuntu-20.04, toolchain: wasm-5.8.0-RELEASE, wasi-backend: MicroWASI }
2323
- { os: ubuntu-20.04, toolchain: wasm-5.9.1-RELEASE, wasi-backend: MicroWASI }
24+
- { os: ubuntu-22.04, toolchain: wasm-DEVELOPMENT-SNAPSHOT-2024-05-02-a, wasi-backend: Node }
2425

2526
runs-on: ${{ matrix.entry.os }}
2627
env:

IntegrationTests/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ TestSuites/.build/$(CONFIGURATION)/%.wasm: FORCE
1111
--triple wasm32-unknown-wasi \
1212
--configuration $(CONFIGURATION) \
1313
-Xswiftc -Xclang-linker -Xswiftc -mexec-model=reactor \
14-
-Xlinker --export=main \
14+
-Xlinker --export-if-defined=main -Xlinker --export-if-defined=__main_argc_argv \
15+
--static-swift-stdlib -Xswiftc -static-stdlib \
1516
$(SWIFT_BUILD_FLAGS)
1617

1718
dist/%.wasm: TestSuites/.build/$(CONFIGURATION)/%.wasm

IntegrationTests/lib.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,28 @@ const WASI = {
1616

1717
return {
1818
wasiImport: wasi.wasiImport,
19-
start(instance) {
19+
start(instance, swift) {
2020
wasi.initialize(instance);
21-
instance.exports.main();
21+
swift.main();
2222
}
2323
}
2424
},
2525
Node: ({ programName }) => {
2626
const wasi = new NodeWASI({
2727
args: [programName],
2828
env: {},
29+
preopens: {
30+
"/": "./",
31+
},
2932
returnOnExit: false,
3033
version: "preview1",
3134
})
3235

3336
return {
3437
wasiImport: wasi.wasiImport,
35-
start(instance) {
38+
start(instance, swift) {
3639
wasi.initialize(instance);
37-
instance.exports.main();
40+
swift.main();
3841
}
3942
}
4043
},
@@ -69,7 +72,7 @@ const startWasiTask = async (wasmPath, wasiConstructor = selectWASIBackend()) =>
6972

7073
swift.setInstance(instance);
7174
// Start the WebAssembly WASI instance!
72-
wasi.start(instance);
75+
wasi.start(instance, swift);
7376
};
7477

7578
module.exports = { startWasiTask, WASI };

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test:
2121
.PHONY: unittest
2222
unittest:
2323
@echo Running unit tests
24-
swift build --build-tests --triple wasm32-unknown-wasi -Xswiftc -Xclang-linker -Xswiftc -mexec-model=reactor -Xlinker --export=main
24+
swift build --build-tests --triple wasm32-unknown-wasi -Xswiftc -Xclang-linker -Xswiftc -mexec-model=reactor -Xlinker --export-if-defined=main -Xlinker --export-if-defined=__main_argc_argv --static-swift-stdlib -Xswiftc -static-stdlib
2525
node --experimental-wasi-unstable-preview1 scripts/test-harness.js ./.build/wasm32-unknown-wasi/debug/JavaScriptKitPackageTests.wasm
2626

2727
.PHONY: benchmark_setup

scripts/test-harness.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Error.stackTraceLimit = Infinity;
22

3-
const { startWasiTask, WASI } = require("../IntegrationTests/lib");
3+
const { startWasiTask } = require("../IntegrationTests/lib");
4+
5+
if (process.env["JAVASCRIPTKIT_WASI_BACKEND"] === "MicroWASI") {
6+
console.log("Skipping XCTest tests for MicroWASI because it is not supported yet.");
7+
process.exit(0);
8+
}
49

510
const handleExitOrError = (error) => {
611
console.log(error);

0 commit comments

Comments
 (0)