Skip to content

Commit

Permalink
Add WASM testing
Browse files Browse the repository at this point in the history
Signed-off-by: John Nunley <[email protected]>
  • Loading branch information
notgull committed Dec 16, 2023
1 parent 79b9292 commit 595c0de
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 3 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ jobs:
- name: Install Rust
run: rustup update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
- run: rustup target add thumbv7m-none-eabi
- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: Install cargo-hack and wasm-pack
uses: taiki-e/install-action
with:
tool: cargo-hack,wasm-pack
- run: cargo build --all --all-features --all-targets
- run: cargo hack build --feature-powerset --no-dev-deps
- run: cargo hack build --feature-powerset --no-dev-deps --target thumbv7m-none-eabi --skip std,default
Expand All @@ -50,6 +52,11 @@ jobs:
env:
RUSTFLAGS: ${{ env.RUSTFLAGS }} --cfg loom
LOOM_MAX_PREEMPTIONS: 2
- name: Check WASM tests
run: cargo build --target wasm32-unknown-unknown
- run: wasm-pack test
- run: wasm-pack test --no-default-features
- run: wasm-pack test --no-default-features --features portable-atomic

msrv:
runs-on: ubuntu-latest
Expand Down
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ name = "bench"
harness = false

[dev-dependencies]
criterion = "0.4.0"
criterion = { version = "0.4.0", features = ["cargo_bench_support"], default-features = false }
easy-parallel = "3.1.0"
fastrand = "2.0.0"

[target.'cfg(target_family = "wasm")'.dev-dependencies]
wasm-bindgen-test = "0.3"

[features]
default = ["std"]
std = []
3 changes: 3 additions & 0 deletions tests/bounded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ use std::sync::atomic::{AtomicUsize, Ordering};
use concurrent_queue::{ConcurrentQueue, PopError, PushError};
use easy_parallel::Parallel;

#[cfg(target_family = "wasm")]
use wasm_bindgen_test::wasm_bindgen_test as test;

#[test]
fn smoke() {
let q = ConcurrentQueue::bounded(2);
Expand Down
3 changes: 3 additions & 0 deletions tests/loom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ use loom::sync::atomic::{AtomicUsize, Ordering};
use loom::sync::{Arc, Condvar, Mutex};
use loom::thread;

#[cfg(target_family = "wasm")]
use wasm_bindgen_test::wasm_bindgen_test as test;

/// A basic MPMC channel based on a ConcurrentQueue and loom primitives.
struct Channel<T> {
/// The queue used to contain items.
Expand Down
3 changes: 3 additions & 0 deletions tests/single.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ use std::sync::atomic::{AtomicUsize, Ordering};
use concurrent_queue::{ConcurrentQueue, PopError, PushError};
use easy_parallel::Parallel;

#[cfg(target_family = "wasm")]
use wasm_bindgen_test::wasm_bindgen_test as test;

#[test]
fn smoke() {
let q = ConcurrentQueue::bounded(1);
Expand Down
3 changes: 3 additions & 0 deletions tests/unbounded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ use std::sync::atomic::{AtomicUsize, Ordering};
use concurrent_queue::{ConcurrentQueue, PopError, PushError};
use easy_parallel::Parallel;

#[cfg(target_family = "wasm")]
use wasm_bindgen_test::wasm_bindgen_test as test;

#[test]
fn smoke() {
let q = ConcurrentQueue::unbounded();
Expand Down

0 comments on commit 595c0de

Please sign in to comment.