-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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 child_process.exec() timeout coverage #9208
Conversation
Maybe testing with a different LGTM anyway if CI is green. |
|
||
if (process.argv[2] === 'child') { | ||
setTimeout(() => { | ||
console.log('child stdout'); |
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 you mind adding a comment mentioning that the console.log()
calls are intentionally part of the 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.
LGTM with a nit
const cmd = `${process.execPath} ${__filename} child`; | ||
|
||
// Test the case where a timeout is set, and it expires. | ||
cp.exec(cmd, { timeout: 1 }, (err, stdout, stderr) => { |
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.
Mind adding common.mustCall
?
assert.strictEqual(stderr.trim(), ''); | ||
}); | ||
|
||
// Test the case where a timeout is set, but not eclipsed. |
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.
Nit: Did you mean elapsed
?
Not sure why, but when I ran the test locally without the
Also, this trips the linter,
|
Oh okay. Exponentiation Operator is only in ES7, so you might have to use |
Hmmm, apparently V8 allowed this harmony feature to be turned on by default. Reference: https://bugs.chromium.org/p/v8/issues/detail?id=3915#c18 |
PR to allow the exponentiation operator in the linter: #9218 |
This allows us to use the exponentiation operator. PR-URL: nodejs#9218 Ref: nodejs#9208 (comment) Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This allows us to use the exponentiation operator. PR-URL: #9218 Ref: #9208 (comment) Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
#9218 landed |
This commit adds coverage for the timeout option used by child_process exec() and execFile(). PR-URL: nodejs#9208 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Green CI: https://ci.nodejs.org/job/node-test-pull-request/4666/. Landing. |
Belated LGTM. |
This commit adds coverage for the timeout option used by child_process exec() and execFile(). PR-URL: #9208 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
This allows us to use the exponentiation operator. PR-URL: #9218 Ref: #9208 (comment) Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
@cjihrig this landed cleanly on v6.x with a small modification. v4.x is failing this test though output:
any idea what is up? |
This commit adds coverage for the timeout option used by child_process exec() and execFile(). PR-URL: #9208 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
I believe it's the difference between this on v6: And this on v4: That assertion can probably be dropped. It's not super important. |
This allows us to use the exponentiation operator. PR-URL: #9218 Ref: #9208 (comment) Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This commit adds coverage for the timeout option used by child_process exec() and execFile(). PR-URL: #9208 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
is it worth backporting without that assertation? |
If you deem the test worthy of backporting, then |
This commit adds coverage for the timeout option used by child_process exec() and execFile(). PR-URL: #9208 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Checklist
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
test
Description of change
This commit adds coverage for the
timeout
option used bychild_process
exec()
andexecFile()
.