Skip to content

Commit

Permalink
Support the latest nightly snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun committed May 8, 2024
1 parent dceda05 commit bdcbbb6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- { os: ubuntu-20.04, toolchain: wasm-5.7.3-RELEASE, wasi-backend: MicroWASI }
- { os: ubuntu-20.04, toolchain: wasm-5.8.0-RELEASE, wasi-backend: MicroWASI }
- { os: ubuntu-20.04, toolchain: wasm-5.9.1-RELEASE, wasi-backend: MicroWASI }
- { os: ubuntu-22.04, toolchain: wasm-DEVELOPMENT-SNAPSHOT-2024-05-02-a, wasi-backend: Node }

runs-on: ${{ matrix.entry.os }}
env:
Expand Down
13 changes: 8 additions & 5 deletions IntegrationTests/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,28 @@ const WASI = {

return {
wasiImport: wasi.wasiImport,
start(instance) {
start(instance, swift) {
wasi.initialize(instance);
instance.exports.main();
swift.main();
}
}
},
Node: ({ programName }) => {
const wasi = new NodeWASI({
args: [programName],
env: {},
preopens: {
"/": "./",
},
returnOnExit: false,
version: "preview1",
})

return {
wasiImport: wasi.wasiImport,
start(instance) {
start(instance, swift) {
wasi.initialize(instance);
instance.exports.main();
swift.main();
}
}
},
Expand Down Expand Up @@ -69,7 +72,7 @@ const startWasiTask = async (wasmPath, wasiConstructor = selectWASIBackend()) =>

swift.setInstance(instance);
// Start the WebAssembly WASI instance!
wasi.start(instance);
wasi.start(instance, swift);
};

module.exports = { startWasiTask, WASI };
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test:
.PHONY: unittest
unittest:
@echo Running unit tests
swift build --build-tests --triple wasm32-unknown-wasi -Xswiftc -Xclang-linker -Xswiftc -mexec-model=reactor -Xlinker --export=main
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
node --experimental-wasi-unstable-preview1 scripts/test-harness.js ./.build/wasm32-unknown-wasi/debug/JavaScriptKitPackageTests.wasm

.PHONY: benchmark_setup
Expand Down
7 changes: 6 additions & 1 deletion scripts/test-harness.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Error.stackTraceLimit = Infinity;

const { startWasiTask, WASI } = require("../IntegrationTests/lib");
const { startWasiTask } = require("../IntegrationTests/lib");

if (process.env["JAVASCRIPTKIT_WASI_BACKEND"] === "MicroWASI") {
console.log("Skipping XCTest tests for MicroWASI because it is not supported yet.");
process.exit(0);
}

const handleExitOrError = (error) => {
console.log(error);
Expand Down

0 comments on commit bdcbbb6

Please sign in to comment.