Testing Guide
MIRR has a comprehensive test suite with 3000+ tests covering all compiler subsystems.
Test Organization
| Directory | Contents |
|---|---|
tests/ | Integration tests |
src/*/ | Unit tests (inline #[cfg(test)]) |
benches/ | Benchmarks |
fuzz/ | Fuzz targets |
Writing Tests
Unit Tests
Unit tests go inline in the module they test:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_feature() {
assert_eq!(result, expected);
}
}
Integration Tests
Integration tests go in tests/ directory:
#![forbid(unsafe_code)]
#![deny(warnings)]
use mirrc::pipeline::{run_pipeline, PipelineConfig};
#[test]
fn test_full_pipeline() {
let source = "module test { signals { x: in bool } }";
let config = PipelineConfig::default();
let result = run_pipeline(source, &config);
assert!(result.is_ok());
}
Test Conventions
- File size limit: Test files must be ≤ 600 lines (CI enforced)
- No unsafe code: All test files use
#![forbid(unsafe_code)] - Zero warnings: All test files use
#![deny(warnings)] - Bounded loops: All loops must have explicit upper bounds
- Error codes: Use
[E-codes]in assertions
Running Tests
# All tests
cargo test --all
# With nextest (recommended)
cargo nextest run
# Specific test
cargo nextest run --test riscv_integration_tests
# With output
cargo test -- --nocapture
Test Coverage
| Subsystem | Test Files | Approx Tests |
|---|---|---|
| Parser | 5+ | 200+ |
| Type checker | 3+ | 150+ |
| Width inference | 4+ | 300+ |
| Temporal | 3+ | 200+ |
| Emitters | 5+ | 400+ |
| Symbolic | 2+ | 200+ |
| MAPE-K | 2+ | 300+ |
| S-expression | 3+ | 200+ |
| Patterns | 2+ | 100+ |
| Integration | 10+ | 500+ |
See Also
- Nextest Guide — Optimized test runner