validate.js
This file
Path
test/pipe/validate.js
783 lines · 27.5 KiB · JavaScript
Last changed by
Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
History of this fileTake it
1import {PassThrough} from 'node:stream';2import {spawn} from 'node:child_process';3import process from 'node:process';4import test from 'ava';5import {execa} from '../../index.js';6import {setFixtureDir} from '../helpers/fixtures-dir.js';7import {foobarString} from '../helpers/input.js';8import {fullStdio, getStdio} from '../helpers/stdio.js';9import {getEarlyErrorSubprocess} from '../helpers/early-error.js';1011setFixtureDir();1213const assertPipeError = async (t, pipePromise, message) => {14 const error = await t.throwsAsync(pipePromise);1516 t.is(error.command, 'source.pipe(destination)');17 t.is(error.escapedCommand, error.command);1819 t.is(typeof error.cwd, 'string');20 t.true(error.failed);21 t.false(error.timedOut);22 t.false(error.isCanceled);23 t.false(error.isTerminated);24 t.is(error.exitCode, undefined);25 t.is(error.signal, undefined);26 t.is(error.signalDescription, undefined);27 t.is(error.stdout, undefined);28 t.is(error.stderr, undefined);29 t.is(error.all, undefined);30 t.deepEqual(error.stdio, Array.from({length: error.stdio.length}));31 t.deepEqual(error.pipedFrom, []);3233 t.true(error.shortMessage.includes(`Command failed: ${error.command}`));34 t.true(error.shortMessage.includes(error.originalMessage));35 t.true(error.message.includes(error.shortMessage));3637 t.true(error.originalMessage.includes(message));38};3940const getMessage = message => Array.isArray(message)41 ? `"${message[0]}: ${message[1]}" option is incompatible`42 : message;4344const testPipeError = async (t, {45 message,46 sourceOptions = {},47 destinationOptions = {},48 getSource = () => execa('empty.js', sourceOptions),49 getDestination = () => execa('empty.js', destinationOptions),50 isScript = false,51 from,52 to,53}) => {54 const source = getSource();55 const pipePromise = isScript ? source.pipe({from, to})`empty.js` : source.pipe(getDestination(), {from, to});56 await assertPipeError(t, pipePromise, getMessage(message));57};5859const testNodeStream = async (t, {60 message,61 sourceOptions = {},62 getSource = () => execa('empty.js', sourceOptions),63 from,64 to,65 writable = to !== undefined,66}) => {67 assertNodeStream({t, message, getSource, from, to, methodName: writable ? 'writable' : 'readable'});68 assertNodeStream({t, message, getSource, from, to, methodName: 'duplex'});69};7071const assertNodeStream = ({t, message, getSource, from, to, methodName}) => {72 const error = t.throws(() => {73 getSource()[methodName]({from, to});74 });75 t.true(error.message.includes(getMessage(message)));76};7778const testIterable = async (t, {79 message,80 sourceOptions = {},81 getSource = () => execa('empty.js', sourceOptions),82 from,83}) => {84 const error = t.throws(() => {85 getSource().iterable({from});86 });87 t.true(error.message.includes(getMessage(message)));88};8990test('Must set "all" option to "true" to use .pipe("all")', testPipeError, {91 from: 'all',92 message: '"all" option must be true',93});94test('Must set "all" option to "true" to use .duplex("all")', testNodeStream, {95 from: 'all',96 message: '"all" option must be true',97});98test('Must set "all" option to "true" to use .iterable("all")', testIterable, {99 from: 'all',100 message: '"all" option must be true',101});102test('.pipe() cannot pipe to non-subprocesses', testPipeError, {103 getDestination: () => new PassThrough(),104 message: 'an Execa subprocess',105});106test('.pipe() cannot pipe to non-Execa subprocesses', testPipeError, {107 getDestination: () => spawn('node', ['--version']),108 message: 'an Execa subprocess',109});110test('.pipe() "from" option cannot be "stdin"', testPipeError, {111 from: 'stdin',112 message: '"from" must not be',113});114test('.duplex() "from" option cannot be "stdin"', testNodeStream, {115 from: 'stdin',116 message: '"from" must not be',117});118test('.iterable() "from" option cannot be "stdin"', testIterable, {119 from: 'stdin',120 message: '"from" must not be',121});122test('$.pipe() "from" option cannot be "stdin"', testPipeError, {123 from: 'stdin',124 isScript: true,125 message: '"from" must not be',126});127test('.pipe() "to" option cannot be "stdout"', testPipeError, {128 to: 'stdout',129 message: '"to" must not be',130});131test('.duplex() "to" option cannot be "stdout"', testNodeStream, {132 to: 'stdout',133 message: '"to" must not be',134});135test('$.pipe() "to" option cannot be "stdout"', testPipeError, {136 to: 'stdout',137 isScript: true,138 message: '"to" must not be',139});140test('.pipe() "from" option cannot be any string', testPipeError, {141 from: 'other',142 message: 'must be "stdout", "stderr", "all"',143});144test('.duplex() "from" option cannot be any string', testNodeStream, {145 from: 'other',146 message: 'must be "stdout", "stderr", "all"',147});148test('.iterable() "from" option cannot be any string', testIterable, {149 from: 'other',150 message: 'must be "stdout", "stderr", "all"',151});152test('.pipe() "to" option cannot be any string', testPipeError, {153 to: 'other',154 message: 'must be "stdin"',155});156test('.duplex() "to" option cannot be any string', testNodeStream, {157 to: 'other',158 message: 'must be "stdin"',159});160test('.pipe() "from" option cannot be a number without "fd"', testPipeError, {161 from: '1',162 message: 'must be "stdout", "stderr", "all"',163});164test('.duplex() "from" option cannot be a number without "fd"', testNodeStream, {165 from: '1',166 message: 'must be "stdout", "stderr", "all"',167});168test('.iterable() "from" option cannot be a number without "fd"', testIterable, {169 from: '1',170 message: 'must be "stdout", "stderr", "all"',171});172test('.pipe() "to" option cannot be a number without "fd"', testPipeError, {173 to: '0',174 message: 'must be "stdin"',175});176test('.duplex() "to" option cannot be a number without "fd"', testNodeStream, {177 to: '0',178 message: 'must be "stdin"',179});180test('.pipe() "from" option cannot be just "fd"', testPipeError, {181 from: 'fd',182 message: 'must be "stdout", "stderr", "all"',183});184test('.duplex() "from" option cannot be just "fd"', testNodeStream, {185 from: 'fd',186 message: 'must be "stdout", "stderr", "all"',187});188test('.iterable() "from" option cannot be just "fd"', testIterable, {189 from: 'fd',190 message: 'must be "stdout", "stderr", "all"',191});192test('.pipe() "to" option cannot be just "fd"', testPipeError, {193 to: 'fd',194 message: 'must be "stdin"',195});196test('.duplex() "to" option cannot be just "fd"', testNodeStream, {197 to: 'fd',198 message: 'must be "stdin"',199});200test('.pipe() "from" option cannot be a float', testPipeError, {201 from: 'fd1.5',202 message: 'must be "stdout", "stderr", "all"',203});204test('.duplex() "from" option cannot be a float', testNodeStream, {205 from: 'fd1.5',206 message: 'must be "stdout", "stderr", "all"',207});208test('.iterable() "from" option cannot be a float', testIterable, {209 from: 'fd1.5',210 message: 'must be "stdout", "stderr", "all"',211});212test('.pipe() "to" option cannot be a float', testPipeError, {213 to: 'fd1.5',214 message: 'must be "stdin"',215});216test('.duplex() "to" option cannot be a float', testNodeStream, {217 to: 'fd1.5',218 message: 'must be "stdin"',219});220test('.pipe() "from" option cannot be a negative number', testPipeError, {221 from: 'fd-1',222 message: 'must be "stdout", "stderr", "all"',223});224test('.duplex() "from" option cannot be a negative number', testNodeStream, {225 from: 'fd-1',226 message: 'must be "stdout", "stderr", "all"',227});228test('.iterable() "from" option cannot be a negative number', testIterable, {229 from: 'fd-1',230 message: 'must be "stdout", "stderr", "all"',231});232test('.pipe() "to" option cannot be a negative number', testPipeError, {233 to: 'fd-1',234 message: 'must be "stdin"',235});236test('.duplex() "to" option cannot be a negative number', testNodeStream, {237 to: 'fd-1',238 message: 'must be "stdin"',239});240test('.pipe() "from" option cannot be a non-existing file descriptor', testPipeError, {241 from: 'fd3',242 message: 'file descriptor does not exist',243});244test('.duplex() "from" cannot be a non-existing file descriptor', testNodeStream, {245 from: 'fd3',246 message: 'file descriptor does not exist',247});248test('.iterable() "from" cannot be a non-existing file descriptor', testIterable, {249 from: 'fd3',250 message: 'file descriptor does not exist',251});252test('.pipe() "to" option cannot be a non-existing file descriptor', testPipeError, {253 to: 'fd3',254 message: 'file descriptor does not exist',255});256test('.duplex() "to" cannot be a non-existing file descriptor', testNodeStream, {257 to: 'fd3',258 message: 'file descriptor does not exist',259});260test('.pipe() "from" option cannot be an input file descriptor', testPipeError, {261 sourceOptions: getStdio(3, new Uint8Array()),262 from: 'fd3',263 message: 'must be a readable stream',264});265test('.duplex() "from" option cannot be an input file descriptor', testNodeStream, {266 sourceOptions: getStdio(3, new Uint8Array()),267 from: 'fd3',268 message: 'must be a readable stream',269});270test('.iterable() "from" option cannot be an input file descriptor', testIterable, {271 sourceOptions: getStdio(3, new Uint8Array()),272 from: 'fd3',273 message: 'must be a readable stream',274});275test('.pipe() "to" option cannot be an output file descriptor', testPipeError, {276 destinationOptions: fullStdio,277 to: 'fd3',278 message: 'must be a writable stream',279});280test('.duplex() "to" option cannot be an output file descriptor', testNodeStream, {281 sourceOptions: fullStdio,282 to: 'fd3',283 message: 'must be a writable stream',284});285test('.pipe() "to" option cannot be "all"', testPipeError, {286 destinationOptions: fullStdio,287 to: 'all',288 message: 'must be a writable stream',289});290test('.duplex() "to" option cannot be "all"', testNodeStream, {291 sourceOptions: fullStdio,292 to: 'all',293 message: 'must be a writable stream',294});295test('Cannot set "stdout" option to "ignore" to use .pipe()', testPipeError, {296 sourceOptions: {stdout: 'ignore'},297 message: ['stdout', '\'ignore\''],298});299test('Cannot set "stdout" option to "ignore" to use .duplex()', testNodeStream, {300 sourceOptions: {stdout: 'ignore'},301 message: ['stdout', '\'ignore\''],302});303test('Cannot set "stdout" option to "ignore" to use .iterable()', testIterable, {304 sourceOptions: {stdout: 'ignore'},305 message: ['stdout', '\'ignore\''],306});307test('Cannot set "stdin" option to "ignore" to use .pipe()', testPipeError, {308 destinationOptions: {stdin: 'ignore'},309 message: ['stdin', '\'ignore\''],310});311test('Cannot set "stdin" option to "ignore" to use .duplex()', testNodeStream, {312 sourceOptions: {stdin: 'ignore'},313 message: ['stdin', '\'ignore\''],314 writable: true,315});316test('Cannot set "stdout" option to "ignore" to use .pipe(1)', testPipeError, {317 sourceOptions: {stdout: 'ignore'},318 from: 'fd1',319 message: ['stdout', '\'ignore\''],320});321test('Cannot set "stdout" option to "ignore" to use .duplex(1)', testNodeStream, {322 sourceOptions: {stdout: 'ignore'},323 from: 'fd1',324 message: ['stdout', '\'ignore\''],325});326test('Cannot set "stdout" option to "ignore" to use .iterable(1)', testIterable, {327 sourceOptions: {stdout: 'ignore'},328 from: 'fd1',329 message: ['stdout', '\'ignore\''],330});331test('Cannot set "stdin" option to "ignore" to use .pipe(0)', testPipeError, {332 destinationOptions: {stdin: 'ignore'},333 message: ['stdin', '\'ignore\''],334 to: 'fd0',335});336test('Cannot set "stdin" option to "ignore" to use .duplex(0)', testNodeStream, {337 sourceOptions: {stdin: 'ignore'},338 message: ['stdin', '\'ignore\''],339 to: 'fd0',340});341test('Cannot set "stdout" option to "ignore" to use .pipe("stdout")', testPipeError, {342 sourceOptions: {stdout: 'ignore'},343 from: 'stdout',344 message: ['stdout', '\'ignore\''],345});346test('Cannot set "stdout" option to "ignore" to use .duplex("stdout")', testNodeStream, {347 sourceOptions: {stdout: 'ignore'},348 from: 'stdout',349 message: ['stdout', '\'ignore\''],350});351test('Cannot set "stdout" option to "ignore" to use .iterable("stdout")', testIterable, {352 sourceOptions: {stdout: 'ignore'},353 from: 'stdout',354 message: ['stdout', '\'ignore\''],355});356test('Cannot set "stdin" option to "ignore" to use .pipe("stdin")', testPipeError, {357 destinationOptions: {stdin: 'ignore'},358 message: ['stdin', '\'ignore\''],359 to: 'stdin',360});361test('Cannot set "stdin" option to "ignore" to use .duplex("stdin")', testNodeStream, {362 sourceOptions: {stdin: 'ignore'},363 message: ['stdin', '\'ignore\''],364 to: 'stdin',365});366test('Cannot set "stdout" + "stderr" option to "ignore" to use .pipe()', testPipeError, {367 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},368 message: ['stdout', '\'ignore\''],369});370test('Cannot set "stdout" + "stderr" option to "ignore" to use .duplex()', testNodeStream, {371 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},372 message: ['stdout', '\'ignore\''],373});374test('Cannot set "stdout" + "stderr" option to "ignore" to use .iterable()', testIterable, {375 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},376 message: ['stdout', '\'ignore\''],377});378test('Cannot set "stdout" + "stderr" option to "ignore" to use .pipe(1)', testPipeError, {379 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},380 from: 'fd1',381 message: ['stdout', '\'ignore\''],382});383test('Cannot set "stdout" + "stderr" option to "ignore" to use .duplex(1)', testNodeStream, {384 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},385 from: 'fd1',386 message: ['stdout', '\'ignore\''],387});388test('Cannot set "stdout" + "stderr" option to "ignore" to use .iterable(1)', testIterable, {389 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},390 from: 'fd1',391 message: ['stdout', '\'ignore\''],392});393test('Cannot set "stdout" + "stderr" option to "ignore" to use .pipe("stdout")', testPipeError, {394 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},395 from: 'stdout',396 message: ['stdout', '\'ignore\''],397});398test('Cannot set "stdout" + "stderr" option to "ignore" to use .duplex("stdout")', testNodeStream, {399 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},400 from: 'stdout',401 message: ['stdout', '\'ignore\''],402});403test('Cannot set "stdout" + "stderr" option to "ignore" to use .iterable("stdout")', testIterable, {404 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},405 from: 'stdout',406 message: ['stdout', '\'ignore\''],407});408test('Cannot set "stdio[1]" option to "ignore" to use .pipe()', testPipeError, {409 sourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},410 message: ['stdio[1]', '\'ignore\''],411});412test('Cannot set "stdio[1]" option to "ignore" to use .duplex()', testNodeStream, {413 sourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},414 message: ['stdio[1]', '\'ignore\''],415});416test('Cannot set "stdio[1]" option to "ignore" to use .iterable()', testIterable, {417 sourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},418 message: ['stdio[1]', '\'ignore\''],419});420test('Cannot set "stdio[0]" option to "ignore" to use .pipe()', testPipeError, {421 destinationOptions: {stdio: ['ignore', 'pipe', 'pipe']},422 message: ['stdio[0]', '\'ignore\''],423});424test('Cannot set "stdio[0]" option to "ignore" to use .duplex()', testNodeStream, {425 sourceOptions: {stdio: ['ignore', 'pipe', 'pipe']},426 message: ['stdio[0]', '\'ignore\''],427 writable: true,428});429test('Cannot set "stdio[1]" option to "ignore" to use .pipe(1)', testPipeError, {430 sourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},431 from: 'fd1',432 message: ['stdio[1]', '\'ignore\''],433});434test('Cannot set "stdio[1]" option to "ignore" to use .duplex(1)', testNodeStream, {435 sourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},436 from: 'fd1',437 message: ['stdio[1]', '\'ignore\''],438});439test('Cannot set "stdio[1]" option to "ignore" to use .iterable(1)', testIterable, {440 sourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},441 from: 'fd1',442 message: ['stdio[1]', '\'ignore\''],443});444test('Cannot set "stdio[0]" option to "ignore" to use .pipe(0)', testPipeError, {445 destinationOptions: {stdio: ['ignore', 'pipe', 'pipe']},446 message: ['stdio[0]', '\'ignore\''],447 to: 'fd0',448});449test('Cannot set "stdio[0]" option to "ignore" to use .duplex(0)', testNodeStream, {450 sourceOptions: {stdio: ['ignore', 'pipe', 'pipe']},451 message: ['stdio[0]', '\'ignore\''],452 to: 'fd0',453});454test('Cannot set "stdio[1]" option to "ignore" to use .pipe("stdout")', testPipeError, {455 sourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},456 from: 'stdout',457 message: ['stdio[1]', '\'ignore\''],458});459test('Cannot set "stdio[1]" option to "ignore" to use .duplex("stdout")', testNodeStream, {460 sourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},461 from: 'stdout',462 message: ['stdio[1]', '\'ignore\''],463});464test('Cannot set "stdio[1]" option to "ignore" to use .iterable("stdout")', testIterable, {465 sourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},466 from: 'stdout',467 message: ['stdio[1]', '\'ignore\''],468});469test('Cannot set "stdio[0]" option to "ignore" to use .pipe("stdin")', testPipeError, {470 destinationOptions: {stdio: ['ignore', 'pipe', 'pipe']},471 message: ['stdio[0]', '\'ignore\''],472 to: 'stdin',473});474test('Cannot set "stdio[0]" option to "ignore" to use .duplex("stdin")', testNodeStream, {475 sourceOptions: {stdio: ['ignore', 'pipe', 'pipe']},476 message: ['stdio[0]', '\'ignore\''],477 to: 'stdin',478});479test('Cannot set "stderr" option to "ignore" to use .pipe(2)', testPipeError, {480 sourceOptions: {stderr: 'ignore'},481 from: 'fd2',482 message: ['stderr', '\'ignore\''],483});484test('Cannot set "stderr" option to "ignore" to use .duplex(2)', testNodeStream, {485 sourceOptions: {stderr: 'ignore'},486 from: 'fd2',487 message: ['stderr', '\'ignore\''],488});489test('Cannot set "stderr" option to "ignore" to use .iterable(2)', testIterable, {490 sourceOptions: {stderr: 'ignore'},491 from: 'fd2',492 message: ['stderr', '\'ignore\''],493});494test('Cannot set "stderr" option to "ignore" to use .pipe("stderr")', testPipeError, {495 sourceOptions: {stderr: 'ignore'},496 from: 'stderr',497 message: ['stderr', '\'ignore\''],498});499test('Cannot set "stderr" option to "ignore" to use .duplex("stderr")', testNodeStream, {500 sourceOptions: {stderr: 'ignore'},501 from: 'stderr',502 message: ['stderr', '\'ignore\''],503});504test('Cannot set "stderr" option to "ignore" to use .iterable("stderr")', testIterable, {505 sourceOptions: {stderr: 'ignore'},506 from: 'stderr',507 message: ['stderr', '\'ignore\''],508});509test('Cannot set "stdout" + "stderr" option to "ignore" to use .pipe(2)', testPipeError, {510 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},511 from: 'fd2',512 message: ['stderr', '\'ignore\''],513});514test('Cannot set "stdout" + "stderr" option to "ignore" to use .duplex(2)', testNodeStream, {515 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},516 from: 'fd2',517 message: ['stderr', '\'ignore\''],518});519test('Cannot set "stdout" + "stderr" option to "ignore" to use .iterable(2)', testIterable, {520 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},521 from: 'fd2',522 message: ['stderr', '\'ignore\''],523});524test('Cannot set "stdout" + "stderr" option to "ignore" to use .pipe("stderr")', testPipeError, {525 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},526 from: 'stderr',527 message: ['stderr', '\'ignore\''],528});529test('Cannot set "stdout" + "stderr" option to "ignore" to use .duplex("stderr")', testNodeStream, {530 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},531 from: 'stderr',532 message: ['stderr', '\'ignore\''],533});534test('Cannot set "stdout" + "stderr" option to "ignore" to use .iterable("stderr")', testIterable, {535 sourceOptions: {stdout: 'ignore', stderr: 'ignore'},536 from: 'stderr',537 message: ['stderr', '\'ignore\''],538});539test('Cannot set "stdio[2]" option to "ignore" to use .pipe(2)', testPipeError, {540 sourceOptions: {stdio: ['pipe', 'pipe', 'ignore']},541 from: 'fd2',542 message: ['stdio[2]', '\'ignore\''],543});544test('Cannot set "stdio[2]" option to "ignore" to use .duplex(2)', testNodeStream, {545 sourceOptions: {stdio: ['pipe', 'pipe', 'ignore']},546 from: 'fd2',547 message: ['stdio[2]', '\'ignore\''],548});549test('Cannot set "stdio[2]" option to "ignore" to use .iterable(2)', testIterable, {550 sourceOptions: {stdio: ['pipe', 'pipe', 'ignore']},551 from: 'fd2',552 message: ['stdio[2]', '\'ignore\''],553});554test('Cannot set "stdio[2]" option to "ignore" to use .pipe("stderr")', testPipeError, {555 sourceOptions: {stdio: ['pipe', 'pipe', 'ignore']},556 from: 'stderr',557 message: ['stdio[2]', '\'ignore\''],558});559test('Cannot set "stdio[2]" option to "ignore" to use .duplex("stderr")', testNodeStream, {560 sourceOptions: {stdio: ['pipe', 'pipe', 'ignore']},561 from: 'stderr',562 message: ['stdio[2]', '\'ignore\''],563});564test('Cannot set "stdio[2]" option to "ignore" to use .iterable("stderr")', testIterable, {565 sourceOptions: {stdio: ['pipe', 'pipe', 'ignore']},566 from: 'stderr',567 message: ['stdio[2]', '\'ignore\''],568});569test('Cannot set "stdio[3]" option to "ignore" to use .pipe(3)', testPipeError, {570 sourceOptions: getStdio(3, 'ignore'),571 from: 'fd3',572 message: ['stdio[3]', '\'ignore\''],573});574test('Cannot set "stdio[3]" option to "ignore" to use .duplex(3)', testNodeStream, {575 sourceOptions: getStdio(3, 'ignore'),576 from: 'fd3',577 message: ['stdio[3]', '\'ignore\''],578});579test('Cannot set "stdio[3]" option to "ignore" to use .iterable(3)', testIterable, {580 sourceOptions: getStdio(3, 'ignore'),581 from: 'fd3',582 message: ['stdio[3]', '\'ignore\''],583});584test('Cannot set "stdout" + "stderr" option to "ignore" to use .pipe("all")', testPipeError, {585 sourceOptions: {stdout: 'ignore', stderr: 'ignore', all: true},586 from: 'all',587 message: ['stdout', '\'ignore\''],588});589test('Cannot set "stdout" + "stderr" option to "ignore" to use .duplex("all")', testNodeStream, {590 sourceOptions: {stdout: 'ignore', stderr: 'ignore', all: true},591 from: 'all',592 message: ['stdout', '\'ignore\''],593});594test('Cannot set "stdout" + "stderr" option to "ignore" to use .iterable("all")', testIterable, {595 sourceOptions: {stdout: 'ignore', stderr: 'ignore', all: true},596 from: 'all',597 message: ['stdout', '\'ignore\''],598});599test('Cannot set "stdio[1]" + "stdio[2]" option to "ignore" to use .pipe("all")', testPipeError, {600 sourceOptions: {stdio: ['pipe', 'ignore', 'ignore'], all: true},601 from: 'all',602 message: ['stdio[1]', '\'ignore\''],603});604test('Cannot set "stdio[1]" + "stdio[2]" option to "ignore" to use .duplex("all")', testNodeStream, {605 sourceOptions: {stdio: ['pipe', 'ignore', 'ignore'], all: true},606 from: 'all',607 message: ['stdio[1]', '\'ignore\''],608});609test('Cannot set "stdio[1]" + "stdio[2]" option to "ignore" to use .iterable("all")', testIterable, {610 sourceOptions: {stdio: ['pipe', 'ignore', 'ignore'], all: true},611 from: 'all',612 message: ['stdio[1]', '\'ignore\''],613});614test('Cannot set "stdout" option to "inherit" to use .pipe()', testPipeError, {615 sourceOptions: {stdout: 'inherit'},616 message: ['stdout', '\'inherit\''],617});618test('Cannot set "stdout" option to "inherit" to use .duplex()', testNodeStream, {619 sourceOptions: {stdout: 'inherit'},620 message: ['stdout', '\'inherit\''],621});622test('Cannot set "stdout" option to "inherit" to use .iterable()', testIterable, {623 sourceOptions: {stdout: 'inherit'},624 message: ['stdout', '\'inherit\''],625});626test('Cannot set "stdin" option to "inherit" to use .pipe()', testPipeError, {627 destinationOptions: {stdin: 'inherit'},628 message: ['stdin', '\'inherit\''],629});630test('Cannot set "stdin" option to "inherit" to use .duplex()', testNodeStream, {631 sourceOptions: {stdin: 'inherit'},632 message: ['stdin', '\'inherit\''],633 writable: true,634});635test('Cannot set "stdout" option to "ipc" to use .pipe()', testPipeError, {636 sourceOptions: {stdout: 'ipc'},637 message: ['stdout', '\'ipc\''],638});639test('Cannot set "stdout" option to "ipc" to use .duplex()', testNodeStream, {640 sourceOptions: {stdout: 'ipc'},641 message: ['stdout', '\'ipc\''],642});643test('Cannot set "stdout" option to "ipc" to use .iterable()', testIterable, {644 sourceOptions: {stdout: 'ipc'},645 message: ['stdout', '\'ipc\''],646});647test('Cannot set "stdin" option to "ipc" to use .pipe()', testPipeError, {648 destinationOptions: {stdin: 'ipc'},649 message: ['stdin', '\'ipc\''],650});651test('Cannot set "stdin" option to "ipc" to use .duplex()', testNodeStream, {652 sourceOptions: {stdin: 'ipc'},653 message: ['stdin', '\'ipc\''],654 writable: true,655});656test('Cannot set "stdout" option to file descriptors to use .pipe()', testPipeError, {657 sourceOptions: {stdout: 1},658 message: ['stdout', '1'],659});660test('Cannot set "stdout" option to file descriptors to use .duplex()', testNodeStream, {661 sourceOptions: {stdout: 1},662 message: ['stdout', '1'],663});664test('Cannot set "stdout" option to file descriptors to use .iterable()', testIterable, {665 sourceOptions: {stdout: 1},666 message: ['stdout', '1'],667});668test('Cannot set "stdin" option to file descriptors to use .pipe()', testPipeError, {669 destinationOptions: {stdin: 0},670 message: ['stdin', '0'],671});672test('Cannot set "stdin" option to file descriptors to use .duplex()', testNodeStream, {673 sourceOptions: {stdin: 0},674 message: ['stdin', '0'],675 writable: true,676});677test('Cannot set "stdout" option to Node.js streams to use .pipe()', testPipeError, {678 sourceOptions: {stdout: process.stdout},679 message: ['stdout', 'Stream'],680});681test('Cannot set "stdout" option to Node.js streams to use .duplex()', testNodeStream, {682 sourceOptions: {stdout: process.stdout},683 message: ['stdout', 'Stream'],684});685test('Cannot set "stdout" option to Node.js streams to use .iterable()', testIterable, {686 sourceOptions: {stdout: process.stdout},687 message: ['stdout', 'Stream'],688});689test('Cannot set "stdin" option to Node.js streams to use .pipe()', testPipeError, {690 destinationOptions: {stdin: process.stdin},691 message: ['stdin', 'Stream'],692});693test('Cannot set "stdin" option to Node.js streams to use .duplex()', testNodeStream, {694 sourceOptions: {stdin: process.stdin},695 message: ['stdin', 'Stream'],696 writable: true,697});698test('Cannot set "stdio[3]" option to Node.js Writable streams to use .pipe()', testPipeError, {699 sourceOptions: getStdio(3, process.stdout),700 message: ['stdio[3]', 'Stream'],701 from: 'fd3',702});703test('Cannot set "stdio[3]" option to Node.js Writable streams to use .duplex()', testNodeStream, {704 sourceOptions: getStdio(3, process.stdout),705 message: ['stdio[3]', 'Stream'],706 from: 'fd3',707});708test('Cannot set "stdio[3]" option to Node.js Writable streams to use .iterable()', testIterable, {709 sourceOptions: getStdio(3, process.stdout),710 message: ['stdio[3]', 'Stream'],711 from: 'fd3',712});713test('Cannot set "stdio[3]" option to Node.js Readable streams to use .pipe()', testPipeError, {714 destinationOptions: getStdio(3, process.stdin),715 message: ['stdio[3]', 'Stream'],716 to: 'fd3',717});718test('Cannot set "stdio[3]" option to Node.js Readable streams to use .duplex()', testNodeStream, {719 sourceOptions: getStdio(3, process.stdin),720 message: ['stdio[3]', 'Stream'],721 to: 'fd3',722});723724test('Destination stream is ended when first argument is invalid', async t => {725 const source = execa('empty.js', {stdout: 'ignore'});726 const destination = execa('stdin.js');727 const pipePromise = source.pipe(destination);728729 await assertPipeError(t, pipePromise, 'option is incompatible');730 await source;731 t.like(await destination, {stdout: ''});732});733734test('Destination stream is ended when first argument is invalid - $', async t => {735 const pipePromise = execa('empty.js', {stdout: 'ignore'}).pipe`stdin.js`;736 await assertPipeError(t, pipePromise, 'option is incompatible');737});738739test('Source stream is aborted when second argument is invalid', async t => {740 const source = execa('noop.js', [foobarString]);741 const pipePromise = source.pipe(false);742743 await assertPipeError(t, pipePromise, 'an Execa subprocess');744 t.like(await source, {stdout: ''});745});746747test('Both arguments might be invalid', async t => {748 const source = execa('empty.js', {stdout: 'ignore'});749 const pipePromise = source.pipe(false);750751 await assertPipeError(t, pipePromise, 'an Execa subprocess');752 t.like(await source, {stdout: undefined});753});754755test('Sets the right error message when the "all" option is incompatible - execa.$', async t => {756 await assertPipeError(757 t,758 execa('empty.js')759 .pipe({all: false})`stdin.js`760 .pipe(execa('empty.js'), {from: 'all'}),761 '"all" option must be true',762 );763});764765test('Sets the right error message when the "all" option is incompatible - execa.execa', async t => {766 await assertPipeError(767 t,768 execa('empty.js')769 .pipe(execa('stdin.js', {all: false}))770 .pipe(execa('empty.js'), {from: 'all'}),771 '"all" option must be true',772 );773});774775test('Sets the right error message when the "all" option is incompatible - early error', async t => {776 await assertPipeError(777 t,778 getEarlyErrorSubprocess()779 .pipe(execa('stdin.js', {all: false}))780 .pipe(execa('empty.js'), {from: 'all'}),781 '"all" option must be true',782 );783});