Split print_test_output() into focused helpers#536
Merged
MatthewMckee4 merged 1 commit intomainfrom Mar 21, 2026
Merged
Conversation
The 74-line print_test_output() mixed diagnostic printing, duration display, spacing logic, and result summary formatting. Extract two helpers so each section is self-contained: - print_diagnostics_section(): handles discovery and regular diagnostics with concise-mode spacing - print_durations_section(): handles the N-slowest display, returns whether anything was printed so the caller can decide on spacing Also simplify test() by resolving num_workers inline (merging the no_parallel check with the fallback) and validating watch+dry_run before extracting local variables. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Merging this PR will not alter performance
|
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.
Summary
print_test_output()was a 74-line function inkarva/src/commands/test/mod.rsthat mixed four concerns: diagnostic printing, duration display, blank-line spacing decisions, and result summary formatting. This made the spacing logic especially hard to follow, since blank lines depended on what the other sections had printed.This PR extracts two focused helpers:
print_diagnostics_section()— prints discovery diagnostics and regular diagnostics, each with their concise-mode trailing newline. The caller no longer needs to know about the internal structure of the two diagnostic blocks.print_durations_section()— prints the N-slowest-tests table and returnsboolindicating whether anything was printed. This lets the caller's spacing logic read as a simple condition (!has_diagnostics && !durations_printed) instead of recomputing the durations check inline.With these extracted,
print_test_output()shrinks to a clear sequence: leading blank line (if diagnostics), diagnostics, durations, trailing blank line (if nothing else printed one), result summary.Also simplifies
test()by resolvingnum_workersin one step (folding theno_parallelcheck into the fallback) and moving the--watch/--dry-runconflict check before the local variable extraction block.Terminal output is unchanged — all 685 snapshot and integration tests pass.
Test plan
just test— all 685 tests passuvx prek run -a— all pre-commit checks pass (including clippy)🤖 Generated with Claude Code