test: gate command output against its @HD sort-order claim - #580
Conversation
WalkthroughThe tests add subprocess-based BAM sort verification, create genuinely template-coordinate-sorted fixtures, and validate ordering claims for ChangesBAM output ordering validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #580 +/- ##
==========================================
+ Coverage 92.84% 92.88% +0.03%
==========================================
Files 166 166
Lines 102064 102064
==========================================
+ Hits 94765 94804 +39
+ Misses 7299 7260 -39 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Commands that write an `@HD SO/GO/SS` sort tag were promising an order nothing
verified. `group` ("output is always template-coordinate"), `dedup`, and `merge`
(default `--order template-coordinate`) all advertise SS:template-coordinate; only
`sort` (via --verify) and `simulate` (since the hermetic rewrite) actually checked
their output. (`simplex`/`duplex`/`codec` emit SO:unsorted, so there is nothing to
gate.)
Add a shared `assert_bam_sorted(bam, order, key_types)` helper that runs fgumi's
own `fgumi sort --verify` on a command's output, and apply it:
- group: assert the output verifies as template-coordinate (it does).
- dedup: assert the same. This surfaced that `create_sorted_bam` never actually
sorted its records -- it wrote them verbatim under a template-coordinate header,
so dedup (which trusts the header) emitted mislabelled-but-unsorted output.
Fixed the helper to genuinely sort its input via `fgumi sort`; dedup's output
then verifies, confirming dedup preserves the order (no dedup bug).
- merge: new test (merge had zero integration coverage) -- merge two genuinely
template-coordinate sorted inputs whose positions interleave, then assert the
merged output verifies as template-coordinate sorted.
4284e0c to
075fb5e
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/integration/helpers/assertions.rs`:
- Around line 234-245: Retain assert_bam_sorted as a diagnostic, but add an
independent identity-complete oracle and use it alongside existing checks: in
tests/integration/helpers/assertions.rs:234-245, provide test-only expected
record/key validation; in tests/integration/test_dedup_command.rs:137-139,
verify every output name, flag, position, and MI/duplicate state; in
tests/integration/test_group_command.rs:51-53, verify output read identities and
assigned MI values; and in tests/integration/test_merge_command.rs:616-617,
verify both records for each a/b/c/d template appear in the exact expected
order.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: bb170e88-cc43-4601-b1d4-47c06d49cea8
📒 Files selected for processing (4)
tests/integration/helpers/assertions.rstests/integration/test_dedup_command.rstests/integration/test_group_command.rstests/integration/test_merge_command.rs
Closes task-list T2. A command's
@HD SO/GO/SStags are a promise about output order that nothing verified — the same class of gap that hid the simulate sort bug, one layer up.Audit
Commands writing a sorted claim:
group("output is always template-coordinate"),dedup, andmerge(default--order template-coordinate).sort(via--verify) andsimulate(since #576's hermetic rewrite) were already covered;simplex/duplex/codecemitSO:unsorted(nothing to gate);extractemitsSO:unsorted.What
A shared
assert_bam_sorted(bam, order, key_types)helper runs fgumi's ownfgumi sort --verifyon a command's output. Applied to:create_sorted_bamnever actually sorted — it wrote records verbatim under a template-coordinate header, so dedup (which trusts the header) emitted mislabelled-but-unsorted output. Fixed the helper to genuinely sort viafgumi sort; dedup's output then verifies, confirming dedup preserves the order (no dedup bug).Verification
cargo ci-lintclean; the group/dedup/merge tests pass (9/9). Theassert_bam_sortedhelper is now the reusable gate for any future command that claims a sort order.Summary by CodeRabbit
dedup,group, andmergeoutputs maintain the expected template-coordinate order.