Skip to content
Myr

Improve error handling (#647)

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

authored by ehmicky · committed by GitHub · parent 249e7c4 · Browse files · 3 files+37 added−13 removed
This commit

State

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

Diff stats

3 files+37 added−13 removed

  • tests:+26 added−1 removed
  • other:+11 added−12 removed

3 files+37 added−13 removed

modified:lib/stream.js+11 added-12 removed
modified:test/helpers/generator.js+11 added
modified:test/stdio/iterable.js+15 added-1 removed
1import {once} from 'node:events';2import test from 'ava';3import {execa, execaSync} from '../../index.js';4import {setFixtureDir} from '../helpers/fixtures-dir.js';5import {getStdinOption, getStdoutOption, getStderrOption, getStdioOption} from '../helpers/stdio.js';5import {stringGenerator, binaryGenerator, asyncGenerator, throwingGenerator} from '../helpers/generator.js';6import {stringGenerator, binaryGenerator, asyncGenerator, throwingGenerator, infiniteGenerator} from '../helpers/generator.js';78setFixtureDir();910const testIterable = async (t, stdioOption, fixtureName, getOptions) => {
36 unmodified lines
47test('stdout option cannot be an iterable', testNoIterableOutput, getStdoutOption, execa);48test('stderr option cannot be an iterable', testNoIterableOutput, getStderrOption, execa);49test('stdout option cannot be an iterable - sync', testNoIterableOutput, getStdoutOption, execaSync);50test('stderr option cannot be an iterable - sync', testNoIterableOutput, getStderrOption, execaSync);5152test('stdin option can be an infinite iterable', async t => {53 const {iterable, abort} = infiniteGenerator();54 try {55 const childProcess = execa('stdin.js', getStdinOption(iterable));56 const stdout = await once(childProcess.stdout, 'data');57 t.is(stdout.toString(), 'foo');58 childProcess.kill('SIGKILL');59 await t.throwsAsync(childProcess, {message: /SIGKILL/});60 } finally {61 abort();62 }63});