Skip to content

Add host, Miri, and bare-metal tests plus CI - #17

Merged
richardanaya merged 2 commits into
masterfrom
cursor/test-suite-and-ci-fec3
Oct 7, 2026
Merged

richardanaya merged 2 commits into
masterfrom
cursor/test-suite-and-ci-fec3

Conversation

@richardanaya

@richardanaya richardanaya commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #16 (cursor/replace-woke-with-alloc-wake-fec3), which is not merged yet. This PR is only the test suite, CI, and the small library adjustments those checks need. Retarget the base to master after #16 lands.

What the suite proves

Host tests in tests/behavior.rs (15, also run under Miri):

  • tasks run to completion, including many of them
  • is_done is false while work is queued or a finished task is still listed, and true after update drops it
  • tasks spawned from inside a running task are picked up
  • wake_by_ref and consuming wake, including from another thread, complete through update_woken then update
  • update_woken does not poll tasks that were not woken
  • a wake plus add_async during poll does not deadlock
  • a task is not polled again after Ready
  • Output types other than () (u32, String, and Cell<u32>, which is Send but not Sync)
  • finished output is dropped, and the task future itself is dropped when update removes it
  • a short many-wake stress run finishes quickly

no_std

nostd-test is a #![no_std] #![no_main] binary with a 16 KiB bump allocator. QEMU (lm3s6965evb, Cortex-M3, semihosting) runs it and exits 0. The harness checks, with no std linked:

  • is_done starts true
  • a completing task is dropped
  • add_async from inside a task
  • a self-wake
  • eight tasks
  • a u32 output

CI also cargo checks the library for wasm32-unknown-unknown and thumbv7m-none-eabi.

thumbv6m-none-eabi (Cortex-M0) is not supported. That target has no pointer-width atomics (target_has_atomic="ptr" is absent), so alloc::sync::Arc is not available and spin::Mutex cannot CAS. The same class of failure happens on main (woke fails to import alloc::sync::Arc). Not a regression. Noted in the README.

CI

.github/workflows/ci.yml on pull requests and pushes to master:

  • rustfmt
  • cargo clippy --all-targets -- -D warnings (and the harness for thumbv7m)
  • cargo test, cargo doc --no-deps, and the four host examples
  • MSRV 1.63: cargo build --lib plus the two no_std cargo checks
  • QEMU run of nostd-test
  • cargo miri test

The 1.63 job does not run cargo test. Current async-std releases pull crates that need a newer compiler. The library itself builds on 1.63.

Checkout uses actions/checkout@v5 (Node.js 24). v4 still targets Node.js 20, which GitHub Actions now warns about.

Library adjustments in this PR

These are here so the checks above are honest, not in #16:

  • spin is pinned to 0.9.9 without lock_api. spin = "0" now resolves to 0.12, whose lock_api needs Rust 1.71, so a fresh 1.63 build could not meet the declared MSRV.
  • Queues are spin::Lazy, because VecDeque::new is not const on 1.63. Same queues, built on first use.
  • update_woken drains the woken queue and drops the guard before polling. spin::Mutex is not reentrant; holding it across poll deadlocked a wake from inside that poll. Wakes during poll are queued for the next update_woken.
  • update drops a task in the same pass that sees it finish, and does not poll a woken task that is already done.
  • The input queue is drained with while let instead of len() > 0. Stable clippy 1.99 denies clippy::len_zero under -D warnings.

examples/timer does not build: the external web crate's glob import now clashes with this crate's name, and set_inner_html is gone. Left unchanged.

Open in Web Open in Cursor 

cursoragent and others added 2 commits October 7, 2026 19:05
Pin spin 0.9.9 (no lock_api) and lazily build the queues so the
declared MSRV, Rust 1.63, can compile the library. Drain the woken
queue before polling so a wake during poll cannot deadlock a
non-reentrant spin mutex, and drop tasks in the update that finishes
them.

Host tests cover completion, is_done, nested spawn, wake and
wake_by_ref, cross-thread wakes, and drops. nostd-test runs the same
ideas on thumbv7m under QEMU with a bump allocator and no std.

Co-authored-by: richardanaya2_2048b.Q6_K_M.gguf <richardanaya@users.noreply.github.com>
Drain the input queue with while-let so clippy -D warnings passes on the current stable toolchain, and switch Actions checkout to v5 so jobs are not pinned to Node.js 20.

Co-authored-by: richardanaya2_2048b.Q6_K_M.gguf <richardanaya@users.noreply.github.com>
@richardanaya
richardanaya marked this pull request as ready for review October 7, 2026 20:06
@richardanaya
richardanaya changed the base branch from cursor/replace-woke-with-alloc-wake-fec3 to master October 7, 2026 20:06
@richardanaya
richardanaya merged commit b3c0332 into master Oct 7, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants