Skip to content
Myr

Fix using both `encoding: 'utf16le'` and `lines`/`verbose` options (#931)

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

authored by ehmicky · committed by GitHub · parent d30fcbc · Browse files · 8 files+42 added−12 removed
This commit

State

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

Diff stats

8 files+42 added−12 removed

  • tests:+41 added−11 removed
  • other:+1 added−1 removed

8 files+42 added−12 removed

modified:lib/stdio/handle.js+1 added-1 removed
modified:test/convert/readable.js+2 added-4 removed
43 unmodified lines
44});4546// eslint-disable-next-line max-params47const testReadableDefault = async (t, fdNumber, from, options, hasResult) => {48 const subprocess = execa('noop-stdin-fd.js', [`${fdNumber}`], options);48 const subprocess = execa('noop-fd.js', [`${fdNumber}`, foobarString], options);49 const stream = subprocess.readable({from});50 subprocess.stdin.end(foobarString);5051 await assertStreamOutput(t, stream, hasResult ? foobarString : '');52 await assertSubprocessOutput(t, subprocess, foobarString, fdNumber);53};
388 unmodified lines
442}443444const testBigOutput = async (t, methodName) => {445 const bigChunk = '.'.repeat(1e6);447 const subprocess = execa('stdin.js');448 subprocess.stdin.end(bigChunk);446 const subprocess = execa('stdin.js', {input: bigChunk});447 const stream = subprocess[methodName]();448449 await assertStreamOutput(t, stream, bigChunk);450 await assertSubprocessOutput(t, subprocess, bigChunk);
4 unmodified lines
added:test/fixtures/nested-input.js+7 added
modified:test/helpers/input.js+4 added
modified:test/helpers/lines.js+3 added
modified:test/stdio/lines.js+19 added-5 removed
12 unmodified lines
13 simpleFull,14 simpleChunks,15 simpleFullUint8Array,16 simpleFullHex,17 simpleFullUtf16Uint8Array,18 simpleLines,19 simpleFullEndLines,20 noNewlinesChunks,21} from '../helpers/lines.js';
59 unmodified lines
81 });82 t.deepEqual(stdout, [foobarObject]);83});8484const testOtherEncoding = async (t, expectedOutput, encoding, stripFinalNewline) => {85const testBinaryEncoding = async (t, expectedOutput, encoding, stripFinalNewline) => {86 const {stdout} = await getSimpleChunkSubprocess({encoding, stripFinalNewline});87 t.deepEqual(stdout, expectedOutput);88};8989test('"lines: true" is a noop with "encoding: buffer"', testOtherEncoding, simpleFullUint8Array, 'buffer', false);90test('"lines: true" is a noop with "encoding: buffer", stripFinalNewline', testOtherEncoding, simpleFullUint8Array, 'buffer', false);91test('"lines: true" is a noop with "encoding: hex"', testOtherEncoding, simpleFullHex, 'hex', false);92test('"lines: true" is a noop with "encoding: hex", stripFinalNewline', testOtherEncoding, simpleFullHex, 'hex', true);90test('"lines: true" is a noop with "encoding: buffer"', testBinaryEncoding, simpleFullUint8Array, 'buffer', false);91test('"lines: true" is a noop with "encoding: buffer", stripFinalNewline', testBinaryEncoding, simpleFullUint8Array, 'buffer', false);92test('"lines: true" is a noop with "encoding: hex"', testBinaryEncoding, simpleFullHex, 'hex', false);93test('"lines: true" is a noop with "encoding: hex", stripFinalNewline', testBinaryEncoding, simpleFullHex, 'hex', true);9495const testTextEncoding = async (t, expectedLines, stripFinalNewline) => {96 const {stdout} = await execa('stdin.js', {97 lines: true,98 stripFinalNewline,99 encoding: 'utf16le',100 input: simpleFullUtf16Uint8Array,101 });102 t.deepEqual(stdout, expectedLines);103};104105test('"lines: true" is a noop with "encoding: utf16"', testTextEncoding, simpleLines, false);106test('"lines: true" is a noop with "encoding: utf16", stripFinalNewline', testTextEncoding, noNewlinesChunks, true);107108test('"lines: true" is a noop with "buffer: false"', async t => {109 const {stdout} = await getSimpleChunkSubprocess({buffer: false});110 t.is(stdout, undefined);111});
77 unmodified lines
modified:test/stdio/node-stream.js+1 added-2 removed
149 unmodified lines
150151const testFileWritableError = async (t, fdNumber) => {152 const {stream, filePath} = await createFileWriteStream();153154 const subprocess = execa('noop-stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, stream));155 subprocess.stdin.end(foobarString);154 const subprocess = execa('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, stream));155156 await assertFileStreamError(t, subprocess, stream, filePath);157};158
150 unmodified lines
modified:test/verbose/output.js+5 added
184 unmodified lines
185 const {stderr} = await nestedExecaAsync('noop-fd.js', ['1', '\n'], {verbose: 'full'});186 t.deepEqual(getOutputLines(stderr), [`${testTimestamp} [0] `]);187});188189test('Can use encoding UTF16, verbose "full"', async t => {190 const {stderr} = await nestedExeca('nested-input.js', 'stdin.js', {verbose: 'full', encoding: 'utf16le'});191 t.is(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);192});193194const testNoOutputOptions = async (t, options, fixtureName = 'nested.js') => {195 const {stderr} = await nestedExeca(fixtureName, 'noop.js', [foobarString], {verbose: 'full', ...options});196 t.is(getOutputLine(stderr), undefined);197};
42 unmodified lines