test: add `escapePOSIXShell` util
In https://github.com/nodejs/node/pull/55028, I've tried to come up with an execNode util, but I couldn't find an implementation that would work for all tests, so I ended up having similar-but-different implementations scattered among several tests. After a bit of soul searching, I realized we could take advantage of string templating and have a util that would escape paths or more when we want to pass them to shell.
Of course, that only works for POSIX shells, where the way we use variables in standardized, however since " is not a valid char in Windows-paths, and paths are (almost?) always the only arbitrary value we pass to shells in tests, it should do just fine.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 88.24%. Comparing base (
0f7bdcc) to head (e0a22b5). Report is 374 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #55125 +/- ##
==========================================
- Coverage 88.25% 88.24% -0.02%
==========================================
Files 651 651
Lines 183856 183863 +7
Branches 35854 35827 -27
==========================================
- Hits 162260 162247 -13
- Misses 14883 14929 +46
+ Partials 6713 6687 -26
CI: https://ci.nodejs.org/job/node-test-pull-request/62810/
CI: https://ci.nodejs.org/job/node-test-pull-request/62817/
CI: https://ci.nodejs.org/job/node-test-pull-request/62823/
CI: https://ci.nodejs.org/job/node-test-pull-request/62836/
CI: https://ci.nodejs.org/job/node-test-pull-request/62837/
CI: https://ci.nodejs.org/job/node-test-pull-request/62838/
CI: https://ci.nodejs.org/job/node-test-pull-request/62841/
CI: https://ci.nodejs.org/job/node-test-pull-request/62844/
- Are there plans to change paths on CI machines to something weird, so this issue can be caught immediately?
Yes
3. Are there any caveats that should be documented? For example, potentially polluting env with the
ESCAPED_#s?
🤷♂️ I guess we'll find out if that's causing problems, it's hard to foresee.
CI: https://ci.nodejs.org/job/node-test-pull-request/62847/
Landed in 99e0d0d2186065aa8ca9ab7cd94e1637bb166220