mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08: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
3257a3601f
commit
4a62a61092
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