Skip to content
Myr

Add tests related to the `buffer` option (#692)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by GitHub · parent 98b0ee3 · Browse files · 1 file+32 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+32 added−0 removed

  • tests:+32 added−0 removed

1 file+32 added−0 removed

modified:test/stream.js+32 added
44 unmodified lines
45test('stdout is undefined if ignored - sync', testIgnore, 1, execaSync);46test('stderr is undefined if ignored - sync', testIgnore, 2, execaSync);47test('stdio[*] is undefined if ignored - sync', testIgnore, 3, execaSync);4849const testIterationBuffer = async (t, index, buffer, expectedValue) => {50 const subprocess = execa('noop-fd.js', [`${index}`], {...fullStdio, buffer});51 const [output] = await Promise.all([52 getStream(subprocess.stdio[index]),53 subprocess,54 ]);55 t.is(output, expectedValue);56};5758test('Can iterate stdout when `buffer` set to `false`', testIterationBuffer, 1, false, 'foobar');59test('Can iterate stderr when `buffer` set to `false`', testIterationBuffer, 2, false, 'foobar');60test('Can iterate stdio[*] when `buffer` set to `false`', testIterationBuffer, 3, false, 'foobar');61test('Cannot iterate stdout when `buffer` set to `true`', testIterationBuffer, 1, true, '');62test('Cannot iterate stderr when `buffer` set to `true`', testIterationBuffer, 2, true, '');63test('Cannot iterate stdio[*] when `buffer` set to `true`', testIterationBuffer, 3, true, '');6465const testDataEventsBuffer = async (t, index, buffer) => {66 const subprocess = execa('noop-fd.js', [`${index}`], {...fullStdio, buffer});67 const [[output]] = await Promise.all([68 once(subprocess.stdio[index], 'data'),69 subprocess,70 ]);71 t.is(output.toString(), 'foobar');72};7374test('Can listen to `data` events on stdout when `buffer` set to `false`', testDataEventsBuffer, 1, false);75test('Can listen to `data` events on stderr when `buffer` set to `false`', testDataEventsBuffer, 2, false);76test('Can listen to `data` events on stdio[*] when `buffer` set to `false`', testDataEventsBuffer, 3, false);77test('Can listen to `data` events on stdout when `buffer` set to `true`', testDataEventsBuffer, 1, true);78test('Can listen to `data` events on stderr when `buffer` set to `true`', testDataEventsBuffer, 2, true);79test('Can listen to `data` events on stdio[*] when `buffer` set to `true`', testDataEventsBuffer, 3, true);8081const maxBuffer = 10;8283const testMaxBufferSuccess = async (t, index, all) => {84 await t.notThrowsAsync(execa('max-buffer.js', [`${index}`, `${maxBuffer}`], {...fullStdio, maxBuffer, all}));
219 unmodified lines