From 9efae59c3c09287801254f28bbfe2e57ece1c8b7 Mon Sep 17 00:00:00 2001 From: "claude@clouddev1" Date: Tue, 2 Jun 2026 22:13:03 +0000 Subject: [PATCH] test: consolidate 25 integration crates into one `it` binary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each top-level tests/*.rs was its own crate → its own binary, each statically linking the bundled engine + every dep. 26 of them, so an edit to the lib relinked all 26. Moved the 25 standalone files into tests/it/ under one tests/it/main.rs (the pattern typing_surface already uses); cargo auto-detects it as the `it` target. End state: 2 integration-test binaries instead of 26. Result: target/debug/deps 1.5 GB → 629 MB (-58%). Build time barely moved (clean 22.9s→22.4s, lib-edit relink 13.3s→12.4s) — wall-clock is dominated by compiling, not linking, so this is a disk win, not a speed win (see docs/plans/20260602-test-consolidation.md). Tests unchanged at 2151/0/1; clippy clean; no fixups needed. typing_surface_matrix stays its own already-consolidated binary. Tradeoff: the 25 files now share one crate (a compile error fails the whole `it` binary; module-scoped namespaces, no clashes) — negligible for a solo project. --- docs/plans/20260602-test-consolidation.md | 88 +++++++++++++++++++ tests/{ => it}/case_insensitive_names.rs | 0 tests/{ => it}/column_op_guards.rs | 0 tests/{ => it}/engine_vocabulary_audit.rs | 0 tests/{ => it}/friendly_enrichment.rs | 0 tests/{ => it}/iteration2_persistence.rs | 0 tests/{ => it}/iteration3_rebuild.rs | 0 tests/{ => it}/iteration4a_rebuild_command.rs | 0 .../iteration4b_lifecycle_commands.rs | 0 tests/{ => it}/iteration5_export_import.rs | 0 tests/{ => it}/iteration6_resume_history.rs | 0 tests/it/main.rs | 34 +++++++ tests/{ => it}/parse_error_pedagogy.rs | 0 tests/{ => it}/project_lifecycle.rs | 0 tests/{ => it}/replay_command.rs | 0 tests/{ => it}/sql_alter_table.rs | 0 tests/{ => it}/sql_create_index.rs | 0 tests/{ => it}/sql_create_table.rs | 0 tests/{ => it}/sql_delete.rs | 0 tests/{ => it}/sql_dml_e2e.rs | 0 tests/{ => it}/sql_drop_index.rs | 0 tests/{ => it}/sql_drop_table.rs | 0 tests/{ => it}/sql_insert.rs | 0 tests/{ => it}/sql_select.rs | 0 tests/{ => it}/sql_update.rs | 0 tests/{ => it}/undo_snapshots.rs | 0 tests/{ => it}/walking_skeleton.rs | 0 27 files changed, 122 insertions(+) create mode 100644 docs/plans/20260602-test-consolidation.md rename tests/{ => it}/case_insensitive_names.rs (100%) rename tests/{ => it}/column_op_guards.rs (100%) rename tests/{ => it}/engine_vocabulary_audit.rs (100%) rename tests/{ => it}/friendly_enrichment.rs (100%) rename tests/{ => it}/iteration2_persistence.rs (100%) rename tests/{ => it}/iteration3_rebuild.rs (100%) rename tests/{ => it}/iteration4a_rebuild_command.rs (100%) rename tests/{ => it}/iteration4b_lifecycle_commands.rs (100%) rename tests/{ => it}/iteration5_export_import.rs (100%) rename tests/{ => it}/iteration6_resume_history.rs (100%) create mode 100644 tests/it/main.rs rename tests/{ => it}/parse_error_pedagogy.rs (100%) rename tests/{ => it}/project_lifecycle.rs (100%) rename tests/{ => it}/replay_command.rs (100%) rename tests/{ => it}/sql_alter_table.rs (100%) rename tests/{ => it}/sql_create_index.rs (100%) rename tests/{ => it}/sql_create_table.rs (100%) rename tests/{ => it}/sql_delete.rs (100%) rename tests/{ => it}/sql_dml_e2e.rs (100%) rename tests/{ => it}/sql_drop_index.rs (100%) rename tests/{ => it}/sql_drop_table.rs (100%) rename tests/{ => it}/sql_insert.rs (100%) rename tests/{ => it}/sql_select.rs (100%) rename tests/{ => it}/sql_update.rs (100%) rename tests/{ => it}/undo_snapshots.rs (100%) rename tests/{ => it}/walking_skeleton.rs (100%) diff --git a/docs/plans/20260602-test-consolidation.md b/docs/plans/20260602-test-consolidation.md new file mode 100644 index 0000000..78738e3 --- /dev/null +++ b/docs/plans/20260602-test-consolidation.md @@ -0,0 +1,88 @@ +# 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. diff --git a/tests/case_insensitive_names.rs b/tests/it/case_insensitive_names.rs similarity index 100% rename from tests/case_insensitive_names.rs rename to tests/it/case_insensitive_names.rs diff --git a/tests/column_op_guards.rs b/tests/it/column_op_guards.rs similarity index 100% rename from tests/column_op_guards.rs rename to tests/it/column_op_guards.rs diff --git a/tests/engine_vocabulary_audit.rs b/tests/it/engine_vocabulary_audit.rs similarity index 100% rename from tests/engine_vocabulary_audit.rs rename to tests/it/engine_vocabulary_audit.rs diff --git a/tests/friendly_enrichment.rs b/tests/it/friendly_enrichment.rs similarity index 100% rename from tests/friendly_enrichment.rs rename to tests/it/friendly_enrichment.rs diff --git a/tests/iteration2_persistence.rs b/tests/it/iteration2_persistence.rs similarity index 100% rename from tests/iteration2_persistence.rs rename to tests/it/iteration2_persistence.rs diff --git a/tests/iteration3_rebuild.rs b/tests/it/iteration3_rebuild.rs similarity index 100% rename from tests/iteration3_rebuild.rs rename to tests/it/iteration3_rebuild.rs diff --git a/tests/iteration4a_rebuild_command.rs b/tests/it/iteration4a_rebuild_command.rs similarity index 100% rename from tests/iteration4a_rebuild_command.rs rename to tests/it/iteration4a_rebuild_command.rs diff --git a/tests/iteration4b_lifecycle_commands.rs b/tests/it/iteration4b_lifecycle_commands.rs similarity index 100% rename from tests/iteration4b_lifecycle_commands.rs rename to tests/it/iteration4b_lifecycle_commands.rs diff --git a/tests/iteration5_export_import.rs b/tests/it/iteration5_export_import.rs similarity index 100% rename from tests/iteration5_export_import.rs rename to tests/it/iteration5_export_import.rs diff --git a/tests/iteration6_resume_history.rs b/tests/it/iteration6_resume_history.rs similarity index 100% rename from tests/iteration6_resume_history.rs rename to tests/it/iteration6_resume_history.rs diff --git a/tests/it/main.rs b/tests/it/main.rs new file mode 100644 index 0000000..3bd4270 --- /dev/null +++ b/tests/it/main.rs @@ -0,0 +1,34 @@ +//! Consolidated integration-test binary (see +//! `docs/plans/20260602-test-consolidation.md`). +//! +//! Each former top-level `tests/*.rs` is now a module here, so the +//! whole suite links into **one** binary instead of 26 — turning an +//! edit-the-lib-then-test cycle from 26 separate links into one. +//! `tests/typing_surface_matrix.rs` stays a separate binary (it is +//! already a consolidated `mod`-based target). + +mod case_insensitive_names; +mod column_op_guards; +mod engine_vocabulary_audit; +mod friendly_enrichment; +mod iteration2_persistence; +mod iteration3_rebuild; +mod iteration4a_rebuild_command; +mod iteration4b_lifecycle_commands; +mod iteration5_export_import; +mod iteration6_resume_history; +mod parse_error_pedagogy; +mod project_lifecycle; +mod replay_command; +mod sql_alter_table; +mod sql_create_index; +mod sql_create_table; +mod sql_delete; +mod sql_dml_e2e; +mod sql_drop_index; +mod sql_drop_table; +mod sql_insert; +mod sql_select; +mod sql_update; +mod undo_snapshots; +mod walking_skeleton; diff --git a/tests/parse_error_pedagogy.rs b/tests/it/parse_error_pedagogy.rs similarity index 100% rename from tests/parse_error_pedagogy.rs rename to tests/it/parse_error_pedagogy.rs diff --git a/tests/project_lifecycle.rs b/tests/it/project_lifecycle.rs similarity index 100% rename from tests/project_lifecycle.rs rename to tests/it/project_lifecycle.rs diff --git a/tests/replay_command.rs b/tests/it/replay_command.rs similarity index 100% rename from tests/replay_command.rs rename to tests/it/replay_command.rs diff --git a/tests/sql_alter_table.rs b/tests/it/sql_alter_table.rs similarity index 100% rename from tests/sql_alter_table.rs rename to tests/it/sql_alter_table.rs diff --git a/tests/sql_create_index.rs b/tests/it/sql_create_index.rs similarity index 100% rename from tests/sql_create_index.rs rename to tests/it/sql_create_index.rs diff --git a/tests/sql_create_table.rs b/tests/it/sql_create_table.rs similarity index 100% rename from tests/sql_create_table.rs rename to tests/it/sql_create_table.rs diff --git a/tests/sql_delete.rs b/tests/it/sql_delete.rs similarity index 100% rename from tests/sql_delete.rs rename to tests/it/sql_delete.rs diff --git a/tests/sql_dml_e2e.rs b/tests/it/sql_dml_e2e.rs similarity index 100% rename from tests/sql_dml_e2e.rs rename to tests/it/sql_dml_e2e.rs diff --git a/tests/sql_drop_index.rs b/tests/it/sql_drop_index.rs similarity index 100% rename from tests/sql_drop_index.rs rename to tests/it/sql_drop_index.rs diff --git a/tests/sql_drop_table.rs b/tests/it/sql_drop_table.rs similarity index 100% rename from tests/sql_drop_table.rs rename to tests/it/sql_drop_table.rs diff --git a/tests/sql_insert.rs b/tests/it/sql_insert.rs similarity index 100% rename from tests/sql_insert.rs rename to tests/it/sql_insert.rs diff --git a/tests/sql_select.rs b/tests/it/sql_select.rs similarity index 100% rename from tests/sql_select.rs rename to tests/it/sql_select.rs diff --git a/tests/sql_update.rs b/tests/it/sql_update.rs similarity index 100% rename from tests/sql_update.rs rename to tests/it/sql_update.rs diff --git a/tests/undo_snapshots.rs b/tests/it/undo_snapshots.rs similarity index 100% rename from tests/undo_snapshots.rs rename to tests/it/undo_snapshots.rs diff --git a/tests/walking_skeleton.rs b/tests/it/walking_skeleton.rs similarity index 100% rename from tests/walking_skeleton.rs rename to tests/it/walking_skeleton.rs