Add more error handling related tests (#773)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent 8312453 · Browse files · 2 files·+27 added−3 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+27 added−3 removed
- tests:+27 added−3 removed
Provenance
- Commit
7591905- Tree
cd856cb- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
8312453
2 files changed+27 added−3 removed
modified:test/stdio/array.js+9 added
249 unmodified lines250 test('Does not destroy process.stdin on child process errors', testDestroyStandard, 0);251 test('Does not destroy process.stdout on child process errors', testDestroyStandard, 1);252 test('Does not destroy process.stderr on child process errors', testDestroyStandard, 2);253 254+const testDestroyStandardSpawn = async (t, index) => {255+ await t.throwsAsync(execa('forever.js', {...getStdio(index, [STANDARD_STREAMS[index], 'pipe']), uid: -1}));256+ t.false(STANDARD_STREAMS[index].destroyed);257+};258+259+test('Does not destroy process.stdin on spawn process errors', testDestroyStandardSpawn, 0);260+test('Does not destroy process.stdout on spawn process errors', testDestroyStandardSpawn, 1);261+test('Does not destroy process.stderr on spawn process errors', testDestroyStandardSpawn, 2);262+263 const testDestroyStandardStream = async (t, index) => {264 const childProcess = execa('forever.js', getStdio(index, [STANDARD_STREAMS[index], 'pipe']));265 const error = new Error('test');266 childProcess.stdio[index].destroy(error);8 unmodified linesmodified:test/stdio/web-stream.js+18 added-3 removed
58 unmodified lines5960616263646565666768686969707172737475767778798081828384858687888958 unmodified linestest('stderr waits for WritableStream completion', testLongWritableStream, 2);test('stdio[*] waits for WritableStream completion', testLongWritableStream, 3);
const testWritableStreamError = async (t, index) => { const error = new Error('foobar'); const writableStream = new WritableStream({ start(controller) { controller.error(new Error('foobar')); controller.error(error); }, }); const {originalMessage} = await t.throwsAsync(execa('noop.js', getStdio(index, writableStream))); t.is(originalMessage, 'foobar'); const thrownError = await t.throwsAsync(execa('noop.js', getStdio(index, writableStream))); t.is(thrownError, error);};
test('stdout option handles errors in WritableStream', testWritableStreamError, 1);test('stderr option handles errors in WritableStream', testWritableStreamError, 2);test('stdio[*] option handles errors in WritableStream', testWritableStreamError, 3);
const testReadableStreamError = async (t, index) => { const error = new Error('foobar'); const readableStream = new ReadableStream({ start(controller) { controller.error(error); }, }); const thrownError = await t.throwsAsync(execa('stdin-fd.js', [`${index}`], getStdio(index, readableStream))); t.is(thrownError, error);};
test('stdin option handles errors in ReadableStream', testReadableStreamError, 0);test('stdio[*] option handles errors in ReadableStream', testReadableStreamError, 3);