-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
test: add escapePOSIXShell
util
#55125
Conversation
04b9b19
to
b931733
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
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 |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌 yay for code quality improvements!
Co-authored-by: Jacob Smith <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks neat. I have a few (non-blocking) concerns:
- Are there plans to change paths on CI machines to something weird, so this issue can be caught immediately? Otherwise we might end up in a situation where new tests will potentially break this again.
- This utility should probably be documented in the Common module API part. Otherwise searching for good usage example through
/test/parallel/
would be a pain: some are usingopts
implicitly, some explicitly, existence ofopts
depends on platform. Also, tagged templates aren't very common, so it would be nice to show an usage example. - Are there any caveats that should be documented? For example, potentially polluting env with the
ESCAPED_#
s?
Co-authored-by: Livia Medeiros <[email protected]>
Yes
🤷♂️ I guess we'll find out if that's causing problems, it's hard to foresee. |
Landed in 99e0d0d |
PR-URL: #55125 Reviewed-By: Jacob Smith <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
PR-URL: #55125 Reviewed-By: Jacob Smith <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
PR-URL: nodejs#55125 Reviewed-By: Jacob Smith <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
In #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.