# Testing and validation
Run focused tests first, then the complete project baseline:
```text
cargo fmt --all -- --check
cargo check --workspace --all-targets
cargo test --workspace --all-targets
cargo test --workspace --doc
RUSTDOCFLAGS="-D warnings -D missing-docs" cargo doc --workspace --no-deps
cargo run --example embed
cargo run --example native_function
```
On a filesystem without hard-link support, use a local target directory:
```text
CARGO_TARGET_DIR=/tmp/lehit-target CARGO_INCREMENTAL=0 cargo test --workspace --all-targets
```
## Test layers
- unit tests cover lexer, grammar, semantic passes, ABI validation, codegen, and JIT internals;
- integration tests under `tests/` lock down supported public import paths and host workflows;
- doctests keep docs.rs examples synchronized with the actual API;
- examples exercise complete embedding scenarios and are compiled by `--all-targets`.
## Adding tests
A language feature should normally have:
1. a lexer/parser regression if syntax changes;
2. a semantic success and failure case;
3. a runtime/codegen test when executable behavior changes;
4. a public integration test when host-facing API changes;
5. updated doctests when the recommended workflow changes.
Core tests must iterate over [`generate_core_lib`](crate::core_lib::generate_core_lib) rather than maintain a second handwritten module list.
Unsafe ABI changes require negative tests showing that invalid metadata is rejected before a pointer is called. Exact proc-macro diagnostics should eventually use UI tests; compile-only happy paths belong in integration tests and doctests.