Skip to content

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

Open
Mikola Lysenko (mikolalysenko) wants to merge 1 commit into
mainfrom
agent/fix-gem-refresh-windows-quoted-remedy-test
Open

Mikola Lysenko (mikolalysenko) wants to merge 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
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

2 participants