node icon indicating copy to clipboard operation
node copied to clipboard

test: add `escapePOSIXShell` util

Open aduh95 opened this issue 1 year ago • 8 comments

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.

aduh95 avatar Sep 25 '24 21:09 aduh95

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     

see 83 files with indirect coverage changes

codecov[bot] avatar Sep 25 '24 23:09 codecov[bot]

CI: https://ci.nodejs.org/job/node-test-pull-request/62810/

nodejs-github-bot avatar Sep 27 '24 23:09 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/62817/

nodejs-github-bot avatar Sep 28 '24 09:09 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/62823/

nodejs-github-bot avatar Sep 28 '24 13:09 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/62836/

nodejs-github-bot avatar Sep 28 '24 23:09 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/62837/

nodejs-github-bot avatar Sep 29 '24 07:09 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/62838/

nodejs-github-bot avatar Sep 29 '24 08:09 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/62841/

nodejs-github-bot avatar Sep 29 '24 09:09 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/62844/

nodejs-github-bot avatar Sep 29 '24 15:09 nodejs-github-bot

  1. 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.

aduh95 avatar Sep 29 '24 17:09 aduh95

CI: https://ci.nodejs.org/job/node-test-pull-request/62847/

nodejs-github-bot avatar Sep 29 '24 17:09 nodejs-github-bot

Landed in 99e0d0d2186065aa8ca9ab7cd94e1637bb166220

nodejs-github-bot avatar Sep 29 '24 20:09 nodejs-github-bot