test(p2): pin loose error/output assertions to exact strings (#62 P2)#77
Merged
Conversation
Closes the last open P2 item from the audit. `integration_tests.rs` and
`command_contract_tests.rs` still asserted on wide `||` disjunctions and,
between them, had no exit-code assertions at all.
Several of the disjunctions could not fail in a useful way:
- `contains("already exists") || contains("Use --force")` — both halves come
from the same format string, so the alternation added nothing.
- `contains("Nuking") || contains("💥")` — likewise one println.
- `contains("Added submodule") || contains("movable-lib")` — the second half
is implied by the first, which embeds the name.
- `contains("complete") || contains("_submod") || contains("submod")` — the
last alternate matches any output mentioning the binary, so the bash
completion test passed on anything.
- `contains("Nuking") || contains("Reinitializing")` — a nuke-without-kill
that skipped the reinit half would still pass. Now both are required.
- `contains("Initializing") || contains("initialized")` could not tell the
two states apart; both sites now assert the specific state reached.
- `contains("Updated") || contains("Already up to date")` — "Already up to
date" appears nowhere in the source, so only one half was ever reachable.
Writing the update assertion surfaced that `submod update` never names the
submodules it touched: it forwards raw fetch refspec output to stdout and
then prints a summary count. The count is what the test now pins; the
noisy passthrough is left alone as a separate concern.
Also added `assert_eq!(status.code(), Some(1))` to the four failing-command
tests in `integration_tests.rs`, and made the invalid-repo test require that
the underlying "Repository not found" cause survives the "Failed to create
manager" wrapping rather than accepting either.
Two follow-ups from the same audit ride along:
- `#![forbid(unsafe_code)]` in lib.rs and main.rs. Cargo.toml was relaxed
from `forbid` to `deny` so the test crate could allow unsafe for its
tracking allocator, which left every src file able to opt out silently.
The library and binary now cannot.
- CLAUDE.md's testing section claimed `performance_tests.rs` uses criterion,
which is the doc drift P3 called out — criterion lives in
`benches/benchmark.rs`. Corrected, and the file list now covers
`fallback_tests.rs`, `git_ops_tests.rs`, and `security_tests.rs`, with a
pointer to the harness's git-state helpers.
Full suite 569 pass, fmt + clippy clean.
Closes #62
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XocU6NjgZricrRWMLyLXDn
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
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.
Closes the last open item from the #62 audit, plus two follow-ups found while auditing it.
P2 — the loose assertions
integration_tests.rsandcommand_contract_tests.rswere the two files the earlier P2 batch never reached. Between them they had 11 wide||disjunctions and zero exit-code assertions.Several couldn't fail in a useful way:
contains("already exists") || contains("Use --force")contains("Nuking") || contains("💥")println!contains("Added submodule") || contains("movable-lib")contains("complete") || contains("_submod") || contains("submod")contains("Nuking") || contains("Reinitializing")--killthat skipped the reinit half would still passcontains("Initializing") || contains("initialized")contains("Updated") || contains("Already up to date")Each is now pinned to the exact string the binary emits, and the two-part cases (
nuke+reinit,--allacross both submodules) assert each part separately so half-completion fails.Added
assert_eq!(output.status.code(), Some(1))to the four failing-command tests inintegration_tests.rs. The invalid-repo test now requires that the underlyingRepository not foundcause survives theFailed to create managerwrapping, instead of accepting either one.Found while writing the update assertion:
submod updatenever names the submodules it touched — it forwards raw fetch refspec output to stdout and then prints a summary count:The test now pins the count, which is the real contract. The plumbing passthrough is cosmetic and left as a separate concern — flagging it because it's the kind of thing an untightened assertion hides.
Follow-ups
#![forbid(unsafe_code)]inlib.rsandmain.rs.Cargo.tomlwas relaxed fromforbidtodenyso the test crate could#![allow(unsafe_code)]for its tracking allocator — which left everysrc/file able to opt out silently. The library and binary now can't.performance_tests.rs — benchmarks (uses criterion), which is exactly the doc drift P3 called out; criterion lives inbenches/benchmark.rs. Corrected, and the file list now coversfallback_tests.rs,git_ops_tests.rs, andsecurity_tests.rs, with a pointer to the harness's git-state helpers so future tests reach for those over printed output.Verification
Full suite 569 pass, 0 failed;
cargo fmt --checkandcargo clippy --all-features --all-targetsclean.Closes #62.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XocU6NjgZricrRWMLyLXDn