|
2 | 2 |
|
3 | 3 | This page covers testing conventions and practices for cascette-rs. |
4 | 4 |
|
| 5 | +## Pre-Submission Quality Gates |
| 6 | + |
| 7 | +Run these commands before every commit or PR. They match the CI workflow |
| 8 | +exactly. CI sets `RUSTFLAGS="-D warnings"` globally, so any warning becomes a |
| 9 | +hard error. **Running without that flag hides issues that will fail CI.** |
| 10 | + |
| 11 | +```bash |
| 12 | +# Format check |
| 13 | +cargo fmt --all -- --check |
| 14 | + |
| 15 | +# Compilation — all targets, warnings as errors |
| 16 | +RUSTFLAGS="-D warnings" cargo check --workspace --all-targets |
| 17 | + |
| 18 | +# Clippy — all targets, warnings as errors |
| 19 | +RUSTFLAGS="-D warnings" cargo clippy --workspace --all-targets |
| 20 | + |
| 21 | +# Tests — default features, warnings as errors |
| 22 | +RUSTFLAGS="-D warnings" cargo nextest run --profile ci --workspace |
| 23 | + |
| 24 | +# Tests — no default features |
| 25 | +RUSTFLAGS="-D warnings" cargo nextest run --profile ci --no-default-features --workspace |
| 26 | + |
| 27 | +# Documentation — warnings as errors |
| 28 | +RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps |
| 29 | + |
| 30 | +# WASM compilation check |
| 31 | +RUSTFLAGS="-D warnings" cargo check --target wasm32-unknown-unknown -p cascette-crypto -p cascette-formats |
| 32 | +``` |
| 33 | + |
| 34 | +All seven checks must pass before submitting changes. A PR that fails any |
| 35 | +of these will not be merged. |
| 36 | + |
| 37 | +### Common Pitfalls |
| 38 | + |
| 39 | +Running `cargo clippy` without `RUSTFLAGS="-D warnings"` produces warnings |
| 40 | +that silently pass locally but fail CI. Always use the exact commands above. |
| 41 | + |
| 42 | +Tests that use `.unwrap()` or `.expect()` in `#[cfg(test)]` modules need |
| 43 | +`#[allow(clippy::unwrap_used, clippy::expect_used)]` on the module — the |
| 44 | +workspace lints flag these even in tests. |
| 45 | + |
5 | 46 | ## Test Organization |
6 | 47 |
|
7 | 48 | ### Module Structure |
|
0 commit comments