diff --git a/nodedb-client/Cargo.toml b/nodedb-client/Cargo.toml index e036aca22..2d729f2cc 100644 --- a/nodedb-client/Cargo.toml +++ b/nodedb-client/Cargo.toml @@ -35,5 +35,15 @@ zerompk = { workspace = true, optional = true } tokio-rustls = { workspace = true, optional = true } rustls-pemfile = { workspace = true, optional = true } -[dev-dependencies] +# The optional `tokio` above is the crate's own dependency and stays as it is; +# these are the dev-dependencies. Native needs nothing new, but the workspace +# entry cannot be used in both: workspace features are additive, so +# `{ workspace = true }` always carries the workspace's `features = ["full"]`, +# and tokio refuses to build on wasm with anything beyond +# `sync,macros,io-util,rt,time`. The wasm entry therefore names the version and +# the features directly, which is what keeps the test targets buildable on both. +[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] tokio = { workspace = true, features = ["rt", "macros"] } + +[target.'cfg(target_arch = "wasm32")'.dev-dependencies] +tokio = { version = "1", default-features = false, features = ["rt", "macros", "sync", "time"] } diff --git a/nodedb-crdt/Cargo.toml b/nodedb-crdt/Cargo.toml index e5e100bf7..dbd53f948 100644 --- a/nodedb-crdt/Cargo.toml +++ b/nodedb-crdt/Cargo.toml @@ -27,5 +27,12 @@ subtle = { workspace = true } getrandom = { workspace = true } [dev-dependencies] -tokio = { workspace = true } serde_json = { workspace = true } + +# Native-only dev-dependencies. `tokio = { workspace = true }` inherits +# `features = ["full"]`, and tokio refuses fs/io-std/net/process/ +# rt-multi-thread/signal on wasm; Cargo unifies dev-dependency features across +# the whole `cargo test` invocation, so it breaks every wasm test target in the +# build. No test or bench in this crate calls tokio. +[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] +tokio = { workspace = true } diff --git a/nodedb-mem/Cargo.toml b/nodedb-mem/Cargo.toml index 4ba61e85b..0f0830f1e 100644 --- a/nodedb-mem/Cargo.toml +++ b/nodedb-mem/Cargo.toml @@ -23,7 +23,17 @@ tikv-jemalloc-ctl = { workspace = true } libc = { workspace = true } [dev-dependencies] -tokio = { workspace = true } -fluxbench = { workspace = true } tracing-subscriber = { workspace = true } tempfile = { workspace = true } + +# Native-only dev-dependencies. `tokio = { workspace = true }` inherits +# `features = ["full"]`, `fluxbench` declares its own normal +# `tokio = { features = ["full"] }`, and tokio refuses +# fs/io-std/net/process/rt-multi-thread/signal on wasm; Cargo unifies +# dev-dependency features across the whole `cargo test` invocation, so either +# entry breaks every wasm test target in the build. Neither is reachable from a +# wasm test here: this crate has no tokio call sites, no benches and no tokio +# test attribute. +[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] +tokio = { workspace = true } +fluxbench = { workspace = true } diff --git a/nodedb-mem/src/budget.rs b/nodedb-mem/src/budget.rs index 8624a145e..9b34e485d 100644 --- a/nodedb-mem/src/budget.rs +++ b/nodedb-mem/src/budget.rs @@ -320,6 +320,9 @@ mod tests { assert_eq!(budget.allocated(), 0); } + // Drives the reserve path from real threads; `wasm32-wasip1` has none. + + #[cfg(not(target_arch = "wasm32"))] #[test] fn concurrent_reserves() { use std::sync::Arc; diff --git a/nodedb-mem/src/governor/reserve.rs b/nodedb-mem/src/governor/reserve.rs index 1b3cd5dfb..a2566111c 100644 --- a/nodedb-mem/src/governor/reserve.rs +++ b/nodedb-mem/src/governor/reserve.rs @@ -167,11 +167,7 @@ impl MemoryGovernor { #[cfg(test)] mod tests { - use std::sync::Arc; use std::sync::atomic::Ordering; - use std::thread; - - use nodedb_types::{DatabaseId, TenantId}; use super::*; use crate::engine_limits::EngineLimits; @@ -345,8 +341,16 @@ mod tests { // ── Concurrent reserves ─────────────────────────────────────────────────── + // Drives the reserve path from real threads; `wasm32-wasip1` has none. + + #[cfg(not(target_arch = "wasm32"))] #[test] fn concurrent_reserves_never_exceed_cap() { + use std::sync::Arc; + use std::thread; + + use nodedb_types::{DatabaseId, TenantId}; + let limits = EngineLimits::zeroed().with(EngineId::Vector, 10_000); let gov = Arc::new( MemoryGovernor::new(GovernorConfig {