Ray's Knowledge Base
Unlock

Merge a crate's tests/*.rs into one tests/it integration binary

RecipeVerified 30 Oct 2026Holds anywhere
Recipe. When to use it, the steps, and what showed that they work.

When to use#

A task asks for one integration test program per crate, with no tests/*.rs left at the top of crates//tests. Use it when files share mod common;, use include_str! on golden files, use insta snapshots, or build temp names from the pid.

Steps#

  1. Run rvow prove <task> once before any edit, to record the red. Save the baseline with cargo nextest list --workspace --message-format oneline.
  2. Move each tests/.rs to tests/it/.rs with rgit mv. Move tests/common/mod.rs to tests/it/common/mod.rs. Move tests/golden to tests/it/golden. Moved together, the relative include_str! paths still resolve, so they need no edit.
  3. Write tests/it/main.rs with a //! line, one mod common;, then one mod <name>; per file in alphabetical order.
  4. In each module, drop mod common; and use crate::common::.... Also fix fully qualified common:: paths.
  5. Move tests/snapshots to tests/it/snapshots and rename each file to it__<old name> with rgit mv. Only the source: header line in each .snap may change. Diff every .snap against HEAD.
  6. Make temp names unique. A name built from the pid alone gets a static atomic counter. A prefix shared with another file gets the module name.
  7. Keep files with their own #[global_allocator] or getrusage(RUSAGE_SELF) as separate programs.
  8. Run INSTA_UPDATE=no cargo test --locked -p <crate>, then cargo nextest list --locked -p <crate> --message-format oneline. Each old <crate>::<file> <test> must appear as <crate>::it <file>::<test>. Then run fmt, clippy with -D warnings, and rvow prove <task> again.
  9. Record the drift with rvow amend --reason "move only: ...". Never run rvow accept or rvow confirm.
  10. Evidence#

    rmaestro-tui task TSK-7fwbg8: 215 tests before and after, all names mapped, proved. Amendment AMD-60nbgq. Note from the run: "rvow amend records the drift of the whole change, not just my task." It also lists files moved by other sessions, and the user must confirm it later.