test(operator_commands): audit + replace low-value smoke tests with output assertions - #4145
Merged
rysweet merged 1 commit intoJul 22, 2026
Conversation
…sertions Test-quality audit follow-up. The operator-command output renderers printed directly via `println!`, so their tests could only assert "does not panic" while discarding the actual rendered text. That left the real behavior — status filtering, priority/title/slug sorting, count lines, `<none>` placeholders, terminal-control sanitization, and concise-label formatting — unverified. Extract behavior-preserving pure helpers that return the rendered lines and have the `print_*` wrappers forward them to stdout (output is byte-identical), then rewrite the smoke tests to assert exact output: - operator_commands::format: add `format_labeled`, `*_section_lines` helpers; convert 9 `*_does_not_panic` tests into output assertions (sanitization, singularization, sorting/filtering, empty placeholders, terminal-handoff Some/None branches). - operator_commands::goals: add `render_lines` on the goal register view / section; convert 2 `print_does_not_panic` tests into full-output assertions. - operator_commands_terminal::commands: `terminal_recipe_list_does_not_panic` discarded its `Result`; assert the probe succeeds and descriptors are well-formed. No user-facing surface change: rendered stdout is identical; the print wrappers are still exercised for coverage. fmt clean; clippy (`--lib --tests --all-features --locked -D warnings`) clean; all 32 tests in the touched modules pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📊 Coverage Summary
Coverage data from CI run. Test files matching |
Owner
Author
|
CI update: all 16 checks green (pre-commit/verify, coverage, install-real, e2e-dashboard, cargo-deny/audit/vet, npm-audit, GitGuardian). The CI |
This was referenced Jul 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.
Summary
Test-quality audit of the Simard suite. The CI coverage metric
(
cargo llvm-cov --workspace --lib --bins --ignore-filename-regex 'tests?/')already reports 82.84% line coverage — well above the 70% target — so the
useful work here is the quality half of the mandate: finding tests that
execute code without verifying behavior and turning them into real
behavior assertions, rather than padding the metric.
The audit surfaced a coherent cluster of low-value tests in the
operator-command output layer: the renderers print directly via
println!, sotheir tests could only assert "does not panic" while discarding the actual
rendered text. That left the real behavior unverified — status filtering,
priority/title/slug sorting, count lines,
<none>placeholders,terminal-control sanitization, and concise-label formatting.
Changes
Behavior-preserving refactor: extract pure helpers that return the rendered
lines, and have the existing
print_*wrappers forward them to stdout(rendered output is byte-identical). Then rewrite the smoke tests to assert
exact output.
operator_commands::format— addedformat_labeled+*_section_lineshelpers; converted 9
*_does_not_panictests into output assertions(sanitization strips ANSI escapes,
Items→Itemsingularization, goalfiltering + priority sort, empty
<none>placeholders, terminal-handoffSome/Nonebranches incl. the missing-last_output_linefallback).operator_commands::goals— addedrender_lineson the goal registerview/section; converted 2
print_does_not_panictests into full-outputassertions (per-section counts,
<none>, concise-label rendering).operator_commands_terminal::commands—terminal_recipe_list_does_not_panicdiscarded its
Result(a probe can returnErrwithout panicking); nowasserts the probe succeeds and the descriptor list is non-empty and every
descriptor carries a name.
Net: 12 assertion-free / discarded-result smoke tests replaced with
behavior-verifying assertions. The thin
print_*wrappers are stillexercised once each so the
println!paths stay covered.Audit methodology
Scanned all ~9,600
#[test]/#[tokio::test]functions for anti-patterns(
assert!(true),assert_eq!(x, x), assertion-free bodies, discardedResults). Most heuristic hits were false positives (helper-based assertions,e.g.
overseer::signal'shas()helper). The genuine low-value cluster wasthe
does_not_panicstdout smoke tests fixed here. No tautological(
assert!(true)/assert_eq!(x, x)) tests exist in the tree.Evidence
cargo +nightly-2026-07-01 llvm-cov --workspace --lib --bins --ignore-filename-regex 'tests?/' --json --summary-only: overall 82.84% lines (143676/173432); functions 83.43%,regions 83.90%.
operator_commandsmodule 80.9% before this change.assertions verify exact rendered output (see files).
cargo fmt --all -- --checkclean.cargo clippy --lib --tests --all-features --locked -- -D warningsclean; pre-commit
cargo clippy --release --no-deps -- -D warningsandpre-push
cargo clippy --all-targets --all-features --locked -- -D warningsboth passed.
unrelated edits.
Surfaces changed
Internal only. The
print_*functions render byte-identical stdout (the*_lineshelpers are the single source of truth the wrappers now use), sothere is no user-facing behavior change and no docs update is required.