Repository navigation
Read --json envelopes in CLI tests through one tests/common/envelope module (#1089) - #1272
Conversation
Assisted-by: Claude Code:claude-opus-5-5
About 25 test files each carried a private copy of the same --json envelope readers: parse stdout, read events[], find an event, and collect error and warning codes. The copies had drifted on strictness and shape, so the next suite to assert on codes would add one more. tests/common/envelope.rs now owns them, re-exported from common and includable on its own. The migrated files delete their copies, and a ratchet in the cli binary keeps new ones out (files changed by open PRs stay pending). Its self-tests run each former shape through the shared readers on the inputs where the copies differed. No production change. Assisted-by: Claude Code:claude-opus-5-5
Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 1ff215e. Configure here.
|
[agent] I don't think this PR caused it. The PR changes only CLI test helpers and doesn't touch This session can't re-run the job (the rerun call returned 403). Please re-run the failed job once. If it fails again, it's a real failure and needs a look. Generated by Claude Code |
|
Ready for review at
Generated by Claude Code |
LLM Description written by Claude Code:claude-opus-5-5
Refs #1089 (child 1: the shared JSON assertion helpers). Also refs #824 (one test-support module).
Summary
CLI tests now read the
--jsonenvelope through one module,tests/common/envelope.rs. It parses stdout, readsevents[], finds an event, and collects error and warning codes. About 25 private copies of those readers in 24 test files are deleted. A ratchet test stops new copies from appearing.Why
remove/covgap_commands_remove.rs, is changed by Use tests/common's binary() and git_sha256 in 40 more CLI tests (#824) #1258, so it moves in a later PR.events, others return empty.find_eventtakes eitherOption<&str>or a required code.eventsreturns eitherVec<(purl, action, errorCode)>or&Vec<Value>. There are five recursive "every code" walkers and six warning-code collectors.What changed
tests/common/envelope.rs, re-exported fromcommonand includable on its own with#[path = "common/envelope.rs"] mod envelope;:parse_json_envelope,json_string,envelope_error_code,envelope_error_message. These moved fromcommon/mod.rsunchanged and are re-exported, so existing callers don't change.events(strict),find_event(env, action, Option<code>),event_triples,event_codes(lenient),codes_in(warnings_array)andall_codes(recursivecode/errorCode).covgap_commands_vendor,vendor_eject,vendor_partial_staging_e2e,apply/check_verifies_installed_treeandvendor_group_commit_e2e;e2e_vendor_{bun,cargo,gem,golang,yarn_classic}_build;e2e_sbt_{build,hosted,vendor,vendor_build},e2e_scala_cli_vendor,e2e_sbt/agentande2e_vex_lockfile/{golang,sbt_vendored};e2e_gradle_agent_build,gradle_agent_cli,mode_migration_{bun,vlt},covgap_commands_scan_hostedandcoverage_fix_scan_hosted_dryrun_vendored.cli/envelope_helper_copies.rs:events, the golangOptionfind, absent triple fields, two chained warning arrays, non-string codes, and the order oferrorCodevscode.Deleted
git diff --stat origin/main: 28 files, +575/−462. All of it is test code; no production lines change. Of the additions, 109 are the shared module and 268 are the ratchet plus its self-tests. Without those, the migrated files are about −290 net.Behavior
No production change. In the tests:
eventsis now strict (it panics on a missing array) for the three callers that read it leniently. Every command envelope serializesevents, and those suites pass.e2e_vendor_golang_build's threefind_event(..).is_some()asserts now panic with the envelope, instead of a custom message, when the event is missing.Test evidence
cargo clippy --workspace --all-features -- -D warnings: clean.cargo test -p socket-patch-cli --all-features --tests --no-run: every CLI test target compiles with no warnings, including the ignored e2e and docker binaries.cli105 (with the new ratchet and self-tests),apply119,vendor_eject8,vendor_partial_staging_e2e9,covgap_commands_scan_hosted55,coverage_fix_scan_hosted_dryrun_vendored9,gradle_agent_cli52,vendor_group_commit_e2e11,e2e_sbt_vendor37,mode_migration_bun33,mode_migration_vlt26 (14 ignored),e2e_sbt_hosted29,spawn_env_hygiene12.covgap_commands_vendor: 52 passed, 3 failed. The 3*_state_write_failure_*tests depend on chmod and fail the same way onmainin this sandbox, because it runs as root; they pass in CI.Risk
Low. The change is test-only and compiles across every test target. The e2e build suites that need real package managers (bun, cargo, gem, Go, yarn classic, sbt, scala-cli, Gradle) were compiled but not run here.
🤖 Generated with Claude Code
Note
Low Risk
Test-only refactor with no production code changes; behavior shifts are limited to stricter envelope helpers in migrated tests.
Overview
Centralizes CLI
--jsonenvelope parsing for tests intests/common/envelope.rs(parse_json_envelope,events,find_event,event_triples,codes_in,all_codes, etc.) and re-exports the parse/error helpers fromcommon/mod.rs.~24 test files drop duplicated local readers and call the shared module instead (via
common::envelopeor#[path = "common/envelope.rs"]).cli/envelope_helper_copies.rsadds a ratchet that fails on new private envelope readers (with an allowlist for files still migrating) and self-tests that lock in former copy behavior (strict vs lenientevents, warning chaining, etc.).Test-only refactor for #1089; a few assertions now use stricter
events/ panic-on-missfind_eventwhere envelopes always includeevents[].Reviewed by Cursor Bugbot for commit 1ff215e. Configure here.
Generated by Claude Code