-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve #5216 #5269
Resolve #5216 #5269
Conversation
PR #5054 added a call to `replacePathSepForRegex` to escape values of the `--testPathPattern` and `<regexForTestFiles>` CLI options. Since the Windows path separator and the regular expression special character delimeter are the same character, this can lead to ambiguous patterns (e.g.: `app\book\d*\`). This commit: - Removes escaping CLI args with `replacePathSepForRegex` to leave them as is unless it's a POSIX path separator on Windows - Changes the tests in `normalize.test.js` to run the same test suite for `--testPathPattern` and `<regexForTestFiles>` - Reverts the changes to `replacePathSepForRegex` from #5230 but keeps the tests for the intended behavior. It will be complicated to escape the "safe" cases when `\` is a path separator and not a regular expression delimeter. Instead of getting fancy, we can urge Windows users to use `/` or `\\` as a path separator.
The previous test case results don't change: This does re-introduce the regression in the escaping of the Watch Usage path pattern. If you enter |
Codecov Report
@@ Coverage Diff @@
## master #5269 +/- ##
==========================================
- Coverage 61.14% 60.98% -0.16%
==========================================
Files 203 203
Lines 6843 6816 -27
Branches 4 4
==========================================
- Hits 4184 4157 -27
Misses 2658 2658
Partials 1 1
Continue to review full report at Codecov.
|
Thanks for following up on this @seanpoulter. Ugh, path separators and regex. |
@seanpoulter mind sending a quick PR for the changelog? It's been released in 22.0.6 |
Would you like a note in the docs to say |
Yeah, I think that's a good idea. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
PR #5054 added a call to
replacePathSepForRegex
to escape values of the--testPathPattern
and<regexForTestFiles>
CLI options. Since the Windows path separator and the regular expression special character delimeter are the same character, this can lead to ambiguous patterns (e.g.:app\book\d*\
).This commit:
Removes escaping CLI args with
replacePathSepForRegex
to leave them as is unless it's a POSIX path separator on WindowsChanges the tests in
normalize.test.js
to run the same test suite for--testPathPattern
and<regexForTestFiles>
Reverts the changes to
replacePathSepForRegex
from Fix --testPathPattern escaping for '\\' on Windows #5230 but keeps the tests for the intended behavior. It will be complicated to escape the "safe" cases when\
is a path separator and not a regular expression delimeter. Instead of getting fancy, we can urge Windows users to use/
or\\
as a path separator.Test plan
Tests have been updated.