Conversation
…on wasip1
The workspace declares `tokio = { version = "1", features = ["full"] }`, and Cargo
unifies dev-dependency features across the whole `cargo test` invocation. On
`wasm32-wasip1` tokio refuses to build with anything beyond
`sync,macros,io-util,rt,time`, so one dev-dependency of that shape breaks every
wasm test target in the build: the shared-crate run for these three crates died
before reaching a single test (cargo exit 101, `error: Only features
sync,macros,io-util,rt,time are supported on wasm.`).
- `nodedb-mem` and `nodedb-crdt`: `tokio` becomes a
`cfg(not(target_arch = "wasm32"))` dev-dependency. `nodedb-mem` also gates
`fluxbench`, which declares its own normal `tokio = { features = ["full"] }`.
Native test builds keep both.
- Two tests in `nodedb-mem` drive the reserve path from real threads, which this
target does not have, and are gated to match. Their `Arc`, `thread`,
`DatabaseId` and `TenantId` imports move into the gated function, as the
neighbouring budget test already does.
- `nodedb-client` keeps its native dev-dependency and gets a second one for wasm:
`tokio = { version = "1", default-features = false, features = ["rt", "macros",
"sync", "time"] }`. Workspace inheritance is additive, so `{ workspace = true }`
always carries `full`; naming the version and features directly is what lets the
wasm target keep a Tokio runtime, and `rt`/`macros` are supported there. No test
needed gating: all of its tests run on both targets.
Measured, per crate, `cargo test --profile ci --target wasm32-wasip1 -p <crate>`
with `CARGO_TARGET_WASM32_WASIP1_RUNNER="wasmtime -W max-wasm-stack=33554432 --dir=."`:
nodedb-mem 83 passed, 0 failed (2 thread tests gated)
nodedb-crdt 168 passed, 0 failed
nodedb-client 34 passed, 0 failed
and natively, unchanged:
nodedb-mem 86 passed, 0 failed
nodedb-crdt 168 passed, 0 failed
nodedb-client 34 passed, 0 failed
The other twelve shared crates carry neither `tokio` nor `fluxbench` in a
dev-dependency, so this is the whole set that blocked the wasm test build for
them. `nodedb-wal` has the same problem and its own change in flight.
fmt clean; clippy clean for all three crates natively and for `wasm32-wasip1`.
Contributor
Author
|
Closing. This change is confined to the wasm32/wasip1 path. NodeDB is a server, does not build for either target, and will not support wasm; that work belongs to NodeDB Lite. If some part of this changes behaviour on a supported target, say which part and it returns as its own PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Make the test targets of
nodedb-mem,nodedb-crdtandnodedb-clientbuildand run on
wasm32-wasip1.nodedb-mem,nodedb-crdt:tokiobecomes acfg(not(target_arch = "wasm32"))dev-dependency.nodedb-memalso gatesfluxbench, which declares its own normaltokio = { features = ["full"] }.nodedb-mem/src/budget.rs,nodedb-mem/src/governor/reserve.rs: two tests thatdrive the reserve path from
std::thread::spawnare native-only, because thistarget has no threads. Their
Arc,thread,DatabaseIdandTenantIdimports move into the gated function, as the neighbouring budget test already
does.
nodedb-client: the native dev-dependency stays, and a second one covers wasm —tokio = { version = "1", default-features = false, features = ["rt", "macros", "sync", "time"] }.Why
The workspace declares
tokio = { version = "1", features = ["full"] }, and Cargounifies dev-dependency features across the whole
cargo testinvocation. On thistarget tokio refuses anything beyond
sync,macros,io-util,rt,time, so a singledev-dependency of that shape breaks every wasm test target in the build. All three
crates died before reaching a test:
Workspace inheritance is additive, so
{ workspace = true, features = ["rt", "macros"] }does not avoid
full; the wasm entry therefore names the version and the featuresdirectly.
rtandmacrosare supported on this target, which is whynodedb-clientkeeps a Tokio runtime there and needs no test gating: all of itstests run on both targets.
The other twelve shared crates have neither
tokionorfluxbenchin adev-dependency section, so this is the whole set for the shared-crate wasm build.
nodedb-walhas the same shape and is covered by its own change.How to check it
nodedb-memnodedb-crdtnodedb-clientThe three
nodedb-memtests that do not run on this target are accounted for: twoare the thread tests gated here, and one is excluded by an existing
cfg(not(target_arch = "wasm32"))innodedb-mem/src/arena.rs.Before the change the same three
cargo check --testsinvocations exit 101 withthe tokio error above; after it they exit 0 and the suites run.
cargo fmt --all -- --checkexits 0;cargo clippy -p <crate> --all-targets -- -D warningsexits 0 natively and for--target wasm32-wasip1.Scope
tokio = ["full"]is untouched: narrowing it would change everynative consumer. The narrowing is per crate, at the dev-dependency.
and the native counts above are unchanged from before.
gating in
nodedb-waland thedocs/wasm.mdnote remain in their own changes.nodedb-client's optional normaltokiostill carries theworkspace's
full, so a wasm build with itsremoteornativefeature enabledstill fails; that is a question about the crate's feature set, not about its
tests, and it is left alone here.