-
Notifications
You must be signed in to change notification settings - Fork 145
Revise WASI documentation for swift test commands
#1595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
36f9cbf
23749d5
a7e800a
fb8611a
e3a13c1
445f7c7
f2d7005
b822825
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,31 +14,43 @@ See https://swift.org/CONTRIBUTORS.txt for Swift project authors | |
| because it provides instructions the reader must follow directly. --> | ||
|
|
||
| To run tests for WebAssembly, install a Swift SDK for WebAssembly by following | ||
| [these instructions](https://book.swiftwasm.org/getting-started/setup.html). | ||
| [these instructions](https://www.swift.org/documentation/articles/wasm-getting-started.html). | ||
|
|
||
| Because `swift test` doesn't know what WebAssembly environment you'd like to use | ||
| ## Swift Development Snapshots | ||
|
|
||
| In Swift development snapshots, running `swift test --swift-sdk <wasm_swift_sdk_id>` is fully | ||
| supported. When you have `jq` installed, you can run this command to compute the Swift SDK ID automatically: | ||
MaxDesiatov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ``` | ||
MaxDesiatov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| swift test --swift-sdk "$(swiftc -print-target-info | jq -r '.swiftCompilerTag')_wasm" | ||
| ``` | ||
|
|
||
| ## Swift 6.2 | ||
|
||
|
|
||
| In Swift 6.2 `swift test` doesn't know what WebAssembly environment you'd like to use | ||
| to run your tests, building tests and running them are two separate steps. To | ||
| build tests for WebAssembly, use the following command: | ||
MaxDesiatov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```sh | ||
| swift build --swift-sdk wasm32-unknown-wasi --build-tests | ||
| swift build --swift-sdk "$(swiftc -print-target-info | jq -r '.swiftCompilerTag')_wasm" --build-tests | ||
| ``` | ||
|
|
||
| After building tests, you can run them using a [WASI](https://wasi.dev/)-compliant | ||
| WebAssembly runtime such as [Wasmtime](https://wasmtime.dev/) or | ||
| [WasmKit](https://github.com/swiftwasm/WasmKit). For example, to run tests using | ||
| Wasmtime, use the following command (replace `{YOURPACKAGE}` with your package's | ||
| WebAssembly runtime such as [WasmKit](https://github.com/swiftwasm/WasmKit). | ||
| Starting with Swift 6.2, WasmKit is included in Swift toolchains for Linux and macOS | ||
| distributed on swift.org. For example, to run tests using | ||
| WasmKit, use the following command (replace `{YOURPACKAGE}` with your package's | ||
| name): | ||
MaxDesiatov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```sh | ||
| wasmtime .build/debug/{YOURPACKAGE}PackageTests.wasm --testing-library swift-testing | ||
| wasmkit run .build/debug/{YOURPACKAGE}PackageTests.wasm --testing-library swift-testing | ||
| ``` | ||
|
|
||
| Most WebAssembly runtimes forward trailing arguments to the WebAssembly program, | ||
| so you can pass command-line options of the testing library. For example, to list | ||
| all tests and filter them by name, use the following commands: | ||
|
|
||
| ```sh | ||
| wasmtime .build/debug/{YOURPACKAGE}PackageTests.wasm list --testing-library swift-testing | ||
| wasmtime .build/debug/{YOURPACKAGE}PackageTests.wasm --testing-library swift-testing --filter "FoodTruckTests.foodTruckExists" | ||
| wasmkit run .build/debug/{YOURPACKAGE}PackageTests.wasm list --testing-library swift-testing | ||
| wasmkit run .build/debug/{YOURPACKAGE}PackageTests.wasm --testing-library swift-testing --filter "FoodTruckTests.foodTruckExists" | ||
| ``` | ||
Uh oh!
There was an error while loading. Please reload this page.