Testing and simulation
Most tests drive real urepo-core and urepo-ext code inside urepo_sys::sim::World so virtual clocks, concurrent task completion order, process crashes, write faults, and lost HTTP replies replay deterministically from a single u64 seed.
Verification commands
Run checks in this order before merging or handing off:
cargo fmt --all --check
cargo clippy --workspace --all-targets --locked -- -D warnings
RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --locked
cargo test --workspace --lockedRun a single crate during development:
| Command | Covers |
|---|---|
cargo test -p urepo-sys |
Real OS seam, simulator, simulated S3 bucket, and Real/World file conformance |
cargo test -p urepo-core |
Domain rules, key and view golden contracts, and multi-seed simulation invariants |
cargo test -p urepo-ext |
Built-in and local extensions, recorded cargo metadata, GitHub replay fixtures, and github_sim |
cargo test -p urepo-cli |
Real urepo binary exit codes, JSON views, examples, and doc sample validation |
cargo test -p urepo-import |
The mise.toml translation in the simulator, its view and error golden contracts, and the real urepo-import binary |
cargo test -p urepo-policies |
Crate layers, seam isolation, and doc links |
Test layers
| Layer | Location | Verifies |
|---|---|---|
| Unit tests | #[cfg(test)] in source files |
Names, sizes, gates, ignore matching, canonical hashing |
| Golden contracts | crates/core/tests/suite/contracts, crates/cli/tests/suite/contracts, crates/import/tests/suite/contracts |
Key stability, archive bytes, JSON view schemas, CLI help text (UREPO_BLESS=1 to update) |
| Simulation invariants | sim::check in crates/core/tests/suite and crates/sys/tests/suite |
Store durability, scheduler ordering, key determinism, and release safety under injected kills and faults |
| End-to-end CLI | crates/cli/tests/suite/command |
Real urepo binary exit codes and JSON output |
| Policies and docs | crates/policies/tests/, crates/cli/tests/suite/{docs,examples}.rs |
Architecture rules, doc links, valid TOML/JSON doc samples, CLI command coverage, runnable examples |
Deterministic simulation
urepo_sys::sim::check runs DEFAULT_SEEDS seeds per invariant test (200 in debug builds, 1000 in release builds). Override the count with UREPO_SEEDS, or replay one failing seed with its full call trace using UREPO_SEED:
UREPO_SEED=42 cargo test -p urepo-core --test suite store::invariants -- --nocapture
UREPO_SEEDS=10000 cargo test --release -p urepo-core --test suite key::invariantsKey simulation invariants guarded across seeds:
- Store: readable records always have both blobs present; concurrent writers for one key leave one valid record;
store cleannever deletes a blob referenced by a readable record. - Scheduler: tasks run at most once per run, never before prerequisites finish, and
currenttasks always have satisfying records; an interrupted run finishes cleanly on restart. - Keys: identical declared inputs yield identical keys across platform classes, and changing any key input field changes the key.
- Releases: one apply per project and environment runs at a time; only tested, desired commits are applied, and none twice; a commit reaches an environment only once it is live in the one before, unless a request waives
after; a release moves only its own project; once faults stop, every release whose gates pass ends live.
Updating golden files
When you change a view or another golden contract on purpose, rewrite the golden files and read the git diff:
UREPO_BLESS=1 cargo test -p urepo-core --test suite contracts::Use -p urepo-cli or -p urepo-import for the goldens of those crates.