All tests run offline. No Ollama server required.
cargo test- Unit tests (
#[cfg(test)] mod testsin each source file):src/config/mod.rs— context window inference, max_tokens derivation, AGENTS.md loading, config.toml parsingsrc/agent/— ephemeral reminder computation (loop-breaker, iteration nudge, goal-aware re-anchor); mock-server integration tests for the fullAgent::runloop (streaming text, tool-call dispatch, 5xx retry, non-streaming JSON, model-not-found fails-fast) against a fake/chat/completionsendpoint; offline fake-model tests (src/agent/tests/fake_model.rs) that drive the loop via a scriptedCompletionSourcewith no HTTP (finish, blank-stall recovery + cap, tool round-trip, same-file serial edits, max_tokens clamp, auto-checkpoint event); eval-suite tests (src/agent/tests/eval_suite.rs) covering goal_set/todo_write persistence + injection, delegate_task, think, large tool-output caps, same-file serial edits, and compaction thrashingsrc/commands.rs— slash-command parsing, alias resolution, registry uniqueness, help renderingsrc/context.rs— token estimation, compaction (preserves system message, reduces tokens, keeps tool-call/result pairs), tool-result pruning, thrashing protectionsrc/state.rs— persistent todo/goal load/save round-trips, atomic writes, system-prompt formattingsrc/tools/— sandbox path confinement (including symlink-escape rejection andopenat2/open_beneathtraversal rejection), list_dir, read_file, write_file, search_replace, grep, run_shell (dangerous command blocking, API key stripping, direct-exec classification, confined-child behavior incl. Landlock/network-block/RLIMIT_FSIZE), worktree isolation between branches, dispatch routing, glob matching, unified diff parsing, apply_patch, document extractionsrc/plan.rs— plan parsing (JSON, numbered list, bullet list, code block), plan formattingsrc/tokenizer.rs— token counting behaviorsrc/tui/render.rs+src/tui/markdown.rs— markdown rendering (headings, bold/italic, inline code, fenced code blocks, ordered/unordered lists, blockquotes, links, tables, unclosed-token degradation), scrollback pre-wrapping, tool-call glimmer/fade
- Integration tests (
tests/):tests/cli_smoke.rs— black-box tests of the compiled binary (CARGO_BIN_EXE_raven):--help/--versionoutput, no-task error, and session persistence round-trip
Writing the test suite caught two real bugs in production code:
glob_segment_matchindex bug — comparedt[pi]instead oft[ti]after star-backtracking, causing*.rsto never matchmain.rsWalkDirroot filtering —filter_entryskipped the root directory entry because temp dirs start with., causing grep/search_code to find zero filesapply_patcherror handling — context mismatch errors were silently written to the file instead of being returned to the callersafe_resolvetraversal detection —Path::starts_withon non-canonicalized paths passed traversal checks because..components matched the workspace prefix
Install llvm-cov:
rustup component add llvm-tools-preview
cargo install cargo-llvm-covRun coverage:
cargo llvm-cov
cargo llvm-cov --html # opens HTML report in browserTarget: >=80% line coverage on config/mod.rs and tools/. Overall coverage
as high as practical without testing pure glue (main.rs argument parsing,
tui/ rendering).
Install cargo-mutants:
cargo install cargo-mutantsRun mutation tests (focuses on logic-heavy modules):
cargo mutants --jobs 2To exclude noisy modules (UI glue, main entry):
cargo mutants --exclude-file src/main.rs --exclude-file src/tui/mod.rs --jobs 2Fix surviving mutants that indicate weak assertions. Don't chase 100% kill rate on logging-only or display-only code.
Task-level agent strength is measured by the opt-in suite under evals/.
| Layer | Command | Model? |
|---|---|---|
| A — offline harness | cargo test eval_suite |
No (scripted fake model) |
| B — live fixtures | python3 evals/run.py --smoke or full |
Yes |
| C — arena | full suite × multiple models | Yes |
Live runs copy each evals/cases/<id>/repo to a temp workspace, invoke headless
raven, then grade with deterministic checks.sh (not LLM-as-judge). Reports
go to evals/out/; update evals/baselines/default.md only after a deliberate
pinned run.
CI policy: cargo test always (includes Layer A). Live smoke/full is manual or
nightly when an endpoint is available.
- Live Ollama API calls in
cargo test— real model responses require a running endpoint and are not part of the default suite. Usepython3 evals/run.pyfor live task evals. The HTTP/streaming loop is covered by mock-server integration tests (see above). - TUI rendering — the markdown renderer and scrollback pre-wrapping logic
are unit-tested (see
src/tui/render.rs+src/tui/markdown.rs), but the ratatui/crossterm event loop and interactive layout are not; those are exercised manually. - Network retries against a real host — the retry-with-backoff logic is covered against the mock (a scripted 503), and the connection-refused path by pointing at an unreachable host.