diff --git a/Cargo.toml b/Cargo.toml index 0119f02..aa6700c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,8 +55,6 @@ julia = ["sdp", "dep:libc", "dep:num-derive", "serde", "faer-sparse"] # enable a blas/lapack source package python = ["sdp", "dep:libc", "dep:pyo3", "dep:num-derive", "serde", "faer-sparse"] -wasm = ["dep:web-time"] - #compile with faer supernodal solver option faer-sparse = ["dep:faer", "dep:faer-entity"] @@ -200,9 +198,10 @@ features = ["sdp","sdp-mkl"] # wasm compatibility # ------------------------------ -[dependencies.web-time] -optional = true -version = "0.2.3" +[target.'cfg(target_family = "wasm")'.dependencies] +web-time = "0.2.3" +[target.'cfg(target_family = "wasm")'.dev-dependencies] +wasm-bindgen-test = "0.3" # ------------------------------ # testing, benchmarking etc diff --git a/src/timers/timers.rs b/src/timers/timers.rs index 741d03f..1177ec2 100644 --- a/src/timers/timers.rs +++ b/src/timers/timers.rs @@ -2,14 +2,13 @@ use std::collections::HashMap; use std::ops::{Deref, DerefMut}; cfg_if::cfg_if! { - if #[cfg(feature="wasm")] { + if #[cfg(target_family = "wasm")] { use web_time::{Duration, Instant}; } else { use std::time::{Duration, Instant}; } } - #[derive(Debug, Default)] struct InnerTimer { diff --git a/tests/basic_qp.rs b/tests/basic_qp.rs index ac53947..f74060a 100644 --- a/tests/basic_qp.rs +++ b/tests/basic_qp.rs @@ -1,4 +1,6 @@ #![allow(non_snake_case)] +#[cfg(target_family = "wasm")] +use wasm_bindgen_test::*; use clarabel::{algebra::*, solver::*}; @@ -173,3 +175,12 @@ fn test_qp_dual_infeasible_ill_cond() { assert!(solver.solution.obj_val.is_nan()); assert!(solver.solution.obj_val_dual.is_nan()); } + +// a minimal test to check that the wasm build is working + +#[cfg(target_family = "wasm")] +#[wasm_bindgen_test] +fn test_qp_feasible_wasm() { + wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); + test_qp_feasible(); +}