Skip to content

Fix gem remedy unit test for quoted Windows paths (#2399) - #2405

Merged
Mikola Lysenko (mikolalysenko) merged 1 commit into
mainfrom
agent/fix-gem-refresh-windows-quoted-remedy-test
Dec 1, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 1 commit into
mainfrom
agent/fix-gem-refresh-windows-quoted-remedy-test

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-fable-5-2

Fixes #2399

Summary

Test-only change, 8 lines in one unit test. The nightly test (windows-latest, 1) leg has failed on main four nights in a row on commands::gem_refresh::tests::a_copy_beside_another_rubys_tree_is_removed_with_its_gem_dir. No product code changes and no assertion is loosened.

Root cause

The remedy quotes every path of its rm -f … && bundle install command as one shell word (shell_word). The test built the expected command from the unquoted Path::display(). On Linux a temp path needs no quotes, so the two agree. A Windows temp path (C:\Users\RUNNER~1\…) holds \ and ~, so the remedy quotes it and the test's unquoted text is not found. An earlier fix covered the other gem remedy tests in this file. This test was added after it.

A second mismatch sat behind the first: the test joined the gemspec path as home.join("specifications/json-1.0.0.gemspec"). Windows keeps the / inside a joined part, while the remedy joins specifications and the file name separately and gets \.

Change

  • Build the expected rm -rf and rm -f commands with shell_word, as the neighboring tests do.
  • Join the gemspec path part by part.

The warning's detail (remove <dir>, <spec> and run …) lists paths unquoted, and the test still expects them unquoted.

Evidence

No Windows machine was available, so the quoting failure was reproduced on Linux by running the test under a temp directory whose path needs quoting:

$ mkdir -p "/x/tmp dir~1"
$ TMPDIR="/x/tmp dir~1" cargo test -p socket-patch-cli --lib gem_refresh::tests

before: a_copy_beside_another_rubys_tree_is_removed_with_its_gem_dir ... FAILED
        panicked at crates/socket-patch-cli/src/commands/gem_refresh.rs:2643:13   (the line the nightly reports)
        test result: FAILED. 13 passed; 1 failed
after:  test result: ok. 14 passed; 0 failed

With the default temp directory all 14 tests pass before and after.

Not verified here: the Windows separator mismatch (the second cause) cannot be reproduced on Linux. It is read from the nightly's output, which prints …3.2.0\specifications\json-1.0.0.gemspec. The Windows test leg runs only nightly, so the first proof is the next nightly run on main after this merges.

Local checks: rustfmt --check on the file; cargo clippy --locked -p socket-patch-cli --all-features -- -D warnings (the form CI runs) is clean. With --all-targets clippy reports findings in integration-test helpers this PR does not touch (tests/prebuilt_common/mod.rs, tests/common/mod.rs and others); they are the same on main and none is in gem_refresh.rs.

Review

/code-review high on the diff: no finding in the changed lines. One pre-existing note in production code the test exercises, not fixed here: the remedy is a POSIX shell command (rm -f '…' && bundle install) on every platform, so on Windows it runs in Git Bash but not in cmd.exe or Windows PowerShell. Changing that changes CLI output, which is a maintainer's call and outside a test fix.

https://claude.ai/code/session_011f9aePyMvbD6rKimV9v2pL


Generated by Claude Code

The test of a copy beside another Ruby's tree built the expected
rm command from Path::display(), but the remedy quotes each path
as one shell word. A Windows temp path holds a backslash and a
tilde, so the nightly Windows leg failed on every run. The test
also joined the gemspec path with a slash inside one part, which
Windows keeps as a slash while the remedy joins part by part.

Build the expected commands with shell_word and join the gemspec
path part by part. The assertions are unchanged.

Fixes #2399

Assisted-by: Claude Code:claude-fable-5-2
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011f9aePyMvbD6rKimV9v2pL
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review December 1, 2026 09:42
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

bugbot run


Generated by Claude Code

@cursor

cursor Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Single unit-test expectation update only; no runtime or CLI behavior changed.

Overview
Test-only fix for a_copy_beside_another_rubys_tree_is_removed_with_its_gem_dir, which was failing on windows-latest because expected remedy strings did not match production output.

The test now builds the gemspec path with separate join("specifications").join(...) segments (matching how remedies construct paths) and uses shell_word for expected rm -rf / rm -f command fragments instead of unquoted Path::display(), consistent with sibling gem-remedy tests. Warning detail assertions still use unquoted displayed paths.

No product code or assertion semantics change.

Reviewed by Cursor Bugbot for commit 0368b54. Configure here.

@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 0368b54. Configure here.

@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: review brief for the approver

What it does
Fixes the unit test behind the nightly test (windows-latest, 1) failure on main (#2399). The test now builds its expected rm commands with the same shell_word quoting the remedy uses, and joins the gemspec path part by part as the remedy does. Test-only; no product code changes, no assertion loosened.

Risk
Low. One unit test in one file; production code untouched.

Look here

  • [gem_refresh.rs#L2610-L2620](https://github.com/SocketDev/socket-patch/blob/0368b54c22086d516fa98ce69608ebad2d497969/crates/socket-patch-cli/src/commands/gem_refresh.rs#L2610-L2620): expected paths now joined and quoted like the remedy
  • [gem_refresh.rs#L569-L578](https://github.com/SocketDev/socket-patch/blob/0368b54c22086d516fa98ce69608ebad2d497969/crates/socket-patch-cli/src/commands/gem_refresh.rs#L569-L578): shell_word, the quoting the test now mirrors
  • gem_refresh.rs#L362: the remedy joins specifications and the file name separately
  • [gem_refresh.rs#L2668-L2673](https://github.com/SocketDev/socket-patch/blob/0368b54c22086d516fa98ce69608ebad2d497969/crates/socket-patch-cli/src/commands/gem_refresh.rs#L2668-L2673): the warning detail still expects unquoted paths, which matches the product

Verified

  • Read the whole diff against the issue's nightly output; the description matches the code.
  • TMPDIR="<dir with a space and ~>" cargo test -p socket-patch-cli --lib gem_refresh::tests: 14 passed (this path forces quoting, as a Windows temp path does).
  • CI on 0368b54c22086d516fa98ce69608ebad2d497969: ci-ok and clippy green; Bugbot found no issues; no open threads; CHANGELOG.md untouched.
  • Not verifiable here: the Windows separator part. The first proof is the next nightly on main after this merges.

Changes I made
None.

Open questions
None.


Generated by Claude Code

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Dec 1, 2026
@mikolalysenko
Mikola Lysenko (mikolalysenko) added this pull request to the merge queue Dec 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[agent] Reviewed; LGTM.

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 1, 2026
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] The merge queue evicted this PR on a failure that is not from this diff.

Queue CI run 46744428179 failed one job, coverage (1), on a_refused_connection_is_not_retried in crates/socket-patch-core/tests/api_retry_e2e.rs: the port the test expects to be closed answered 404, because a parallel test's stand-in server took the port the test had just freed. This PR changes one unit test in the CLI crate and nothing that test reaches. All 127 checks passed on the PR head 0368b54, which is unchanged. Filed as #2424.

Nothing to fix here. The PR needs to be put back in the queue; auto-merge is no longer armed and I don't arm it myself.


Generated by Claude Code

@mikolalysenko
Mikola Lysenko (mikolalysenko) added this pull request to the merge queue Dec 1, 2026
Merged via the queue into main with commit 6246d9b Dec 1, 2026
127 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the agent/fix-gem-refresh-windows-quoted-remedy-test branch December 1, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: nightly test (windows-latest, 1) fails on main: gem_refresh test expects unquoted Windows paths in the rm -f remedy

4 participants