Skip to content

Commit 39cc537

Browse files
Add instructions for running tests for WebAssembly
1 parent 6077347 commit 39cc537

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Sources/Testing/Testing.docc/TemporaryGettingStarted.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,26 @@ using Xcode 16 Beta.
144144
See the [Test Explorer](https://www.swift.org/documentation/articles/getting-started-with-vscode-swift.html#test-explorer)
145145
section of
146146
[Getting Started with Swift in VS Code](https://www.swift.org/documentation/articles/getting-started-with-vscode-swift.html).
147+
148+
#### Running tests for WebAssembly
149+
150+
To run tests for WebAssembly, install a Swift SDK for WebAssembly by following
151+
[the instructions](https://book.swiftwasm.org/getting-started/setup-snapshot.html).
152+
153+
Because `swift test` doesn't know what WebAssembly environment you'd like to use
154+
to run your tests, building tests and running them are two separate steps. To
155+
build tests for WebAssembly, use the following command:
156+
157+
```sh
158+
swift build --swift-sdk wasm32-unknown-wasi --build-tests
159+
```
160+
161+
After building tests, you can run them using a [WASI](https://wasi.dev/)-compliant
162+
WebAssembly runtime, such as [Wasmtime](https://wasmtime.dev/) or
163+
[WasmKit](https://github.com/swiftwasm/WasmKit). For example, to run tests using
164+
Wasmtime, use the following command (replace `{YOURPACKAGE}` with your package's
165+
name):
166+
167+
```sh
168+
wasmtime .build/debug/{YOURPACKAGE}PackageTests.wasm
169+
```

0 commit comments

Comments
 (0)