Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.3k
test: make a test path-independent#12945
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
vsemozhetbyt commented May 10, 2017 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
vsemozhetbyt commented May 10, 2017
vsemozhetbyt commented May 10, 2017
The test runs only on Windows and Windows is OK in CI. One Linux fail must be irrelevant. |
cjihrig left a comment
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.
If we go this route, the test may need to be renamed since it no longer uses spawn().
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.
Would quoting the args and specifying the shell work with spawn()?
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.
I've tried and failed. It seems the args are re-quoted internally in an inappropriate way for this case. But I may miss some variants. Can anybody else test?
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.
Does windowsVerbatimArguments make a difference?
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.
Is this documented? I can't find.
vsemozhetbytMay 10, 2017 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
I've found out a way with spawn():
constargs=['/c',`""${process.execPath}"`,`"${__filename}"`,'child','<',stdinPipeName,'>',`${stdoutPipeName}"`];constchild=spawn(comspec,args,{shell: true});But it seems strange. And we execute cmd.exe with cmd.exe first, if I get this right. Is this way better?
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.
windowsVerbatimArguments is not documented. See
Lines 424 to 428 in cfe7b34
| if(process.platform==='win32'){ | |
| file=typeofoptions.shell==='string' ? options.shell : | |
| process.env.comspec||'cmd.exe'; | |
| args=['/d','/s','/c','"'+command+'"']; | |
| options.windowsVerbatimArguments=true; |
When you run exec() or spawn() with shell: true, this code path is hit. It's probably what you're looking for.
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.
Another way:
constargs=[`"${__filename}"`,'child','<',stdinPipeName,'>',stdoutPipeName];constchild=spawn(`"${process.execPath}"`,args,{shell: true});Slightly better maybe than the previous one.
vsemozhetbytMay 10, 2017 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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 does not work:
constargs=['/c',`"${process.execPath}"`,`"${__filename}"`,'child','<',stdinPipeName,'>',stdoutPipeName];constchild=spawn(comspec,args,{shell: true,windowsVerbatimArguments: true});Should I prefer one of the beforementioned variants with spawn()?
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.
The variant in #12945 (comment) seems reasonable enough.
parallel/test-spawn-cmd-named-pipe.js failed with spaces both in node.exe and test paths.
vsemozhetbyt commented May 10, 2017
refack left a comment
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.
LGTM if CI is green
refack commented May 10, 2017
@vsemozhetbyt you could update the first comment, since you eventually found a way to use |
cjihrig left a comment
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.
LGTM pending CI
vsemozhetbyt commented May 10, 2017
vsemozhetbyt commented May 10, 2017
Windows CI is green. |
vsemozhetbyt commented May 12, 2017
Landed in 529e4f2 |
parallel/test-spawn-cmd-named-pipe.js failed with spaces both in node.exe and test paths. PR-URL: #12945 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
parallel/test-spawn-cmd-named-pipe.js failed with spaces both in node.exe and test paths. PR-URL: nodejs#12945 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
test, child_process
This is the first step to fix the #12773.
I've decided to start from the most whimsical one (section 4 in the #12773):
parallel/test-spawn-cmd-named-pipe.jsfails if spaces exist both in node.exe and the test paths. If there are no spaces or there are spaces only in one of the paths (either), the test passes.If I get it right, the cause is the very complicated rules for
cmd.execommand line syntax concerning spaces and quotes: see "Quote Characters in a command" here and "Examples:" here.The fixed test passes with all 4 paths variants (spaceless + spaceless, spacy + spaceless, spaceless + spacy, and spacy + spacy).
Please, test in more environments and propose better fixes if you have some)
cc @nodejs/testing, @nodejs/platform-windows, @bnoordhuis, @cjihrig