Rust Development
This section covers building, testing, and benchmarking the Rust crates of typstyle.
cargo build # Debug build
cargo build --release # Release build
cargo build -p typstyle # CLI only
cargo build -p typstyle-core # Core only
cargo build # Debug build
cargo build --release # Release build
cargo build -p typstyle # CLI only
cargo build -p typstyle-core # Core only
❗ Important
Update snapshots with cargo insta
cargo insta
when changing core library or fixtures.
Add CLI tests to crates/typstyle/tests/
crates/typstyle/tests/
when modifying CLI behavior. For style arguments, add tests to test_style_args.rs
test_style_args.rs
.
List all tests:
cargo nextest list --workspace
cargo nextest list --workspace
Run all tests and review snapshots:
cargo nextest run --workspace --no-fail-fast
cargo insta review
cargo nextest run --workspace --no-fail-fast
cargo insta review
Snapshot tests only:
cargo nextest run --workspace -E 'test([snapshot])' \
--no-fail-fast --no-default-features
cargo insta review
cargo nextest run --workspace -E 'test([snapshot])' \
--no-fail-fast --no-default-features
cargo insta review
Exclude end-to-end tests:
cargo nextest run --workspace -E '!test([e2e])' --no-fail-fast
cargo nextest run --workspace -E '!test([e2e])' --no-fail-fast
CLI tests only:
cargo nextest run -p typstyle --no-fail-fast
cargo nextest run -p typstyle --no-fail-fast
Integration tests:
cargo nextest run -p tests --no-fail-fast
cargo nextest run -p tests --no-fail-fast
Review and accept snapshot changes:
cargo insta review # Interactive review
cargo insta accept # Accept all changes
cargo insta review # Interactive review
cargo insta accept # Accept all changes
Using Criterion.rs:
cargo bench --workspace -- --list # List benchmarks
cargo bench --workspace # Run all benchmarks
cargo bench --workspace -- --list # List benchmarks
cargo bench --workspace # Run all benchmarks
View HTML reports at target/criterion/report/index.html
target/criterion/report/index.html
.
Format code:
cargo fmt --all
cargo fmt --all
Run clippy:
cargo clippy --workspace --all-targets --all-features
cargo clippy --workspace --all-targets --all-features
- Add tests to appropriate modules when implementing new features
- Use snapshot tests for formatter output validation
- Update snapshots after intentional changes to formatting behavior
- Add CLI integration tests for new command-line features
- Benchmark performance-critical changes