throw.js
This file
Path
test/pipe/throw.js
74 lines · 2.8 KiB · JavaScript
Last changed by
Report `null` pipe options as a rejectionSindre Sorhusbefore adoptionecda56b
History of this fileTake it
The walk stopped after 200 commits: lines older than ccfa412 point at it.
TweaksSindre Sorhusbefore adoption698a1b8
lines 1–2why, one step back1import assert from 'node:assert/strict';2import test from 'node:test';Upgrade xo (#980)ehmickybefore adoptionccfa412
lines 3–6why, one step back3import {execa} from '../../index.js';4import {foobarString} from '../helpers/input.js';5import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6import {assertPipeError} from '../helpers/pipe.js';TweaksSindre Sorhusbefore adoption698a1b8
line 7why, one step back7import {assertLike} from '../helpers/assert.js';Upgrade xo (#980)ehmickybefore adoptionccfa412
lines 8–10why, one step back89setFixtureDirectory();10TweaksSindre Sorhusbefore adoption698a1b8
line 11why, one step back11test('Destination stream is ended when first argument is invalid', async () => {Upgrade xo (#980)ehmickybefore adoptionccfa412
lines 12–15why, one step back12 const source = execa('empty.js', {stdout: 'ignore'});13 const destination = execa('stdin.js');14 const pipePromise = source.pipe(destination);15TweaksSindre Sorhusbefore adoption698a1b8
line 16why, one step back16 await assertPipeError(pipePromise, 'option is incompatible');Upgrade xo (#980)ehmickybefore adoptionccfa412
line 17why, one step back17 await source;TweaksSindre Sorhusbefore adoption698a1b8
line 18why, one step back18 assertLike(await destination, {stdout: ''});Upgrade xo (#980)ehmickybefore adoptionccfa412
lines 19–20why, one step back19});20TweaksSindre Sorhusbefore adoption698a1b8
line 21why, one step back21test('Destination stream is ended when first argument is invalid - $', async () => {Upgrade xo (#980)ehmickybefore adoptionccfa412
line 22why, one step back22 const pipePromise = execa('empty.js', {stdout: 'ignore'}).pipe`stdin.js`;TweaksSindre Sorhusbefore adoption698a1b8
line 23why, one step back23 await assertPipeError(pipePromise, 'option is incompatible');Upgrade xo (#980)ehmickybefore adoptionccfa412
lines 24–25why, one step back24});25TweaksSindre Sorhusbefore adoption698a1b8
line 26why, one step back26test('Source stream is aborted when second argument is invalid', async () => {Upgrade xo (#980)ehmickybefore adoptionccfa412
lines 27–29why, one step back27 const source = execa('noop.js', [foobarString]);28 const pipePromise = source.pipe(false);29TweaksSindre Sorhusbefore adoption698a1b8
lines 30–31why, one step back30 await assertPipeError(pipePromise, 'an Execa subprocess');31 assertLike(await source, {stdout: ''});Upgrade xo (#980)ehmickybefore adoptionccfa412
lines 32–33why, one step back32});33TweaksSindre Sorhusbefore adoption698a1b8
line 34why, one step back34test('Both arguments might be invalid', async () => {Upgrade xo (#980)ehmickybefore adoptionccfa412
lines 35–37why, one step back35 const source = execa('empty.js', {stdout: 'ignore'});36 const pipePromise = source.pipe(false);37TweaksSindre Sorhusbefore adoption698a1b8
lines 38–40why, one step back38 await assertPipeError(pipePromise, 'an Execa subprocess');39 const {stdout} = await source;40 assert.equal(stdout, undefined);Upgrade xo (#980)ehmickybefore adoptionccfa412
line 41why, one step back41});Fix `.pipe()` with the `stdio` option and orphaned destination subprocessesSindre Sorhusbefore adoption8d3f0a9
lines 42–44why, one step back4243// The destination subprocess is spawned before the `to` option is validated, so its error must be handled.44// This runs in another process, since that is where the unhandled rejection crashes it.TweaksSindre Sorhusbefore adoption698a1b8
line 45why, one step back45test('Destination subprocess error is not unhandled when the "to" option is invalid', async () => {Fix `.pipe()` with the `stdio` option and orphaned destination subprocessesSindre Sorhusbefore adoption8d3f0a9
line 46why, one step back46 const {stdout} = await execa('pipe-destination-error.js', ['fail.js']);TweaksSindre Sorhusbefore adoption698a1b8
line 47why, one step back47 assert.equal(stdout, 'REACHED THE END');Fix `.pipe()` with the `stdio` option and orphaned destination subprocessesSindre Sorhusbefore adoption8d3f0a9
lines 48–49why, one step back48});49TweaksSindre Sorhusbefore adoption698a1b8
line 50why, one step back50test('Destination subprocess is terminated when the "to" option is invalid', async () => {Fix `.pipe()` with the `stdio` option and orphaned destination subprocessesSindre Sorhusbefore adoption8d3f0a9
line 51why, one step back51 const {stdout} = await execa('pipe-destination-error.js', ['stdin.js'], {timeout: 10_000});TweaksSindre Sorhusbefore adoption698a1b8
line 52why, one step back52 assert.equal(stdout, 'REACHED THE END');Fix `.pipe()` with the `stdio` option and orphaned destination subprocessesSindre Sorhusbefore adoption8d3f0a9
lines 53–54why, one step back53});54TweaksSindre Sorhusbefore adoption698a1b8
line 55why, one step back55test('Destination subprocess passed by the user is not terminated when the "to" option is invalid', async () => {Fix `.pipe()` with the `stdio` option and orphaned destination subprocessesSindre Sorhusbefore adoption8d3f0a9
lines 56–59why, one step back56 const source = execa('empty.js', {stdout: 'ignore'});57 const destination = execa('stdin.js');58 const pipePromise = source.pipe(destination, {to: 'fd9'});59TweaksSindre Sorhusbefore adoption698a1b8
line 60why, one step back60 await assertPipeError(pipePromise, 'fd9');Fix `.pipe()` with the `stdio` option and orphaned destination subprocessesSindre Sorhusbefore adoption8d3f0a9
lines 61–62why, one step back61 destination.stdin.end(foobarString);62 const {stdout} = await destination;TweaksSindre Sorhusbefore adoption698a1b8
line 63why, one step back63 assert.equal(stdout, foobarString);Fix `.pipe()` with the `stdio` option and orphaned destination subprocessesSindre Sorhusbefore adoption8d3f0a9
line 64why, one step back64});Report `null` pipe options as a rejectionSindre Sorhusbefore adoptionecda56b
lines 65–74why, one step back6566test('The pipe options cannot be null', async () => {67 const source = execa('empty.js');68 const destination = execa('stdin.js');69 const pipePromise = source.pipe(destination, null);7071 await assertPipeError(pipePromise, 'not `null`');72 destination.stdin.end();73 await Promise.all([source, destination]);74});