mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
test: handle null stdio streams in spawnSyncAndAssert helper
When a test uses 'pipe' for the stdio but the child process crashes, the stream will be null. In this case, don't try to stringify it and instead log an empty string. Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com> PR-URL: https://github.com/nodejs/node/pull/64273 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
This commit is contained in:
1 parent
0ea079be7b
commit
af52410d70
1 file changed
+2
-2
@@ -80,9 +80,9 @@ function expectSyncExit(caller, spawnArgs, {
|
||||
function logAndThrow() {
|
||||
const tag = `[process ${child.pid}]:`;
|
||||
console.error(`${tag} --- stderr ---`);
|
||||
console.error(stderrStr === undefined ? child.stderr.toString() : stderrStr);
|
||||
console.error(stderrStr === undefined ? (child.stderr?.toString() ?? '') : stderrStr);
|
||||
console.error(`${tag} --- stdout ---`);
|
||||
console.error(stdoutStr === undefined ? child.stdout.toString() : stdoutStr);
|
||||
console.error(stdoutStr === undefined ? (child.stdout?.toString() ?? '') : stdoutStr);
|
||||
console.error(`${tag} status = ${child.status}, signal = ${child.signal}`);
|
||||
|
||||
const error = new Error(`${failures.join('\n')}`);
|
||||
|
||||
Reference in new issue
Block a user