test(cli): binary-level integration tests (#41)#92
Merged
Conversation
…act (#41) Unit tests cover each command's logic and JSON shape in-process, but nothing invoked the built `surf` binary the way CI pipelines and agents do. Adds surf-cli/tests/cli.rs (assert_cmd + predicates) covering the three things only the process boundary exercises: - exit codes: clean check (0), diverged check (1), malformed-hub check (1, fails closed), blocking lint (1), and no-workspace (non-zero with a stderr message). - `--format json` parses from stdout and matches the versioned schema (REPORT_VERSION) for check, lint, verify, and stats. - stdout stays pure JSON when a command also warns on stderr (zero-match --files glob), since the report is machine-consumed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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 #41.
Unit coverage is solid, but nothing invoked the built
surfbinary — exit codes, human output, and the versioned--format jsoncontract (REPORT_VERSION, §5) were never tested the way CI pipelines and agents actually consume them.Adds
surf-cli/tests/cli.rs(assert_cmd+predicatesas dev-deps) covering the three things only the process boundary exercises:Exit codes
check→ 0check→ 1 (DIVERGEDon stdout)check→ 1 (fails closed, check: gate fails open — malformed hubs are skipped and hash errors count as clean #35)lint→ 1no surf.tomlmessage on stderrJSON contract —
--format jsonparses from stdout and carries the versioned schema forcheck,lint,verify, andstats(assertsversion == REPORT_VERSIONand the expected keys per command).Stream hygiene — stdout stays pure JSON even when a command also warns on stderr (zero-match
--filesglob), since the report is machine-consumed.Verification
cargo test -p surf-cli --test cli→ 10 passed. Fullcargo test --all,cargo fmt --all --check, andcargo clippy --all-targets --all-features -- -D warningsall clean.🤖 Generated with Claude Code