From f03425f0142d432e733e1178160ce97c0bcedf26 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Fri, 29 Nov 2024 19:48:42 +0100 Subject: [PATCH] Run Wasm tests in workers as well --- .github/workflows/tests.yml | 29 +++++++++++++++++++++++------ Cargo.toml | 2 +- tests/mod.rs | 4 +--- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 890e133c..5bd11868 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -240,19 +240,18 @@ jobs: web: name: Web - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - - run: choco install wget - if: runner.os == 'Windows' - name: Install precompiled wasm-pack shell: bash run: | - VERSION=v0.12.1 + VERSION=v0.13.1 URL=https://github.com/rustwasm/wasm-pack/releases/download/${VERSION}/wasm-pack-${VERSION}-x86_64-unknown-linux-musl.tar.gz wget -O - $URL | tar -xz --strip-components=1 -C ~/.cargo/bin wasm-pack --version + node --version - uses: Swatinem/rust-cache@v2 - name: Test (Node) env: @@ -260,11 +259,29 @@ jobs: run: wasm-pack test --node - name: Test (Firefox) env: - RUSTFLAGS: -Dwarnings --cfg getrandom_backend="wasm_js" --cfg getrandom_browser_test + WASM_BINDGEN_USE_BROWSER: 1 + RUSTFLAGS: -Dwarnings --cfg getrandom_backend="wasm_js" run: wasm-pack test --headless --firefox - name: Test (Chrome) env: - RUSTFLAGS: -Dwarnings --cfg getrandom_backend="wasm_js" --cfg getrandom_browser_test + WASM_BINDGEN_USE_BROWSER: 1 + RUSTFLAGS: -Dwarnings --cfg getrandom_backend="wasm_js" + run: wasm-pack test --headless --chrome + - name: Test (dedicated worker) + env: + WASM_BINDGEN_USE_DEDICATED_WORKER: 1 + RUSTFLAGS: -Dwarnings --cfg getrandom_backend="wasm_js" + run: wasm-pack test --headless --firefox + - name: Test (shared worker) + env: + WASM_BINDGEN_USE_SHARED_WORKER: 1 + RUSTFLAGS: -Dwarnings --cfg getrandom_backend="wasm_js" + run: wasm-pack test --headless --firefox + - name: Test (service worker) + env: + WASM_BINDGEN_USE_SERVICE_WORKER: 1 + RUSTFLAGS: -Dwarnings --cfg getrandom_backend="wasm_js" + # Firefox doesn't support module service workers and therefor can't import scripts run: wasm-pack test --headless --chrome wasi: diff --git a/Cargo.toml b/Cargo.toml index 3b779eae..16e47a4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,7 +66,7 @@ windows-targets = "0.52" [target.'cfg(all(getrandom_backend = "wasm_js", target_arch = "wasm32", target_os = "unknown"))'.dependencies] wasm-bindgen = { version = "0.2.89", default-features = false } js-sys = "0.3" -[target.'cfg(all(getrandom_backend = "wasm_js", getrandom_browser_test, target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies] +[target.'cfg(all(getrandom_backend = "wasm_js", target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies] wasm-bindgen-test = "0.3.39" [features] diff --git a/tests/mod.rs b/tests/mod.rs index 204ec653..aec5df38 100644 --- a/tests/mod.rs +++ b/tests/mod.rs @@ -1,10 +1,8 @@ use core::mem::MaybeUninit; use getrandom::{fill, fill_uninit}; -#[cfg(getrandom_browser_test)] +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] use wasm_bindgen_test::wasm_bindgen_test as test; -#[cfg(getrandom_browser_test)] -wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); #[test] fn test_zero() {