Development Guide
Prerequisites
- Rust (stable toolchain)
- Node.js 18+ (for the VS Code extension only)
Build
cargo build # Debug build
cargo build --release # Release build
Test
cargo test # All tests
cargo test --lib # Unit tests only
cargo test --test integration_tests # Integration tests only
cargo test <test_name> # Single test by name
Lint
cargo fmt --all -- --check # Check formatting
cargo clippy -- -D warnings # Lint (CI treats warnings as errors)
VS Code extension
cd editors/vscode
npm install
npm run compile
Press F5 in VS Code to launch a development instance with the extension.
Test structure
Unit tests
Inline in each module (#[cfg(test)] blocks).
Integration tests
End-to-end CLI tests in tests/integration_tests.rs. These run infr check/infr build on temp files and verify stderr/stdout.
Conformance tests
Self-contained .infr files in tests/conformance/ with expected diagnostics as comments:
const x <- 5
x <- 10 #> Error [infr]: Cannot reassign const binding `x`
To add a conformance test, create a new .infr file in tests/conformance/ with expected diagnostic comments.
Snapshot tests
Input/output pairs in tests/snapshots/. Each .infr file has a corresponding .R expected output, verified by the insta crate.
Bug fix workflow
- Add a regression test that reproduces the issue
- Run the test and observe it fail
- Implement the fix
- Run the test and observe it pass
Code quality principles
- Prefer clean, long-term solutions over quick hacks
- A proper fix in the right layer is better than a workaround in the wrong one
- If the right fix requires modifying the parser or AST, do that instead of hacking around it