Skip to content

Use tests/common's binary() and git_sha256 in 40 more CLI tests (#824) - #1258

Merged
Mikola Lysenko (mikolalysenko) merged 3 commits into
mainfrom
arch-refactor/824-shared-test-helpers-2
Oct 9, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 3 commits into
mainfrom
arch-refactor/824-shared-test-helpers-2

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-opus-5-5

Refs #824 (children 2–3, slice 2; the tracker stays open for the files that open PRs change).

Summary

Forty more CLI test files drop their private binary() and git_sha256 and import the ones in tests/common instead. Standalone test binaries declare #[path = "common/mod.rs"] mod common;; directory binaries (apply/, cli/, get/, remove/, repair/, rollback/, scan/, e2e_vex_lockfile/) use crate::common. The two pnpm build suites keep their SOCKET_PATCH_PNPM_E2E_SOCKET_BIN override, renamed to socket_bin() so it no longer looks like a copy. The shared_helper_copies ratchet drops the 40 migrated files.

Why

What changed

  • 40 test files: private helpers deleted, shared ones imported; unused sha2/PathBuf imports removed.
  • 9 standalone e2e suites take cache_env/hermetic through common instead of loading them twice (189dddb, from the final review).
  • tests/cli/shared_helper_copies.rs: 40 entries removed from PENDING_PRIVATE_HELPERS (31 left: 27 files changed by open PRs, and 4 shared modules whose includers don't all declare mod common).

Deleted

git diff --stat origin/main: 41 files, +152/−421 (after 189dddb), all under crates/socket-patch-cli/tests. Production: 0 lines.

Behavior

None. Every removed git_sha256 was the Git-blob SHA-256 (SHA256("blob <len>\0" ++ bytes)) or a call to compute_git_sha256_from_bytes; tests/common's own tests pin both shapes as equal. Every removed binary() returned env!("CARGO_BIN_EXE_socket-patch") as a PathBuf or &'static str, and every caller compiles against the PathBuf version.

Test evidence

  • cargo test -p socket-patch-cli --all-features --no-run on all 34 touched targets: no warnings.
  • cargo test -p socket-patch-cli --all-features on the same targets plus spawn_env_hygiene: all pass (apply 119, cli 97 including the ratchet, get 81, remove 99, rollback 57, scan 120, e2e_vex_lockfile 344, vendor_jvm_cli 50, e2e_vendor_pnpm_build 49, e2e_vendor_pypi_build 52, …). The only failures are the 2 root-only repair tests (repair_exits_zero_and_stays_quiet_when_lock_file_unremovable, repair_cleanup_failure_is_reported_in_json_and_silent_modes). They fail the same way on main because the sandbox runs as root, and their files are not changed here.
  • cargo clippy --workspace --all-features -- -D warnings: clean.
  • rustfmt was run only on the touched files whose main copy was already rustfmt-clean (all 41).

Risk

Low. Test-only, mechanical, and the compiler checks every call site. The ignored e2e bodies (docker, toolchain builds) are compiled but not run here; they call the same helpers as before.

🤖 Generated with Claude Code


Note

Low Risk
Test-only mechanical deduplication; shared helpers are already pinned by tests/common and the ratchet test.

Overview
Forty CLI integration/e2e tests now import shared binary() and git_sha256() from tests/common instead of maintaining local copies. Standalone test binaries add #[path = "common/mod.rs"] mod common; nested suites under apply/, cli/, get/, etc. use crate::common. Several e2e suites also pull cache_env / hermetic through common so those modules are not loaded twice.

The shared_helper_copies ratchet drops the 40 migrated paths from PENDING_PRIVATE_HELPERS, leaving only files still pending or blocked by other PRs.

pnpm build e2e keeps the SOCKET_PATCH_PNPM_E2E_SOCKET_BIN override but renames the local helper to socket_bin() so it is not confused with the shared binary().

No production or CLI runtime behavior changes—duplicate helper bodies and unused sha2 imports are removed only.

Reviewed by Cursor Bugbot for commit 189dddb. Configure here.


Generated by Claude Code

Assisted-by: Claude Code:claude-opus-5-5
Forty more CLI test files drop their private copies of binary() and
git_sha256 and import tests/common's instead, so a change to how the
tests find the binary or hash a blob is made in one place. The two
pnpm build suites keep their SOCKET_PATCH_PNPM_E2E_SOCKET_BIN override
as a named socket_bin() helper. No test changes what it asserts.

The shared_helper_copies ratchet drops the migrated files; the 27
files open PRs change and the 4 shared modules stay listed.

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko Mikola Lysenko (mikolalysenko) added refactor Structural change: duplicated code or logic, missing abstraction, layering, dead code arch-refactor PR opened by the scheduled architecture refactor routine labels Oct 9, 2026
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review October 9, 2026 10:13
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

Mikola Lysenko (mikolalysenko) pushed a commit that referenced this pull request Oct 9, 2026
Assisted-by: Claude Code:claude-opus-5-5

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Oct 9, 2026
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

Labeled Ready for review by the burn-down agent.

  • Head: bad5ac25b37969fbb56747cb7ed625d781db3790
  • CI: all 293 check runs on this head completed success/skipped/neutral; no merge conflict with main.
  • Bugbot: reviewed this head, no findings; no unresolved review threads.
  • CHANGELOG.md untouched.

Generated by Claude Code

@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

Final review brief (bad5ac25b)

What it does: 40 socket-patch-cli test files drop their private binary() and git_sha256 copies and use the shared ones from tests/common (more of #824). The shared_helper_copies ratchet loses the matching 40 entries. The two pnpm build suites keep their SOCKET_PATCH_PNPM_E2E_SOCKET_BIN override, now as socket_bin().

Risk: low. Test-only and mechanical: 41 files, +142/−401, no production code. Every removed copy matched the shared helper. git_sha256 was always SHA256("blob <len>\0" + content) or compute_git_sha256_from_bytes, and binary() was always CARGO_BIN_EXE_socket-patch. The compiler checks every call site, and no assertion was removed.

Look here:

Verified: Compared every removed helper line by line with the shared one. cargo test -p socket-patch-cli --all-features --no-run builds all 29 touched targets with no warnings. Ran 10 of them, all passing: cli (incl. the ratchet), rollback, scan, e2e_vex_lockfile, e2e_vendor_pnpm_build, vendor_jvm_cli, cli_scan_silent, covgap_commands_scan_mod, mode_migration_cargo, e2e_gem. CHANGELOG.md untouched. CI 293/293 success/skipped (ci-ok, clippy green), Bugbot success, no review threads, mergeable.

Changes I made: none.

Open questions / non-blocking note: 9 standalone files now pull in common/mod.rs (which already has pub mod cache_env/hermetic) and also keep their own #[path = "common/cache_env.rs"]/hermetic.rs mods: e2e_gem, e2e_npm, e2e_pypi, e2e_redirect_{gem,gradle}build, e2e_scan, e2e_vendor{composer,pnpm,pypi}_build. That adds clippy::duplicate_mod hits, and 6 targets that were clean now fail under local cargo clippy --all-targets. CI's clippy runs without --all-targets (ci.yml:81), and main already has 312 such errors, so nothing gates on this. A later #824 pass can switch those files to use common::{cache_env, hermetic};. e2e_gem.rs also keeps a private git_sha256_file, which is outside this PR's scope.

Auto-merge is armed, so approving sends it straight to the merge queue.


Generated by Claude Code

Nine standalone e2e suites now include common/mod.rs, which already
declares cache_env and hermetic, yet still loaded those two files a
second time through their own #[path] mods (clippy::duplicate_mod under
--all-targets). They take common's modules instead.

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] Addressed the final-review note in 189dddb: the 9 standalone suites (e2e_gem, e2e_npm, e2e_pypi, e2e_redirect_{gem,gradle}build, e2e_scan, e2e_vendor{composer,pnpm,pypi}_build) now take use common::{cache_env, hermetic} instead of re-loading those files through their own #[path] mods, so the cache_env.rs/hermetic.rs duplicate_mod hits are gone. All 9 targets pass (cargo test -p socket-patch-cli --all-features).

One duplicate_mod hit of the same kind remains under --all-targets: common/jvm_env.rs is loaded by both common/mod.rs and the shared prebuilt_common/mod.rs in the four suites that include both modules. e2e_vex_lockfile/main.rs on main already has this pattern. Fixing it means changing prebuilt_common, whose includers don't all declare mod common, so it stays for a later #824 pass. e2e_gem.rs's private git_sha256_file is also left for that pass.


Generated by Claude Code

@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 189dddb. Configure here.

@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[final reviewer] Disarmed auto-merge: the head moved from bad5ac25b (my brief) to 189dddb, a non-merge commit that addresses the brief note (shared cache_env/hermetic helpers in 9 standalone suites). ci-ok hasn't finished on the new head yet. I'll re-review the delta and re-arm once CI is green and the brief is updated.


Generated by Claude Code

@mikolalysenko
Mikola Lysenko (mikolalysenko) added this pull request to the merge queue Oct 9, 2026
Merged via the queue into main with commit 88d5c59 Oct 9, 2026
253 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the arch-refactor/824-shared-test-helpers-2 branch October 9, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-refactor PR opened by the scheduled architecture refactor routine Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review refactor Structural change: duplicated code or logic, missing abstraction, layering, dead code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants