Skip to content

fix: Don't escape regex characters in test commands on Windows#4007

Open
BillionClaw wants to merge 1 commit intoShopify:mainfrom
BillionClaw:clawoss/fix/windows-regex-escape
Open

fix: Don't escape regex characters in test commands on Windows#4007
BillionClaw wants to merge 1 commit intoShopify:mainfrom
BillionClaw:clawoss/fix/windows-regex-escape

Conversation

@BillionClaw
Copy link

Fixes #3759

Shellwords.escape() is designed for Unix shells and incorrectly escapes characters like $ on Windows. This causes the "Run Test In Terminal" CodeLens feature to fail on Windows because the regex pattern becomes incorrectly escaped.

Changes:

  • Added escape_for_shell() helper that uses Gem.win_platform? to detect Windows
  • On Windows: returns text unescaped (Windows cmd parsing doesn't need same escaping)
  • On Unix: continues using Shellwords.escape()

Shellwords.escape() is designed for Unix shells and incorrectly escapes
characters like `$` on Windows. This causes test commands to fail when
running tests in terminal on Windows because the regex pattern
`/\^TestClass#test_method\$/` becomes `/\^TestClass#test_method\\$/`.

On Windows, we skip Shellwords.escape() since Windows command line
parsing doesn't require the same escaping rules for regex patterns.

Fixes Shopify#3759
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CodeLens Run Test In Terminal doesn't work (on Windows) due to incorrectly escaped Regex

1 participant