diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6a3d50f..087d770b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -241,22 +241,37 @@ jobs: uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.RUST_STABLE_VER }} - targets: wasm32-unknown-unknown + targets: wasm32-unknown-unknown,wasm32-wasip1 - name: restore cache uses: Swatinem/rust-cache@v2 with: save-if: ${{ github.event_name != 'merge_group' }} - - name: install wasm-pack + - name: install cargo-nextest and wasmtime uses: taiki-e/install-action@v2 with: - tool: wasm-pack + tool: cargo-nextest,wasmtime-cli + + # We test using wasm32-wasip1, but want to make sure that wasm32-unknown-unknown still builds + - name: cargo build (wasm32-unknown-unknown) + run: | + cargo build --target wasm32-unknown-unknown \ + --config 'target.wasm32-unknown-unknown.rustflags = "-Ctarget-feature=+simd128"' + + - name: cargo nextest + run: | + cargo nextest run --workspace --locked --all-features --no-fail-fast --target wasm32-wasip1 \ + --config 'target.wasm32-wasip1.rustflags = "-Ctarget-feature=+simd128"' \ + --config 'target.wasm32-wasip1.runner = "wasmtime"' + + - name: cargo test --doc + run: | + cargo test --doc --workspace --locked --all-features --no-fail-fast --target wasm32-wasip1 \ + --config 'target.wasm32-wasip1.rustflags = "-Ctarget-feature=+simd128"' \ + --config 'target.wasm32-wasip1.rustdocflags = "-Ctarget-feature=+simd128"' \ + --config 'target.wasm32-wasip1.runner = "wasmtime"' - - name: Run fearless_simd_tests on Chrome - run: RUSTFLAGS=-Ctarget-feature=+simd128 wasm-pack test --headless --chrome - working-directory: fearless_simd_tests - check-msrv: name: cargo check (msrv) diff --git a/Cargo.lock b/Cargo.lock index 161950a6..f6b6e795 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -52,33 +52,12 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "bumpalo" -version = "3.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db76d6187cd04dff33004d8e6c9cc4e05cd330500379d2394209271b4aeee" - [[package]] name = "bytemuck" version = "1.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c76a5792e44e4abe34d3abf15636779261d45a7450612059293d1d2cfc63422" -[[package]] -name = "cc" -version = "1.2.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d487aa071b5f64da6f19a3e848e3578944b726ee5a4854b82172f02aa876bfdc" -dependencies = [ - "shlex", -] - -[[package]] -name = "cfg-if" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" - [[package]] name = "clap" version = "4.5.40" @@ -157,8 +136,6 @@ version = "0.0.0" dependencies = [ "fearless_simd", "fearless_simd_dev_macros", - "wasm-bindgen", - "wasm-bindgen-test", ] [[package]] @@ -173,44 +150,12 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" -[[package]] -name = "js-sys" -version = "0.3.77" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" -dependencies = [ - "once_cell", - "wasm-bindgen", -] - [[package]] name = "libm" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" -[[package]] -name = "log" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" - -[[package]] -name = "minicov" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f27fe9f1cc3c22e1687f9446c2083c4c5fc7f0bcf1c7a86bdbded14985895b4b" -dependencies = [ - "cc", - "walkdir", -] - -[[package]] -name = "once_cell" -version = "1.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" - [[package]] name = "once_cell_polyfill" version = "1.70.1" @@ -235,27 +180,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rustversion" -version = "1.0.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - [[package]] name = "strsim" version = "0.11.1" @@ -285,130 +209,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" -[[package]] -name = "walkdir" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" -dependencies = [ - "same-file", - "winapi-util", -] - -[[package]] -name = "wasm-bindgen" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" -dependencies = [ - "cfg-if", - "once_cell", - "rustversion", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" -dependencies = [ - "bumpalo", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" -dependencies = [ - "cfg-if", - "js-sys", - "once_cell", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "wasm-bindgen-test" -version = "0.3.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66c8d5e33ca3b6d9fa3b4676d774c5778031d27a578c2b007f905acf816152c3" -dependencies = [ - "js-sys", - "minicov", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-bindgen-test-macro", -] - -[[package]] -name = "wasm-bindgen-test-macro" -version = "0.3.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17d5042cc5fa009658f9a7333ef24291b1291a25b6382dd68862a7f3b969f69b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "web-sys" -version = "0.3.77" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "winapi-util" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" -dependencies = [ - "windows-sys", -] - [[package]] name = "windows-sys" version = "0.59.0" diff --git a/fearless_simd/src/macros.rs b/fearless_simd/src/macros.rs index 1c25948d..e7227aeb 100644 --- a/fearless_simd/src/macros.rs +++ b/fearless_simd/src/macros.rs @@ -31,7 +31,7 @@ /// /// # Example /// -/// ``` +/// ```rust /// use fearless_simd::{Level, Simd, dispatch}; /// /// #[inline(always)] diff --git a/fearless_simd_dev_macros/src/lib.rs b/fearless_simd_dev_macros/src/lib.rs index 9c0f1c74..b38f1f70 100644 --- a/fearless_simd_dev_macros/src/lib.rs +++ b/fearless_simd_dev_macros/src/lib.rs @@ -41,7 +41,7 @@ pub fn simd_test(_: TokenStream, item: TokenStream) -> TokenStream { #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] let include_avx2 = false; // Note that we cannot feature-gate this with `target_arch`. If we run - // `wasm-pack test --headless --chrome`, then the `target_arch` will still be set to + // `cargo test --target wasm32-wasip1`, then the `target_arch` will still be set to // the operating system you are running on. Because of this, we instead add the `target_arch` // feature gate to the actual test. let include_wasm = !exclude_wasm(&input_fn_name.to_string()); @@ -49,7 +49,6 @@ pub fn simd_test(_: TokenStream, item: TokenStream) -> TokenStream { let fallback_snippet = if include_fallback { quote! { #[test] - #[cfg_attr(all(target_arch = "wasm32", target_feature = "simd128"), wasm_bindgen_test::wasm_bindgen_test)] fn #fallback_name() { let fallback = fearless_simd::Fallback::new(); #input_fn_name(fallback); @@ -101,7 +100,7 @@ pub fn simd_test(_: TokenStream, item: TokenStream) -> TokenStream { let wasm_snippet = if include_wasm { quote! { #[cfg(all(target_arch = "wasm32", target_feature = "simd128"))] - #[wasm_bindgen_test::wasm_bindgen_test] + #[test] fn #wasm_name() { let wasm = unsafe { fearless_simd::wasm32::WasmSimd128::new_unchecked() }; #input_fn_name(wasm); diff --git a/fearless_simd_tests/Cargo.toml b/fearless_simd_tests/Cargo.toml index 60fe5998..9eddb65d 100644 --- a/fearless_simd_tests/Cargo.toml +++ b/fearless_simd_tests/Cargo.toml @@ -20,7 +20,3 @@ workspace = true [dependencies] fearless_simd = { workspace = true, features = ["std"] } fearless_simd_dev_macros = { workspace = true } - -[target.'cfg(target_arch = "wasm32")'.dev-dependencies] -wasm-bindgen-test = "0.3.50" -wasm-bindgen = "0.2.100" diff --git a/fearless_simd_tests/README.md b/fearless_simd_tests/README.md index c4fb9981..bfbd429d 100644 --- a/fearless_simd_tests/README.md +++ b/fearless_simd_tests/README.md @@ -9,11 +9,23 @@ This is a development-only crate for testing `fearless_simd`. ### Testing WebAssembly +simd128 -Run browser tests with: +To run the WebAssembly tests, first install a WebAssembly runtime such as [wasmtime](https://docs.wasmtime.dev/introduction.html): ```sh -RUSTFLAGS=-Ctarget-feature=+simd128 wasm-pack test --headless --chrome +cargo install --locked wasmtime-cli ``` -Currently these tests only enforce that WASM SIMD and the fallback scalar implementations match when -run in the browser. +Or [wasmi](https://github.com/wasmi-labs/wasmi): + +```sh +cargo install --locked --features simd wasmi_cli +``` + +Run WebAssembly tests with: + +```sh +cargo test --target wasm32-wasip1 \ + --config 'target.wasm32-wasip1.rustflags = "-Ctarget-feature=+simd128"' \ + --config 'target.wasm32-wasip1.rustdocflags = "-Ctarget-feature=+simd128"' \ + --config 'target.wasm32-wasip1.runner = "wasmtime"' # or "wasmi_cli" if you installed that +``` diff --git a/fearless_simd_tests/tests/mod.rs b/fearless_simd_tests/tests/mod.rs index 20b40351..8f5285a6 100644 --- a/fearless_simd_tests/tests/mod.rs +++ b/fearless_simd_tests/tests/mod.rs @@ -10,9 +10,6 @@ use fearless_simd::*; use fearless_simd_dev_macros::simd_test; -#[cfg(target_arch = "wasm32")] -wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); - mod harness; #[simd_test]