Skip to content

test: convert assertions to inline snapshots across the codebase#672

Closed
MatthewMckee4 wants to merge 7 commits intotest/consolidated-auditfrom
test/snapshot-sweep
Closed

test: convert assertions to inline snapshots across the codebase#672
MatthewMckee4 wants to merge 7 commits intotest/consolidated-auditfrom
test/snapshot-sweep

Conversation

@MatthewMckee4
Copy link
Copy Markdown
Member

Summary

Converts hand-written assert_eq! checks across karva_logging, karva_diagnostic, and karva_metadata to inline insta snapshots. In karva_logging/time.rs the format_duration / format_duration_bracketed tests now pin the exact formatted string. In karva_diagnostic/traceback.rs the filter_traceback, parse_traceback_line, get_traceback_location, and calculate_line_range tests snapshot the full parsed Option<TracebackLocation> / Option<TextRange> shapes instead of building them by hand. In karva_metadata/options.rs the TOML-parsing and Combine merge tests now snapshot the whole struct so every field is pinned, not just the three or four that were previously checked.

Assertions were left as-is where a snapshot would not help: single-integer or single-enum-variant comparisons (e.g. MaxFail and RunHash tests), matches!-style property checks on TestPath variants, is_ok / is_err / len / is_empty checks in the cache and diagnostic stats tests, and roundtrip tests where the entire point is equality. The base branch is test/consolidated-audit (PR #670) so the diff reviews against just this sweep.

Test Plan

  • just test (888 tests pass)
  • uvx prek run -a (all hooks pass)

…r coverage

Removes two non-snapshot fail-fast tests in basic.rs that duplicated the
existing snapshot-based coverage, deletes trivial unit tests in
function_kind.rs and a helper-formula test module in orchestration.rs that
was testing a copy of the production logic, and adds an integration test
covering the last-failed plus filterset workflow.
Adds 32 new integration tests covering CLI flag combinations and
orchestration behaviours that were either untested or only had a happy
path. The additions are spread across basic, last_failed, configuration,
and a new discovery/edge_cases module.
Converts the hand-written equality checks in `format_duration` and
`format_duration_bracketed` tests to inline snapshots so intentional
format changes can be updated in bulk via `cargo insta review`.
Converts `filter_traceback`, `parse_traceback_line`,
`get_traceback_location`, and `calculate_line_range` unit tests to
inline snapshots. These assert on multi-line strings and
`Option<TracebackLocation>` / `Option<TextRange>` structs where seeing
the full parsed shape is much easier to review than hand-built
expected values.
Converts the TOML parsing and `Combine` merge tests on `Options`,
`TestOptions`, and `SrcOptions` to debug snapshots of the full struct.
The hand-written per-field asserts previously checked a handful of
fields in each merged struct; the snapshot form pins down every field
at once so intentional schema changes regenerate cleanly.
@MatthewMckee4 MatthewMckee4 added internal An internal refactor or improvement rust Pull requests that update rust code labels Apr 11, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 11, 2026

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 1 untouched benchmark


Comparing test/snapshot-sweep (92e25c2) with test/consolidated-audit (c312ef1)

Open in CodSpeed

@MatthewMckee4 MatthewMckee4 force-pushed the test/consolidated-audit branch from c312ef1 to ccee0f2 Compare April 11, 2026 19:29
@MatthewMckee4
Copy link
Copy Markdown
Member Author

Folded into #670 via cherry-pick of the karva_diagnostic traceback snapshot commit (27cb339). The karva_logging and karva_metadata conversions from this branch were already made directly on #670 in parallel.

@MatthewMckee4 MatthewMckee4 deleted the test/snapshot-sweep branch April 12, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal An internal refactor or improvement rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant