# Plan: consolidate integration tests into one binary **Date:** 2026-06-02 · **Status:** done ## Outcome (measured) | Metric | Before | After | |---|---|---| | `target/debug/deps` | 1.5 GB | **629 MB** (−58%) | | Integration-test binaries | 26 | **2** (`it` + `typing_surface_matrix`) | | Clean test build | 22.9 s | 22.4 s | | Lib-edit relink | 13.3 s | 12.4 s | | Tests | 2151/0/1 | 2151/0/1 (identical) | cargo auto-detected `tests/it/main.rs` as the `it` target — no `[[test]]` entry, no fixups, no warnings. **Correction to the build-time hypothesis:** the expected relink speed-up (≈13 s → ≈5 s) did *not* materialise. Wall-clock is dominated by *compiling* (the lib + ~290 deps + the test code's codegen/monomorphisation), not by *linking*. Consolidation collapses 26 link steps into 2 — which is why **disk** drops 58 % (each link emits a whole standalone binary) — but compile work is unchanged, so build time barely moves. **The real, durable win is disk, not speed.** Minor cost: editing a single test file now recompiles the whole `it` module set (test-only edits marginally slower; lib edits marginally faster — a wash). Kept for the disk benefit, which is exactly the concern that prompted it. ## Why Each top-level `tests/*.rs` is a separate integration-test *crate* → its own binary, each statically linking the bundled engine + every dependency + debug info. There are **26** of them. With incremental disabled (build-hygiene change, commit `42f9553`), an edit to the lib forces **all 26 to relink**. **Measured baseline:** - Lib-edit relink (touch `src/app.rs`, `cargo test --no-run`): **13.3 s** - Clean build of all test targets (`cargo clean && cargo test --no-run`): **22.9 s** - `target/debug/deps`: **1.5 GB** Collapsing to one binary turns 26 links into 1 — the dominant cost in both numbers. ## Approach The pattern already used by `tests/typing_surface_matrix.rs` (one binary that `mod`-includes the `tests/typing_surface/` modules). Apply it to the other 25 standalone files. Feasibility pre-checks (done, all clear): - **No top-level integration test uses insta** → moving files causes no snapshot-path churn. - **No crate-level `#![…]` attributes** to hoist. - **No shared `mod common;` helpers** to relocate; the 25 files are self-contained (`use rdbms_playground::…`), no inter-file `mod`. ## Steps 1. `mkdir tests/it`. 2. `git mv` the 25 standalone `tests/*.rs` → `tests/it/.rs` (everything except `typing_surface_matrix.rs`, which stays as its own already-consolidated binary). 3. Create `tests/it/main.rs` = `mod ;` for all 25. 4. Confirm cargo builds it as one target (`tests/it/main.rs` auto-detection; add an explicit `[[test]] name="it"` only if not). 5. Fix anything the combined build surfaces (expected minimal): a stray `use crate::` self-ref, or a clippy `dead_code`/unused-import the per-crate split had hidden. **End state: 2 integration-test binaries (`it` + `typing_surface_matrix`) instead of 26.** ## Verification / go-no-go gate - Full `cargo test` → identical **2151 / 0 / 1**. - `cargo clippy --all-targets -- -D warnings` clean. - Re-measure relink + clean build; record before/after in the commit. - If the after-numbers aren't materially better, **revert** (all `git mv`, trivially reversible). ## Tradeoff (accepted) Lose per-crate isolation: a compile error fails the whole `it` binary, and the 25 files share one crate namespace (module-scoped — no name clashes). Negligible for a solo teaching project; the build-speed win is the priority.