Skip to content

test(cli): use tests/common's helpers instead of local copies (T55) - #2241

Open
Mikola Lysenko (mikolalysenko) wants to merge 5 commits into
mainfrom
arch-refactor/1959-test-common-helpers
Open

Mikola Lysenko (mikolalysenko) wants to merge 5 commits into
mainfrom
arch-refactor/1959-test-common-helpers

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

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

Refs #1959 (T55, first slice). Living document: Part 5, tests.

Why

Suites that already include tests/common kept their own copies of its helpers. This deletes the copies that are byte-for-byte or behaviourally identical to common's and calls common::* instead. It also drops the stderr_chatter filter, which hid stray lines from the silent-mode emptiness checks.

Changes

  • has_command: deleted 6 copies identical to common::has_command (e2e_npm, e2e_gem, e2e_scan, e2e_yarn4_pnpm_linker_build, e2e_yarn4_workspaces_build, e2e_redirect_yarn_berry_build). These kept: the pm_command/go version variants in e2e_hosted_production, e2e_vendored_production and e2e_artifactory_mirror, and the tool_command + .success() variants in e2e_vendor_rush and e2e_redirect_rush_sim, because they behave differently.
  • git_sha256_file: deleted 4 copies (e2e_npm, e2e_gem, e2e_scan, e2e_pypi).
  • sha256_hex: deleted 9 copies (mode_migration_cargo, e2e_redirect_cargo_build, e2e_vex_vendor, repair/repair_vendor_e2e, e2e_vex_lockfile/{maven,uv,poetry,nuget}, vlt_e2e_common, which now re-exports common::sha256_hex). hex::encode and format!("{:x}") produce the same lowercase hex.
  • Double includes: the three yarn suites and e2e_redirect_rush_sim no longer #[path]-include common/cache_env.rs (and, for rush, common/hermetic.rs) a second time beside mod common.
  • Dead code: deleted common::{env_map, npm_run} (0 callers) and update_fixture::{raw_asset, delay_asset} plus the asset_delay field.
  • Tests fixed: deleted 4 stderr_chatter copies (cli_apply_silent, cli_scan_silent, apply/apply_silent_staging_errors, vendor/vendor_silent_errors). The filter dropped any line containing SOCKET_API_TOKEN or Continuing anyway:
    • 5 emptiness checks now assert stderr.is_empty(): scan_silent_no_packages_produces_no_output, scan_silent_apply_flow_produces_no_output_but_still_applies, scan_vendor_silent_gc_prints_nothing, apply_json_offline_missing_source_keeps_stderr_clean and vendor_json_online_fetch_failure_keeps_stderr_clean.
    • The presence checks read stderr directly.
    • Red→green: with a temporary eprintln!("No SOCKET_API_TOKEN set (injected)") at the top of main, all 5 emptiness tests fail. Before this PR the filter hid that line and they passed. They pass again once it is removed.
  • Comments: removed the stale "assertions ignore the token warning" paragraph in cli_scan_silent. The one in cli_apply_silent now gives the real reason: the notice is an info notice, muted under --silent/--json.

Size

git diff --stat: 23 files, +46 / −298, all under crates/socket-patch-cli/tests/. Production: 0.

Behavior change

None in the product. The 5 silent-mode tests are stricter, as described above.

Verification

  • cargo test -p socket-patch-cli --tests --no-run: every test target builds with no new warnings. Two pre-existing unused-import warnings remain, in in_process_vendor_bun_takeover/registry.rs and vendor/e2e_golang_redirect.rs.
  • Green: apply, cli, cli_apply_silent, cli_scan_silent, common_selftests, e2e_vex_lockfile, e2e_vex_vendor, mode_migration_cargo, vendor, update, self_update_e2e, self_update_failures_e2e and e2e_redirect_rush_sim. The toolchain e2e suites (e2e_npm, e2e_gem, e2e_scan, e2e_pypi, the yarn suites) compile but are #[ignore]d or toolchain-gated here.
  • repair: 116 pass. 2 fail only because the sandbox runs as root (repair_cleanup_failure_is_reported_in_json_and_silent_modes, repair_exits_zero_and_stays_quiet_when_lock_file_unremovable); they are chmod tests that pass in CI.
  • cargo clippy --workspace --all-features -- -D warnings: clean.

/code-review high findings not fixed here

Risk

Low: test-only and mechanical. No cfg(windows)/cfg(unix) code changed.

🤖 Generated with Claude Code

https://claude.ai/code/session_011f9aePrALfrCutpZn63ds9

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 Nov 25, 2026
The stderr_chatter filter (4 byte-identical copies) dropped API-token
warning lines that these offline and cached runs never print, so the
emptiness checks now assert on the whole stderr and the presence
checks read it directly.

Assisted-by: Claude Code:claude-opus-5-5
Delete local copies identical to tests/common's: has_command in six
suites, git_sha256_file in four, sha256_hex in nine, and the yarn
suites' second include of common/cache_env.rs. Delete the unused
common::{env_map, npm_run} and update_fixture's raw_asset and
delay_asset.

Assisted-by: Claude Code:claude-opus-5-5
Assisted-by: Claude Code:claude-opus-5-5
Drop the second #[path] include of common/cache_env.rs and
common/hermetic.rs beside mod common, and state why the silent
suites' stderr never holds the proxy notice: it is an info notice,
muted under --silent and --json.

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review November 25, 2026 15:28
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

@cursor

cursor Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Test-only mechanical refactor with stricter assertions; no production code changes.

Overview
Consolidates CLI integration tests onto shared helpers in tests/common and removes local duplicates of has_command, git_sha256_file, and sha256_hex across many e2e and VEX suites. Yarn/rush tests now import cache_env / hermetic through mod common instead of double #[path]-including the same modules.

Removes unused test utilities (common::npm_run, env_map, and update_fixture::{raw_asset, delay_asset, asset_delay}).

Behavioral change in tests only: deletes the stderr_chatter helper that stripped SOCKET_API_TOKEN / "Continuing anyway" lines from assertions. Silent/--json success-path checks now require stderr.is_empty() outright; error-path checks substring-match stderr directly—so stray info notices can no longer pass vacuously. Module comments in cli_apply_silent / cli_scan_silent were updated to document that the token notice is muted under --silent/--json.

Reviewed by Cursor Bugbot for commit 0d967b7. Configure here.

Mikola Lysenko (mikolalysenko) pushed a commit that referenced this pull request Nov 25, 2026
Assisted-by: Claude Code:claude-opus-5-5
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 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.

2 participants