Skip to content

Commit

Permalink
Add reproduction of #1217
Browse files Browse the repository at this point in the history
Signed-off-by: Jiahao XU <[email protected]>
  • Loading branch information
NobodyXu committed Sep 30, 2024
1 parent e6a87a6 commit 9def0e7
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,46 @@ jobs:
- run: cargo test --no-run --target ${{ matrix.target }} --release
- run: cargo test --no-run --target ${{ matrix.target }} --features parallel

test-wasm32-wasip1-thread:
name: Test wasm32-wasip1-thread
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust (rustup)
run: |
rustup toolchain install nightly --no-self-update --profile minimal --target wasm32-wasip1-threads
- name: Get latest version of wasi-sdk
env:
REPO: WebAssembly/wasi-sdk
GH_TOKEN: ${{ github.token }}
run: |
VERSION="$(gh release list --repo $REPO -L 1 --json tagName --jq '.[]|.tagName')"
echo $VERSION
echo "WASI_TOOLCHAIN_VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Install wasi-sdk
working-directory: /tmp
env:
REPO: WebAssembly/wasi-sdk
run: |
VERSION="$WASI_TOOLCHAIN_VERSION"
VERSION_FULL="${VERSION}.0"
FILE="wasi-sdk-${VERSION_FULL}-x86_64-linux.deb"
wget "https://github.com/$REPO/releases/download/wasi-sdk-${VERSION}/${FILE}"
sudo dpkg -i "${FILE}"
WASI_SDK_PATH="/opt/wasi-sdk"
CC="${WASI_SDK_PATH}/bin/clang"
echo "WASI_SDK_PATH=$WASI_SDK_PATH" >> "$GITHUB_ENV"
echo "CC=$CC" >> "$GITHUB_ENV"
- uses: Swatinem/rust-cache@v2
with:
env-vars: "WASI_TOOLCHAIN_VERSION"

- name: Run tests
run: cargo +nightly build -p cc-test --target wasm32-wasip1-threads

cuda:
name: Test CUDA support
runs-on: ubuntu-20.04
Expand Down
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ members = [
"dev-tools/cc-test",
"dev-tools/gen-target-info",
"dev-tools/gen-windows-sys-binding",
"dev-tools/wasm32-wasip1-threads-test",
]

[patch.crates-io]
cc = { path = "." }
8 changes: 8 additions & 0 deletions dev-tools/wasm32-wasip1-threads-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "wasm32-wasip1-threads-test"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
rusqlite = { version = "0.32.0", features = ["bundled"] }
14 changes: 14 additions & 0 deletions dev-tools/wasm32-wasip1-threads-test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub fn add(left: u64, right: u64) -> u64 {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}

0 comments on commit 9def0e7

Please sign in to comment.