-
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 mustCall() to child-process test #13605
Conversation
Add common.mustCall() check to test-child-process-stdio-big-write-end.
@@ -43,10 +43,10 @@ function parent() { | |||
child.stdout.on('data', function(c) { |
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.
How about adding a mustCallAtLeast
?
(I see that the value of n
is asserted, but this will give a one-step-closer-to-root-cause assertion error)
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 I understand correctly, the assertion on n
will occur before any assertion by mustCallAtLeast()
.
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.
Ack.
@@ -43,10 +43,10 @@ function parent() { | |||
child.stdout.on('data', function(c) { |
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.
Ack.
@@ -43,10 +43,10 @@ function parent() { | |||
child.stdout.on('data', function(c) { | |||
n += c; | |||
}); | |||
child.stdout.on('end', function() { | |||
child.stdout.on('end', common.mustCall(function() { | |||
assert.strictEqual(+n, sent); | |||
console.log('ok'); |
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.
Should remove (maybe replace with comment // end of test
)
@@ -43,10 +43,10 @@ function parent() { | |||
child.stdout.on('data', function(c) { | |||
n += c; | |||
}); | |||
child.stdout.on('end', function() { | |||
child.stdout.on('end', common.mustCall(function() { | |||
assert.strictEqual(+n, sent); |
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 +
is cheating the strict
either put on the right side send + '\n'
('\n'
is because data comes from console.log
)
or replace the 'data' handler with:
let n = 0;
child.stdout.setEncoding('ascii');
child.stdout.on('data', function(d) {
const c = Number(d);
if (!c) assert.fail(c);
n += c;
});
Add common.mustCall() check to test-child-process-stdio-big-write-end. PR-URL: #13605 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Landed in f308b4d |
Add common.mustCall() check to test-child-process-stdio-big-write-end. PR-URL: #13605 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Add common.mustCall() check to test-child-process-stdio-big-write-end. PR-URL: #13605 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Add common.mustCall() check to test-child-process-stdio-big-write-end. PR-URL: #13605 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Add common.mustCall() check to test-child-process-stdio-big-write-end. PR-URL: #13605 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Add common.mustCall() check to test-child-process-stdio-big-write-end.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test child_process