Repository navigation
Fix gem remedy unit tests for paths that need quoting (#2276) - #2278
Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
Conversation
Refs #2276. Assisted-by: Claude Code:claude-fable-5-2
Two gem_refresh unit tests built the expected `rm -rf ... && bundle install` command from Path::display(), but the code renders each path of that command through shell_word, which single-quotes a path holding a character outside its safe set. A Windows temp path holds a backslash, so both tests failed on the Windows nightly. A temp dir with a space in its path fails them the same way on Linux. Build the expected commands with shell_word. The warning detail lists the paths unquoted, so its assertions stay as they are. Fixes #2276. Assisted-by: Claude Code:claude-fable-5-2
a_copy_no_ruby_owns_is_removed_with_its_gem_dir joined `specifications/json-1.0.0.gemspec` onto the gem home as one component. The code joins the directory and the file name apart, so on Windows the test's path kept a `/` where the remedy has a `\\`, and the expected command and detail would still not match there. the_rm_remedy_quotes_a_path_the_shell_would_split wrapped display() in literal quotes, which breaks under a temp dir with a `'` in its path. It now uses shell_word too. Refs #2276. Assisted-by: Claude Code:claude-fable-5-2
|
bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview In
Reviewed by Cursor Bugbot for commit ebf0df9. Configure here. |
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 ebf0df9. Configure here.
|
[agent] Generated by Claude Code |
|
[agent] PR shepherd: review brief What it does Risk Look here
Verified
Changes I made Open questions
Generated by Claude Code |
LLM Description written by Claude Code:claude-fable-5-2
Fixes #2276
Summary
Test-only change in
crates/socket-patch-cli/src/commands/gem_refresh.rs. Two unit tests of the stale-gem remedy failed on the Windows nightly because they expected paths the code does not print. No behavior of the CLI changes.Root cause
The remedy bullet prints
rm -rf <paths> && bundle installand renders each path throughshell_word, which single-quotes a path holding a character outside[A-Za-z0-9_@%+=:,./-]. The tests built the expected command fromPath::display(). A Windows temp path holds\, so the bullet has quoted paths and the tests looked for unquoted ones. On Linux a temp path is safe unquoted, and a PR runs no Windows tests, so this only showed on the nightly.The review of the first fix found a second mismatch in
a_copy_no_ruby_owns_is_removed_with_its_gem_dir: it joinedspecifications/json-1.0.0.gemspeconto the gem home as one component, while the code joins the directory and the file name apart. On Windows the test's path keeps a/where the remedy has a\.What changed
a_copy_no_ruby_owns_is_removed_with_its_gem_diranda_gem_dir_without_its_gemspec_is_the_thing_to_removebuild the expected command withshell_word. The warning detail lists paths unquoted (display_list), so those assertions stay.the_rm_remedy_quotes_a_path_the_shell_would_splitwrappeddisplay()in literal quotes, which breaks under a temp dir with a'in its path. It usesshell_wordtoo.Evidence
main(cfc870f) on Linux, with a temp dir that needs quoting:TMPDIR='/…/tmp dir' cargo test -p socket-patch-cli --lib gem_refresh::fails the same two tests at the same lines as the nightly (gem_refresh.rs:2413and:2473), 11 passed, 2 failed.tmp dirand withit's a dir.cargo test -p socket-patch-cli --lib: 1076 passed.cargo clippy --locked --workspace --all-features -- -D warnings(CI's command): clean. With--all-targetsthe local toolchain reports lints in integration-test files this PR does not touch; none are ingem_refresh.rs.workflow_dispatch,os=windows) on ebf0df9 is green,test (windows-latest, 1)included. Its log shows all three changed testsok; the two from CI: two gem_refresh unit tests from #2251 fail on the Windows nightly (expected path not shell-quoted) #2276 failed in that job on the nightly.clippyand every other check pass excepthosted-e2e, and soci-ok. That failure is CI: hosted-e2e gem leg fails on every PR: production published activestorage 6.0.3 patch 146ef6aa, not in GEM_UUIDS #2270 (gem_bundler_hosted_install_proof, production patch146ef6aa-…not inGEM_UUIDS), which is red onmaintoo. Bugbot found no issues.Follow-ups
a_copy_beside_another_rubys_tree_is_removed_with_its_gem_dirwith the samedisplay()expectation. It fails under the spaced temp dir too and will need the same change, in whichever of the two PRs merges second.rm -rf '…' && bundle install) thatcmd.exeand Windows PowerShell do not accept. Whether Windows users should get a different command is a product question.https://claude.ai/code/session_011f9aePn2Jt8HwcDumwxsHx
Generated by Claude Code