test: fix hijackStdout behavior in console#14647
test: fix hijackStdout behavior in console#14647XadillaX wants to merge 3 commits intonodejs:masterfrom
Conversation
d3d6dba to
c45e347
Compare
`console.log` and some other function will swallow the exception in `stdout.write`. So an asynchronous exception is needed, or `common.hijackStdout` won't detect some exception. Refs: https://github.com/nodejs/node/blob/v8.2.1/lib/console.js#L87
|
/cc @nodejs/testing |
test/common/index.js
Outdated
| try { | ||
| listener(data); | ||
| } catch(e) { | ||
| process.nextTick(function() { |
There was a problem hiding this comment.
Nit: I know you like functions but this could be a single line.
IMHO the indentation is weird
| }); | ||
|
|
||
| let uncaughtTimes = 0; | ||
| process.on('uncaughtException', common.mustCallAtLeast(function(e) { |
There was a problem hiding this comment.
CR: How is the mustCallAtLeast fit with the ${([ 'err', 'out' ])[uncaughtTimes++]} trick?
There was a problem hiding this comment.
The second parameter of common.mustCallAtLeast is 2.
There was a problem hiding this comment.
Sorry I wasn't clear. I meant it should be mustCall, as any more calls would generate console undefined error
test/parallel/test-common.js
Outdated
|
|
||
| // hijackStderr and hijackStdout again | ||
| // for console | ||
| [ 'err', 'out' ].forEach((txt) => { |
There was a problem hiding this comment.
Optional: do [['err', 'error'], ['out', 'log']].forEach(([ext, method]) => {
instead of console[txt === 'err' ? 'error' : 'log']('test');
|
@refack updated. |
refack
left a comment
There was a problem hiding this comment.
LGTM. Just need to replace mustCallAtLeast with mustCall
| }); | ||
|
|
||
| let uncaughtTimes = 0; | ||
| process.on('uncaughtException', common.mustCallAtLeast(function(e) { |
There was a problem hiding this comment.
Sorry I wasn't clear. I meant it should be mustCall, as any more calls would generate console undefined error
|
@refack How about now? I've added the code: assert.strictEqual(uncaughtTimes < 2, true); |
That works too. |
|
Trying again on windows https://ci.nodejs.org/job/node-test-commit-windows-fanned/11379/ |
`console.log` and some other function will swallow the exception in `stdout.write`. So an asynchronous exception is needed, or `common.hijackStdout` won't detect some exception. Refs: https://github.com/nodejs/node/blob/v8.2.1/lib/console.js#L87 PR-URL: #14647 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
|
Landed in 1ffd01c |
`console.log` and some other function will swallow the exception in `stdout.write`. So an asynchronous exception is needed, or `common.hijackStdout` won't detect some exception. Refs: https://github.com/nodejs/node/blob/v8.2.1/lib/console.js#L87 PR-URL: nodejs/node#14647 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
`console.log` and some other function will swallow the exception in `stdout.write`. So an asynchronous exception is needed, or `common.hijackStdout` won't detect some exception. Refs: https://github.com/nodejs/node/blob/v8.2.1/lib/console.js#L87 PR-URL: nodejs/node#14647 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
`console.log` and some other function will swallow the exception in `stdout.write`. So an asynchronous exception is needed, or `common.hijackStdout` won't detect some exception. Refs: https://github.com/nodejs/node/blob/v8.2.1/lib/console.js#L87 PR-URL: nodejs#14647 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
`console.log` and some other function will swallow the exception in `stdout.write`. So an asynchronous exception is needed, or `common.hijackStdout` won't detect some exception. Refs: https://github.com/nodejs/node/blob/v8.2.1/lib/console.js#L87 PR-URL: #14647 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
`console.log` and some other function will swallow the exception in `stdout.write`. So an asynchronous exception is needed, or `common.hijackStdout` won't detect some exception. Refs: https://github.com/nodejs/node/blob/v8.2.1/lib/console.js#L87 PR-URL: #14647 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
|
it looks like this is a patch to test features that don't exist on v6.x Should we backport them? |
|
ping |
|
ping @XadillaX |
console.logand some other function will swallow the exception instdout.write. So an asynchronous exception is needed, orcommon.hijackStdoutwon't detect some exception.Refs: https://github.com/nodejs/node/blob/v8.2.1/lib/console.js#L87
Checklist
make -j4 testAffected core subsystem(s)
test