Move the inline tests out of commands.rs and sync/reconciliation.rs - #441
Merged
lamemustafa merged 1 commit intoSep 16, 2026
Merged
Conversation
docs/proposed-rust-module-conventions.md item 2, continuing #440. Four inline test modules move to files beside their parents, each kept as the same child module via #[path], so private access, test paths and module paths are unchanged: commands.rs tests -> commands_tests.rs statement_export_tests -> commands_statement_export_tests.rs party_statement_export_tests -> commands_party_statement_export_tests.rs sync/reconciliation.rs tests -> reconciliation_tests.rs commands.rs has production code after its first test block; it stays in place. commands.rs goes from 4,684 to 3,580 lines; reconciliation.rs from 2,578 to 1,708. Checked, not asserted: - Both parents rebuild byte-identical to HEAD from the new parent plus the re-indented children, expanding only the three moved commands.rs modules (the existing commands_native_ledger_tests.rs declaration is untouched). - rustfmt changed layout only: two trailing commas in commands_tests.rs, and in reconciliation_tests.rs two match arms `=> { assignment }` rewritten as `=> assignment,`, which both evaluate to (). The 559 string literals in those two reformatted files are identical; the other two test files and both parents were unchanged by rustfmt. - Whole-lib test lists are identical before and after under default (968), voucher-scan (986), live-calibration-harness (988) and lab-writes (1,068). The 67 moved tests pass. The only compiler warnings are the two existing unused variables in runtime.rs under voucher-scan. - The two #[cfg(unix)] tests moved; unix includes the macOS host. The target_os cfgs in commands.rs are in production code that did not move. - Text readers checked: scripts/client-grouping.test.mjs and ledger-entries-ui.test.mjs read commands.rs and still pass, as does the full frontend suite (239). check-tally-live-read-boundary.mjs scans reconciliation.rs for probe features and still passes. - clippy --lib --tests -D warnings is clean. Resealing changed exactly two pinned hashes; the coverage report counts four newly unsealed test-only modules and lists nothing else. The four new test files are unpinned, like #440's: tests decide nothing about what Bridge posts or emits, so they carry no pin reason. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
lamemustafa
deleted the
refactor/extract-commands-reconciliation-tests
branch
September 16, 2026 10:33
lamemustafa
added a commit
that referenced
this pull request
Sep 16, 2026
…_write_store.rs (#442) docs/proposed-rust-module-conventions.md item 2, continuing #440 and #441. Three inline test modules move beside their parents via #[path]: bridge-tally-protocol native_outstandings/wire.rs currency_tests -> wire_currency_tests.rs group_tests -> wire_group_tests.rs bridge db/tally_write_store.rs tests -> tally_write_store_tests.rs wire.rs goes from 1,796 to 1,262 lines; tally_write_store.rs from 1,794 to 1,259. No production change: both parents rebuild byte-identical to the base. rustfmt changed whitespace only; every string and char literal, including the eight multi-line ones, is identical. No test lost: the 23 moved wire.rs tests and 6 moved tally_write_store.rs tests pass, and whole-lib test lists are identical for bridge under default, voucher-scan, live-calibration-harness and lab-writes, and for bridge-tally-protocol under default and all features. The only compiler warnings are two existing unused variables in tally/runtime.rs under voucher-scan and live-calibration-harness. check-tally-request-builder-hazards.mjs skips only inline #[cfg(test)] blocks, so it now scans these extracted test files (and #440's and #441's) as production; its results are unchanged. The three new test files are unpinned, as in #440 and #441. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
lamemustafa
added a commit
that referenced
this pull request
Sep 16, 2026
…ot by name #440, #441 and #442 moved inline `#[cfg(test)] mod tests { ... }` blocks into sibling files loaded by `#[cfg(test)] #[path = "..."] mod tests;`. check-tally-request-builder-hazards.mjs skipped only the inline form, so it began reading those files as production code. Results did not change, but a test that builds a hazard-shaped string as an expectation would have raised a false alarm. Skipping any file named *_tests.rs was rejected: a safety scanner must not exempt production code for its file name. Instead a file is skipped only when it is actually loaded as a test module: - Edges: a brace-depth-0 out-of-line `mod name;` whose attribute group has a cfg implying test (cfg(test), or test as an argument of cfg(all(...))), with #[path] or bare in a crate root or mod.rs; plus any such declaration made by a file already test-only, iterated to a fixed point. - Vetoes, from every .rs file in the repository and matched by basename case-insensitively: any other `mod name;` at any depth (including macro bodies and inline modules), any `path = "..."` or include!-family string not part of an edge (covering cfg_attr), and every Cargo crate root. - Files whose braces underflow or do not end balanced contribute no edges. - Everything unhandled -- cfg(any(...)), #[path] inside an inline module, r#name -- leaves the file scanned, so an error is a false alarm, never a missed hazard. The design was critiqued before implementation. The critique found four ways the first draft could skip a production file -- a non-test declaration it did not recognise, a Cargo target, a declaration outside the scan roots, case variants -- and that it would still have scanned 24 of the 74 extracted files: 22 declared by other test files, one under cfg(all(test, ...)), one bare in a mod.rs. The veto set, the fixed point and those two cfg/bare shapes are the response. Checked, not asserted: on this repository the skipped set is exactly the 74 files the rustc-validated module graph from #436 marks test-only, path for path; the 10 pinned violations are unchanged. The skipped count is now pinned too, so a lexer regression that quarantines too much fails the gate. Main now runs under `import.meta.main` so the functions can be imported; a test runs the real script as a child process so a main that silently does nothing cannot pass. 15 fixture tests; 15 mutations of the scanner (trust file names, accept any cfg mentioning test, drop each veto, trust unbalanced files, accept nested declarations, drop propagation, drop the crate-root veto, case-sensitive veto, #[path] under the stem, main never running, no bare-mod detection, strings or comments not skipped, only the first attribute, no raw-string path) each fail a named test. One of those first survived because a fixture's production declaration masked the lexer; the fixture was fixed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Sep 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Continues #440 under
docs/proposed-rust-module-conventions.mditem 2: extract inline test modules first. No production change.src-tauri/src/commands.rscommands_tests.rs(754),commands_statement_export_tests.rs(31),commands_party_statement_export_tests.rs(314)src-tauri/src/sync/reconciliation.rsreconciliation_tests.rs(865)Each block stays the same child module via
#[cfg(test)] #[path = "…"] mod <name>;.commands.rshas production code after its first test block, and that code stays in place.Checked, not asserted
HEADfrom the new parent plus the re-indented children, expanding only the three movedcommands.rsmodules. The existingcommands_native_ledger_tests.rsdeclaration is untouched. The moved blocks contain no multi-line string literals.commands_tests.rsit removed two trailing commas. Inreconciliation_tests.rsit rewrote two match arms from=> { assignment }to=> assignment,; both forms evaluate to(). The 546 string and 13 char literals in those two files are identical. The other two test files and both parents were unchanged by rustfmt.voucher-scan(986),live-calibration-harness(988) andlab-writes(1,068). The 61 moved tests pass: 29 + 1 + 12 incommands.rs, 19 inreconciliation.rs. (Corrected from 67, which also counted six tests in modules that did not move.) The only compiler warnings are two unused variables that already exist inruntime.rsundervoucher-scan.#[cfg(unix)]test and the#[cfg(unix)]import it needs moved together;unixincludes the macOS host that ran them. Thetarget_oscfgs incommands.rsbelong to production code that did not move.scripts/client-grouping.test.mjsandledger-entries-ui.test.mjsreadcommands.rs, and both still pass.check-tally-live-read-boundary.mjsstill passes. ItsproductionSurfacesfeature check readsreconciliation.rsonly, so it no longer sees the moved test code. That test code contains no probe feature names, and test code cannot enable a production feature, but the scan is narrower than before (as withruntime.rsin Move the inline tests out of tally/runtime.rs and tally/connection.rs #440). Its other loop, which scans every.rsfile for probe identifiers, includes the new files.cargo clippy --lib --tests -- -D warnings -A clippy::pedanticis clean.--verifyexits 0. The coverage report countsnewly unsealed test-only modules: 4and lists nothing else.Coverage, as in #440
The four new test files are unpinned. Their ~1,960 lines were sealed only because they sat inside pinned files. Tests decide nothing about what Bridge posts or emits, so they carry no pin reason under #416's rule. The cost is the same as in #440: a change that only weakens one of these tests no longer changes a pinned hash.
🤖 Generated with Claude Code