Skip to content

Commit f09cbdf

Browse files
committed
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.
1 parent d7a658a commit f09cbdf

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

test/common/child_process.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ function expectSyncExit(caller, spawnArgs, {
8080
function logAndThrow() {
8181
const tag = `[process ${child.pid}]:`;
8282
console.error(`${tag} --- stderr ---`);
83-
console.error(stderrStr === undefined ? child.stderr.toString() : stderrStr);
83+
console.error(stderrStr === undefined ? (child.stderr?.toString() ?? '') : stderrStr);
8484
console.error(`${tag} --- stdout ---`);
85-
console.error(stdoutStr === undefined ? child.stdout.toString() : stdoutStr);
85+
console.error(stdoutStr === undefined ? (child.stdout?.toString() ?? '') : stdoutStr);
8686
console.error(`${tag} status = ${child.status}, signal = ${child.signal}`);
8787

8888
const error = new Error(`${failures.join('\n')}`);

0 commit comments

Comments
 (0)