wait-error.js
This file
Path
test/resolve/wait-error.js
65 lines · 6.0 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
The walk stopped after 200 commits: lines older than 9f65b86 point at it.
TweaksSindre Sorhusbefore adoption698a1b8
lines 1–3why, one step back1import assert from 'node:assert/strict';2import test from 'node:test';3import {assertRejects} from '../helpers/assert.js';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 4–10why, one step back4import {execa} from '../../index.js';5import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6import {noopReadable, noopWritable, noopDuplex} from '../helpers/stream.js';7import {destroyOptionStream, destroySubprocessStream, getStreamStdio} from '../helpers/wait.js';89setFixtureDirectory();10TweaksSindre Sorhusbefore adoption698a1b8
line 11why, one step back11const testStreamError = async (streamMethod, stream, fdNumber, useTransform) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 12–20why, one step back12 const subprocess = execa('empty.js', getStreamStdio(fdNumber, stream, useTransform));13 const cause = new Error('test');14 streamMethod({15 stream,16 subprocess,17 fdNumber,18 error: cause,19 });20TweaksSindre Sorhusbefore adoption698a1b8
lines 21–27why, one step back21 const error = await assertRejects(subprocess);22 assert.equal(error.cause, cause);23 assert.equal(error.exitCode, 0);24 assert.equal(error.signal, undefined);25 assert.equal(error.isTerminated, false);26 assert.equal(error.failed, true);27 assert.equal(stream.destroyed, true);100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 28–29why, one step back28};29TweaksSindre Sorhusbefore adoption698a1b8
lines 30–65why, one step back30test('Throws stream error when stdin option errors', () => testStreamError(destroyOptionStream, noopReadable(), 0, false));31test('Throws stream error when stdin option Duplex errors', () => testStreamError(destroyOptionStream, noopDuplex(), 0, false));32test('Throws stream error when stdout option errors', () => testStreamError(destroyOptionStream, noopWritable(), 1, false));33test('Throws stream error when stdout option Duplex errors', () => testStreamError(destroyOptionStream, noopDuplex(), 1, false));34test('Throws stream error when stderr option errors', () => testStreamError(destroyOptionStream, noopWritable(), 2, false));35test('Throws stream error when stderr option Duplex errors', () => testStreamError(destroyOptionStream, noopDuplex(), 2, false));36test('Throws stream error when output stdio[*] option errors', () => testStreamError(destroyOptionStream, noopWritable(), 3, false));37test('Throws stream error when output stdio[*] Duplex option errors', () => testStreamError(destroyOptionStream, noopDuplex(), 3, false));38test('Throws stream error when input stdio[*] option errors', () => testStreamError(destroyOptionStream, noopReadable(), 3, false));39test('Throws stream error when subprocess.stdin errors', () => testStreamError(destroySubprocessStream, noopReadable(), 0, false));40test('Throws stream error when subprocess.stdin Duplex errors', () => testStreamError(destroySubprocessStream, noopDuplex(), 0, false));41test('Throws stream error when subprocess.stdout errors', () => testStreamError(destroySubprocessStream, noopWritable(), 1, false));42test('Throws stream error when subprocess.stdout Duplex errors', () => testStreamError(destroySubprocessStream, noopDuplex(), 1, false));43test('Throws stream error when subprocess.stderr errors', () => testStreamError(destroySubprocessStream, noopWritable(), 2, false));44test('Throws stream error when subprocess.stderr Duplex errors', () => testStreamError(destroySubprocessStream, noopDuplex(), 2, false));45test('Throws stream error when output subprocess.stdio[*] errors', () => testStreamError(destroySubprocessStream, noopWritable(), 3, false));46test('Throws stream error when output subprocess.stdio[*] Duplex errors', () => testStreamError(destroySubprocessStream, noopDuplex(), 3, false));47test('Throws stream error when input subprocess.stdio[*] errors', () => testStreamError(destroySubprocessStream, noopReadable(), 3, false));48test('Throws stream error when stdin option errors, with a transform', () => testStreamError(destroyOptionStream, noopReadable(), 0, true));49test('Throws stream error when stdin option Duplex errors, with a transform', () => testStreamError(destroyOptionStream, noopDuplex(), 0, true));50test('Throws stream error when stdout option errors, with a transform', () => testStreamError(destroyOptionStream, noopWritable(), 1, true));51test('Throws stream error when stdout option Duplex errors, with a transform', () => testStreamError(destroyOptionStream, noopDuplex(), 1, true));52test('Throws stream error when stderr option errors, with a transform', () => testStreamError(destroyOptionStream, noopWritable(), 2, true));53test('Throws stream error when stderr option Duplex errors, with a transform', () => testStreamError(destroyOptionStream, noopDuplex(), 2, true));54test('Throws stream error when output stdio[*] option errors, with a transform', () => testStreamError(destroyOptionStream, noopWritable(), 3, true));55test('Throws stream error when output stdio[*] Duplex option errors, with a transform', () => testStreamError(destroyOptionStream, noopDuplex(), 3, true));56test('Throws stream error when input stdio[*] option errors, with a transform', () => testStreamError(destroyOptionStream, noopReadable(), 3, true));57test('Throws stream error when subprocess.stdin errors, with a transform', () => testStreamError(destroySubprocessStream, noopReadable(), 0, true));58test('Throws stream error when subprocess.stdin Duplex errors, with a transform', () => testStreamError(destroySubprocessStream, noopDuplex(), 0, true));59test('Throws stream error when subprocess.stdout errors, with a transform', () => testStreamError(destroySubprocessStream, noopWritable(), 1, true));60test('Throws stream error when subprocess.stdout Duplex errors, with a transform', () => testStreamError(destroySubprocessStream, noopDuplex(), 1, true));61test('Throws stream error when subprocess.stderr errors, with a transform', () => testStreamError(destroySubprocessStream, noopWritable(), 2, true));62test('Throws stream error when subprocess.stderr Duplex errors, with a transform', () => testStreamError(destroySubprocessStream, noopDuplex(), 2, true));63test('Throws stream error when output subprocess.stdio[*] errors, with a transform', () => testStreamError(destroySubprocessStream, noopWritable(), 3, true));64test('Throws stream error when output subprocess.stdio[*] Duplex errors, with a transform', () => testStreamError(destroySubprocessStream, noopDuplex(), 3, true));65test('Throws stream error when input subprocess.stdio[*] errors, with a transform', () => testStreamError(destroySubprocessStream, noopReadable(), 3, true));