Runs CI tests on Node 23 (#1169)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent e3572d0 · Browse files · 9 files·+175 added−152 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
9 files+175 added−152 removed
- tests:+173 added−150 removed
- other:+2 added−2 removed
Provenance
- Commit
e330bd8- Tree
6bdc976- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
e3572d0
9 files changed+175 added−152 removed
modified:.github/workflows/main.yml+2 added-2 removed
8 unmodified lines910111213131415161712 unmodified lines303132333434353637385 unmodified lines8 unmodified lines strategy: fail-fast: false matrix: node-version: - 22 - 23 - 18 os: - ubuntu - macos12 unmodified lines - uses: lycheeverse/lychee-action@v1 with: args: --cache --verbose --no-progress --include-fragments --exclude packagephobia --exclude /pull/ --exclude linkedin --exclude file:///test --exclude invalid.com '*.md' 'docs/*.md' '.github/**/*.md' '*.json' '*.js' 'lib/**/*.js' 'test/**/*.js' '*.ts' 'test-d/**/*.ts' fail: true if: ${{ matrix.os == 'ubuntu' && matrix.node-version == 22 }} if: ${{ matrix.os == 'ubuntu' && matrix.node-version == 23 }} - run: npm run lint - run: npm run type - run: npm run unit - uses: codecov/codecov-action@v45 unmodified linesmodified:test/convert/duplex.js+15 added-6 removed
21 unmodified lines22 assertPromiseError,23 getReadWriteSubprocess,24 } from '../helpers/convert.js';25 import {foobarString} from '../helpers/input.js';26+import {majorNodeVersion} from '../helpers/node-version.js';27 import {prematureClose, fullStdio, fullReadableStdio} from '../helpers/stdio.js';28 import {defaultHighWaterMark} from '../helpers/stream.js';29 30 setFixtureDirectory();117 unmodified lines148 149 const cause = new Error('test');150 outputStream.destroy(cause);151 152+ // Node 23 does not allow calling `stream.pipeline()` with an already errored stream153+ if (majorNodeVersion >= 23) {154+ outputStream.on('error', () => {});155+ stream.on('error', () => {});156+ await t.throwsAsync(pipeline(stream, outputStream), {code: 'ERR_STREAM_UNABLE_TO_PIPE'});157+ stream.end();158+ } else {151- await assertPromiseError(t, pipeline(inputStream, stream, outputStream), cause);152- await t.throwsAsync(finishedStream(stream));159+ await assertPromiseError(t, pipeline(inputStream, stream, outputStream), cause);160+ await t.throwsAsync(finishedStream(stream));161 154- await assertStreamError(t, inputStream, cause);155- const error = await assertStreamError(t, stream, cause);156- await assertStreamReadError(t, outputStream, cause);157- await assertSubprocessError(t, subprocess, {cause: error});162+ await assertStreamError(t, inputStream, cause);163+ const error = await assertStreamError(t, stream, cause);164+ await assertStreamReadError(t, outputStream, cause);165+ await assertSubprocessError(t, subprocess, {cause: error});166+ }167 });168 169 test('.duplex() can be piped to errored stream with Stream.pipeline()', async t => {170 const subprocess = execa('stdin-fail.js');34 unmodified linesmodified:test/convert/readable.js+13 added-8 removed
1 import {once} from 'node:events';2-import process from 'node:process';2 import {3 compose,4 Readable,5 Writable,21 unmodified lines27 getReadWriteSubprocess,28 } from '../helpers/convert.js';29 import {foobarString, foobarBuffer, foobarObject} from '../helpers/input.js';30 import {simpleFull} from '../helpers/lines.js';31+import {majorNodeVersion} from '../helpers/node-version.js';32 import {prematureClose, fullStdio} from '../helpers/stdio.js';33 import {outputObjectGenerator, getOutputsAsyncGenerator} from '../helpers/generator.js';34 import {defaultHighWaterMark, defaultObjectHighWaterMark} from '../helpers/stream.js';35 194 unmodified lines230 231 const cause = new Error('test');232 outputStream.destroy(cause);233 234+ // Node 23 does not allow calling `stream.pipeline()` with an already errored stream235+ if (majorNodeVersion >= 23) {236+ outputStream.on('error', () => {});237+ await t.throwsAsync(pipeline(stream, outputStream), {code: 'ERR_STREAM_UNABLE_TO_PIPE'});238+ } else {234- await assertPromiseError(t, pipeline(stream, outputStream), cause);235- await t.throwsAsync(finishedStream(stream));239+ await assertPromiseError(t, pipeline(stream, outputStream), cause);240+ await t.throwsAsync(finishedStream(stream));241 237- const error = await assertStreamError(t, stream, cause);238- await assertStreamReadError(t, outputStream, cause);239- await assertSubprocessError(t, subprocess, {cause: error});242+ const error = await assertStreamError(t, stream, cause);243+ await assertStreamReadError(t, outputStream, cause);244+ await assertSubprocessError(t, subprocess, {cause: error});245+ }246 });247 248 test('.readable() can be used with Stream.compose()', async t => {249 const subprocess = getReadableSubprocess();176 unmodified lines426 });427 428 // This feature does not work on Node 18.429 // @todo: remove after dropping support for Node 18.424-const majorVersion = Number(process.version.split('.')[0].slice(1));425-if (majorVersion >= 20) {430+if (majorNodeVersion >= 20) {431 const testHighWaterMark = async (t, methodName) => {432 const subprocess = execa('stdin.js');433 const stream = subprocess[methodName]();434 31 unmodified linesmodified:test/fixtures/graceful-ref.js+1 added-2 removed
1223465#!/usr/bin/env nodeimport {once} from 'node:events';import {getCancelSignal} from 'execa';
const cancelSignal = await getCancelSignal();once(cancelSignal, 'abort');cancelSignal.addEventListener('abort', () => {});added:test/helpers/node-version.js+3 added
123import {version} from 'node:process';
export const majorNodeVersion = Number(version.split('.')[0].slice(1));added:test/stdio/type-invalid.js+63 added
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263import test from 'ava';import {execa, execaSync} from '../../index.js';import {getStdio} from '../helpers/stdio.js';import {noopGenerator} from '../helpers/generator.js';import {generatorsMap} from '../helpers/map.js';import {setFixtureDirectory} from '../helpers/fixtures-directory.js';
setFixtureDirectory();
const testInvalidGenerator = (t, fdNumber, stdioOption, execaMethod) => { t.throws(() => { execaMethod('empty.js', getStdio(fdNumber, {...noopGenerator(), ...stdioOption})); }, {message: 'final' in stdioOption ? /must be a generator/ : /must be a generator, a Duplex stream or a web TransformStream/});};
test('Cannot use invalid "transform" with stdin', testInvalidGenerator, 0, {transform: true}, execa);test('Cannot use invalid "transform" with stdout', testInvalidGenerator, 1, {transform: true}, execa);test('Cannot use invalid "transform" with stderr', testInvalidGenerator, 2, {transform: true}, execa);test('Cannot use invalid "transform" with stdio[*]', testInvalidGenerator, 3, {transform: true}, execa);test('Cannot use invalid "final" with stdin', testInvalidGenerator, 0, {final: true}, execa);test('Cannot use invalid "final" with stdout', testInvalidGenerator, 1, {final: true}, execa);test('Cannot use invalid "final" with stderr', testInvalidGenerator, 2, {final: true}, execa);test('Cannot use invalid "final" with stdio[*]', testInvalidGenerator, 3, {final: true}, execa);test('Cannot use invalid "transform" with stdin, sync', testInvalidGenerator, 0, {transform: true}, execaSync);test('Cannot use invalid "transform" with stdout, sync', testInvalidGenerator, 1, {transform: true}, execaSync);test('Cannot use invalid "transform" with stderr, sync', testInvalidGenerator, 2, {transform: true}, execaSync);test('Cannot use invalid "transform" with stdio[*], sync', testInvalidGenerator, 3, {transform: true}, execaSync);test('Cannot use invalid "final" with stdin, sync', testInvalidGenerator, 0, {final: true}, execaSync);test('Cannot use invalid "final" with stdout, sync', testInvalidGenerator, 1, {final: true}, execaSync);test('Cannot use invalid "final" with stderr, sync', testInvalidGenerator, 2, {final: true}, execaSync);test('Cannot use invalid "final" with stdio[*], sync', testInvalidGenerator, 3, {final: true}, execaSync);
// eslint-disable-next-line max-paramsconst testInvalidBinary = (t, fdNumber, optionName, type, execaMethod) => { t.throws(() => { execaMethod('empty.js', getStdio(fdNumber, {...generatorsMap[type].uppercase(), [optionName]: 'true'})); }, {message: /a boolean/});};
test('Cannot use invalid "binary" with stdin', testInvalidBinary, 0, 'binary', 'generator', execa);test('Cannot use invalid "binary" with stdout', testInvalidBinary, 1, 'binary', 'generator', execa);test('Cannot use invalid "binary" with stderr', testInvalidBinary, 2, 'binary', 'generator', execa);test('Cannot use invalid "binary" with stdio[*]', testInvalidBinary, 3, 'binary', 'generator', execa);test('Cannot use invalid "objectMode" with stdin, generators', testInvalidBinary, 0, 'objectMode', 'generator', execa);test('Cannot use invalid "objectMode" with stdout, generators', testInvalidBinary, 1, 'objectMode', 'generator', execa);test('Cannot use invalid "objectMode" with stderr, generators', testInvalidBinary, 2, 'objectMode', 'generator', execa);test('Cannot use invalid "objectMode" with stdio[*], generators', testInvalidBinary, 3, 'objectMode', 'generator', execa);test('Cannot use invalid "binary" with stdin, sync', testInvalidBinary, 0, 'binary', 'generator', execaSync);test('Cannot use invalid "binary" with stdout, sync', testInvalidBinary, 1, 'binary', 'generator', execaSync);test('Cannot use invalid "binary" with stderr, sync', testInvalidBinary, 2, 'binary', 'generator', execaSync);test('Cannot use invalid "binary" with stdio[*], sync', testInvalidBinary, 3, 'binary', 'generator', execaSync);test('Cannot use invalid "objectMode" with stdin, generators, sync', testInvalidBinary, 0, 'objectMode', 'generator', execaSync);test('Cannot use invalid "objectMode" with stdout, generators, sync', testInvalidBinary, 1, 'objectMode', 'generator', execaSync);test('Cannot use invalid "objectMode" with stderr, generators, sync', testInvalidBinary, 2, 'objectMode', 'generator', execaSync);test('Cannot use invalid "objectMode" with stdio[*], generators, sync', testInvalidBinary, 3, 'objectMode', 'generator', execaSync);test('Cannot use invalid "objectMode" with stdin, duplexes', testInvalidBinary, 0, 'objectMode', 'duplex', execa);test('Cannot use invalid "objectMode" with stdout, duplexes', testInvalidBinary, 1, 'objectMode', 'duplex', execa);test('Cannot use invalid "objectMode" with stderr, duplexes', testInvalidBinary, 2, 'objectMode', 'duplex', execa);test('Cannot use invalid "objectMode" with stdio[*], duplexes', testInvalidBinary, 3, 'objectMode', 'duplex', execa);test('Cannot use invalid "objectMode" with stdin, webTransforms', testInvalidBinary, 0, 'objectMode', 'webTransform', execa);test('Cannot use invalid "objectMode" with stdout, webTransforms', testInvalidBinary, 1, 'objectMode', 'webTransform', execa);test('Cannot use invalid "objectMode" with stderr, webTransforms', testInvalidBinary, 2, 'objectMode', 'webTransform', execa);test('Cannot use invalid "objectMode" with stdio[*], webTransforms', testInvalidBinary, 3, 'objectMode', 'webTransform', execa);added:test/stdio/type-undefined.js+75 added
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475import test from 'ava';import {execa, execaSync} from '../../index.js';import {getStdio} from '../helpers/stdio.js';import {uppercaseGenerator} from '../helpers/generator.js';import {uppercaseBufferDuplex} from '../helpers/duplex.js';import {uppercaseBufferWebTransform} from '../helpers/web-transform.js';import {generatorsMap} from '../helpers/map.js';import {setFixtureDirectory} from '../helpers/fixtures-directory.js';
setFixtureDirectory();
// eslint-disable-next-line max-paramsconst testUndefinedOption = (t, fdNumber, optionName, type, optionValue) => { t.throws(() => { execa('empty.js', getStdio(fdNumber, {...generatorsMap[type].uppercase(), [optionName]: optionValue})); }, {message: /can only be defined when using a generator/});};
test('Cannot use "binary" with duplexes and stdin', testUndefinedOption, 0, 'binary', 'duplex', true);test('Cannot use "binary" with duplexes and stdout', testUndefinedOption, 1, 'binary', 'duplex', true);test('Cannot use "binary" with duplexes and stderr', testUndefinedOption, 2, 'binary', 'duplex', true);test('Cannot use "binary" with duplexes and stdio[*]', testUndefinedOption, 3, 'binary', 'duplex', true);test('Cannot use "final" with duplexes and stdin', testUndefinedOption, 0, 'final', 'duplex', uppercaseBufferDuplex().transform);test('Cannot use "final" with duplexes and stdout', testUndefinedOption, 1, 'final', 'duplex', uppercaseBufferDuplex().transform);test('Cannot use "final" with duplexes and stderr', testUndefinedOption, 2, 'final', 'duplex', uppercaseBufferDuplex().transform);test('Cannot use "final" with duplexes and stdio[*]', testUndefinedOption, 3, 'final', 'duplex', uppercaseBufferDuplex().transform);test('Cannot use "binary" with webTransforms and stdin', testUndefinedOption, 0, 'binary', 'webTransform', true);test('Cannot use "binary" with webTransforms and stdout', testUndefinedOption, 1, 'binary', 'webTransform', true);test('Cannot use "binary" with webTransforms and stderr', testUndefinedOption, 2, 'binary', 'webTransform', true);test('Cannot use "binary" with webTransforms and stdio[*]', testUndefinedOption, 3, 'binary', 'webTransform', true);test('Cannot use "final" with webTransforms and stdin', testUndefinedOption, 0, 'final', 'webTransform', uppercaseBufferWebTransform().transform);test('Cannot use "final" with webTransforms and stdout', testUndefinedOption, 1, 'final', 'webTransform', uppercaseBufferWebTransform().transform);test('Cannot use "final" with webTransforms and stderr', testUndefinedOption, 2, 'final', 'webTransform', uppercaseBufferWebTransform().transform);test('Cannot use "final" with webTransforms and stdio[*]', testUndefinedOption, 3, 'final', 'webTransform', uppercaseBufferWebTransform().transform);
const testUndefinedFinal = (t, fdNumber, type, useTransform) => { t.throws(() => { execa('empty.js', getStdio(fdNumber, { transform: useTransform ? uppercaseGenerator().transform : undefined, final: generatorsMap[type].uppercase().transform, })); }, {message: type === 'duplex' ? /must not be a Duplex/ : /must not be a web TransformStream/});};
test('Cannot use "final" with duplexes and stdin, without transform', testUndefinedFinal, 0, 'duplex', false);test('Cannot use "final" with duplexes and stdout, without transform', testUndefinedFinal, 1, 'duplex', false);test('Cannot use "final" with duplexes and stderr, without transform', testUndefinedFinal, 2, 'duplex', false);test('Cannot use "final" with duplexes and stdio[*], without transform', testUndefinedFinal, 3, 'duplex', false);test('Cannot use "final" with duplexes and stdin, with transform', testUndefinedFinal, 0, 'duplex', true);test('Cannot use "final" with duplexes and stdout, with transform', testUndefinedFinal, 1, 'duplex', true);test('Cannot use "final" with duplexes and stderr, with transform', testUndefinedFinal, 2, 'duplex', true);test('Cannot use "final" with duplexes and stdio[*], with transform', testUndefinedFinal, 3, 'duplex', true);test('Cannot use "final" with webTransforms and stdin, without transform', testUndefinedFinal, 0, 'webTransform', false);test('Cannot use "final" with webTransforms and stdout, without transform', testUndefinedFinal, 1, 'webTransform', false);test('Cannot use "final" with webTransforms and stderr, without transform', testUndefinedFinal, 2, 'webTransform', false);test('Cannot use "final" with webTransforms and stdio[*], without transform', testUndefinedFinal, 3, 'webTransform', false);test('Cannot use "final" with webTransforms and stdin, with transform', testUndefinedFinal, 0, 'webTransform', true);test('Cannot use "final" with webTransforms and stdout, with transform', testUndefinedFinal, 1, 'webTransform', true);test('Cannot use "final" with webTransforms and stderr, with transform', testUndefinedFinal, 2, 'webTransform', true);test('Cannot use "final" with webTransforms and stdio[*], with transform', testUndefinedFinal, 3, 'webTransform', true);
const testSyncMethodsDuplex = (t, fdNumber, type) => { t.throws(() => { execaSync('empty.js', getStdio(fdNumber, generatorsMap[type].uppercase())); }, {message: type === 'duplex' ? /cannot be a Duplex stream/ : /cannot be a web TransformStream/});};
test('Cannot use duplexes with sync methods and stdin', testSyncMethodsDuplex, 0, 'duplex');test('Cannot use duplexes with sync methods and stdout', testSyncMethodsDuplex, 1, 'duplex');test('Cannot use duplexes with sync methods and stderr', testSyncMethodsDuplex, 2, 'duplex');test('Cannot use duplexes with sync methods and stdio[*]', testSyncMethodsDuplex, 3, 'duplex');test('Cannot use webTransforms with sync methods and stdin', testSyncMethodsDuplex, 0, 'webTransform');test('Cannot use webTransforms with sync methods and stdout', testSyncMethodsDuplex, 1, 'webTransform');test('Cannot use webTransforms with sync methods and stderr', testSyncMethodsDuplex, 2, 'webTransform');test('Cannot use webTransforms with sync methods and stdio[*]', testSyncMethodsDuplex, 3, 'webTransform');deleted:test/stdio/type.js-130 removed
1-import test from 'ava';2-import {execa, execaSync} from '../../index.js';3-import {getStdio} from '../helpers/stdio.js';4-import {noopGenerator, uppercaseGenerator} from '../helpers/generator.js';5-import {uppercaseBufferDuplex} from '../helpers/duplex.js';6-import {uppercaseBufferWebTransform} from '../helpers/web-transform.js';7-import {generatorsMap} from '../helpers/map.js';8-import {setFixtureDirectory} from '../helpers/fixtures-directory.js';9-10-setFixtureDirectory();11-12-const testInvalidGenerator = (t, fdNumber, stdioOption, execaMethod) => {13- t.throws(() => {14- execaMethod('empty.js', getStdio(fdNumber, {...noopGenerator(), ...stdioOption}));15- }, {message: 'final' in stdioOption ? /must be a generator/ : /must be a generator, a Duplex stream or a web TransformStream/});16-};17-18-test('Cannot use invalid "transform" with stdin', testInvalidGenerator, 0, {transform: true}, execa);19-test('Cannot use invalid "transform" with stdout', testInvalidGenerator, 1, {transform: true}, execa);20-test('Cannot use invalid "transform" with stderr', testInvalidGenerator, 2, {transform: true}, execa);21-test('Cannot use invalid "transform" with stdio[*]', testInvalidGenerator, 3, {transform: true}, execa);22-test('Cannot use invalid "final" with stdin', testInvalidGenerator, 0, {final: true}, execa);23-test('Cannot use invalid "final" with stdout', testInvalidGenerator, 1, {final: true}, execa);24-test('Cannot use invalid "final" with stderr', testInvalidGenerator, 2, {final: true}, execa);25-test('Cannot use invalid "final" with stdio[*]', testInvalidGenerator, 3, {final: true}, execa);26-test('Cannot use invalid "transform" with stdin, sync', testInvalidGenerator, 0, {transform: true}, execaSync);27-test('Cannot use invalid "transform" with stdout, sync', testInvalidGenerator, 1, {transform: true}, execaSync);28-test('Cannot use invalid "transform" with stderr, sync', testInvalidGenerator, 2, {transform: true}, execaSync);29-test('Cannot use invalid "transform" with stdio[*], sync', testInvalidGenerator, 3, {transform: true}, execaSync);30-test('Cannot use invalid "final" with stdin, sync', testInvalidGenerator, 0, {final: true}, execaSync);31-test('Cannot use invalid "final" with stdout, sync', testInvalidGenerator, 1, {final: true}, execaSync);32-test('Cannot use invalid "final" with stderr, sync', testInvalidGenerator, 2, {final: true}, execaSync);33-test('Cannot use invalid "final" with stdio[*], sync', testInvalidGenerator, 3, {final: true}, execaSync);34-35-// eslint-disable-next-line max-params36-const testInvalidBinary = (t, fdNumber, optionName, type, execaMethod) => {37- t.throws(() => {38- execaMethod('empty.js', getStdio(fdNumber, {...generatorsMap[type].uppercase(), [optionName]: 'true'}));39- }, {message: /a boolean/});40-};41-42-test('Cannot use invalid "binary" with stdin', testInvalidBinary, 0, 'binary', 'generator', execa);43-test('Cannot use invalid "binary" with stdout', testInvalidBinary, 1, 'binary', 'generator', execa);44-test('Cannot use invalid "binary" with stderr', testInvalidBinary, 2, 'binary', 'generator', execa);45-test('Cannot use invalid "binary" with stdio[*]', testInvalidBinary, 3, 'binary', 'generator', execa);46-test('Cannot use invalid "objectMode" with stdin, generators', testInvalidBinary, 0, 'objectMode', 'generator', execa);47-test('Cannot use invalid "objectMode" with stdout, generators', testInvalidBinary, 1, 'objectMode', 'generator', execa);48-test('Cannot use invalid "objectMode" with stderr, generators', testInvalidBinary, 2, 'objectMode', 'generator', execa);49-test('Cannot use invalid "objectMode" with stdio[*], generators', testInvalidBinary, 3, 'objectMode', 'generator', execa);50-test('Cannot use invalid "binary" with stdin, sync', testInvalidBinary, 0, 'binary', 'generator', execaSync);51-test('Cannot use invalid "binary" with stdout, sync', testInvalidBinary, 1, 'binary', 'generator', execaSync);52-test('Cannot use invalid "binary" with stderr, sync', testInvalidBinary, 2, 'binary', 'generator', execaSync);53-test('Cannot use invalid "binary" with stdio[*], sync', testInvalidBinary, 3, 'binary', 'generator', execaSync);54-test('Cannot use invalid "objectMode" with stdin, generators, sync', testInvalidBinary, 0, 'objectMode', 'generator', execaSync);55-test('Cannot use invalid "objectMode" with stdout, generators, sync', testInvalidBinary, 1, 'objectMode', 'generator', execaSync);56-test('Cannot use invalid "objectMode" with stderr, generators, sync', testInvalidBinary, 2, 'objectMode', 'generator', execaSync);57-test('Cannot use invalid "objectMode" with stdio[*], generators, sync', testInvalidBinary, 3, 'objectMode', 'generator', execaSync);58-test('Cannot use invalid "objectMode" with stdin, duplexes', testInvalidBinary, 0, 'objectMode', 'duplex', execa);59-test('Cannot use invalid "objectMode" with stdout, duplexes', testInvalidBinary, 1, 'objectMode', 'duplex', execa);60-test('Cannot use invalid "objectMode" with stderr, duplexes', testInvalidBinary, 2, 'objectMode', 'duplex', execa);61-test('Cannot use invalid "objectMode" with stdio[*], duplexes', testInvalidBinary, 3, 'objectMode', 'duplex', execa);62-test('Cannot use invalid "objectMode" with stdin, webTransforms', testInvalidBinary, 0, 'objectMode', 'webTransform', execa);63-test('Cannot use invalid "objectMode" with stdout, webTransforms', testInvalidBinary, 1, 'objectMode', 'webTransform', execa);64-test('Cannot use invalid "objectMode" with stderr, webTransforms', testInvalidBinary, 2, 'objectMode', 'webTransform', execa);65-test('Cannot use invalid "objectMode" with stdio[*], webTransforms', testInvalidBinary, 3, 'objectMode', 'webTransform', execa);66-67-// eslint-disable-next-line max-params68-const testUndefinedOption = (t, fdNumber, optionName, type, optionValue) => {69- t.throws(() => {70- execa('empty.js', getStdio(fdNumber, {...generatorsMap[type].uppercase(), [optionName]: optionValue}));71- }, {message: /can only be defined when using a generator/});72-};73-74-test('Cannot use "binary" with duplexes and stdin', testUndefinedOption, 0, 'binary', 'duplex', true);75-test('Cannot use "binary" with duplexes and stdout', testUndefinedOption, 1, 'binary', 'duplex', true);76-test('Cannot use "binary" with duplexes and stderr', testUndefinedOption, 2, 'binary', 'duplex', true);77-test('Cannot use "binary" with duplexes and stdio[*]', testUndefinedOption, 3, 'binary', 'duplex', true);78-test('Cannot use "final" with duplexes and stdin', testUndefinedOption, 0, 'final', 'duplex', uppercaseBufferDuplex().transform);79-test('Cannot use "final" with duplexes and stdout', testUndefinedOption, 1, 'final', 'duplex', uppercaseBufferDuplex().transform);80-test('Cannot use "final" with duplexes and stderr', testUndefinedOption, 2, 'final', 'duplex', uppercaseBufferDuplex().transform);81-test('Cannot use "final" with duplexes and stdio[*]', testUndefinedOption, 3, 'final', 'duplex', uppercaseBufferDuplex().transform);82-test('Cannot use "binary" with webTransforms and stdin', testUndefinedOption, 0, 'binary', 'webTransform', true);83-test('Cannot use "binary" with webTransforms and stdout', testUndefinedOption, 1, 'binary', 'webTransform', true);84-test('Cannot use "binary" with webTransforms and stderr', testUndefinedOption, 2, 'binary', 'webTransform', true);85-test('Cannot use "binary" with webTransforms and stdio[*]', testUndefinedOption, 3, 'binary', 'webTransform', true);86-test('Cannot use "final" with webTransforms and stdin', testUndefinedOption, 0, 'final', 'webTransform', uppercaseBufferWebTransform().transform);87-test('Cannot use "final" with webTransforms and stdout', testUndefinedOption, 1, 'final', 'webTransform', uppercaseBufferWebTransform().transform);88-test('Cannot use "final" with webTransforms and stderr', testUndefinedOption, 2, 'final', 'webTransform', uppercaseBufferWebTransform().transform);89-test('Cannot use "final" with webTransforms and stdio[*]', testUndefinedOption, 3, 'final', 'webTransform', uppercaseBufferWebTransform().transform);90-91-const testUndefinedFinal = (t, fdNumber, type, useTransform) => {92- t.throws(() => {93- execa('empty.js', getStdio(fdNumber, {94- transform: useTransform ? uppercaseGenerator().transform : undefined,95- final: generatorsMap[type].uppercase().transform,96- }));97- }, {message: type === 'duplex' ? /must not be a Duplex/ : /must not be a web TransformStream/});98-};99-100-test('Cannot use "final" with duplexes and stdin, without transform', testUndefinedFinal, 0, 'duplex', false);101-test('Cannot use "final" with duplexes and stdout, without transform', testUndefinedFinal, 1, 'duplex', false);102-test('Cannot use "final" with duplexes and stderr, without transform', testUndefinedFinal, 2, 'duplex', false);103-test('Cannot use "final" with duplexes and stdio[*], without transform', testUndefinedFinal, 3, 'duplex', false);104-test('Cannot use "final" with duplexes and stdin, with transform', testUndefinedFinal, 0, 'duplex', true);105-test('Cannot use "final" with duplexes and stdout, with transform', testUndefinedFinal, 1, 'duplex', true);106-test('Cannot use "final" with duplexes and stderr, with transform', testUndefinedFinal, 2, 'duplex', true);107-test('Cannot use "final" with duplexes and stdio[*], with transform', testUndefinedFinal, 3, 'duplex', true);108-test('Cannot use "final" with webTransforms and stdin, without transform', testUndefinedFinal, 0, 'webTransform', false);109-test('Cannot use "final" with webTransforms and stdout, without transform', testUndefinedFinal, 1, 'webTransform', false);110-test('Cannot use "final" with webTransforms and stderr, without transform', testUndefinedFinal, 2, 'webTransform', false);111-test('Cannot use "final" with webTransforms and stdio[*], without transform', testUndefinedFinal, 3, 'webTransform', false);112-test('Cannot use "final" with webTransforms and stdin, with transform', testUndefinedFinal, 0, 'webTransform', true);113-test('Cannot use "final" with webTransforms and stdout, with transform', testUndefinedFinal, 1, 'webTransform', true);114-test('Cannot use "final" with webTransforms and stderr, with transform', testUndefinedFinal, 2, 'webTransform', true);115-test('Cannot use "final" with webTransforms and stdio[*], with transform', testUndefinedFinal, 3, 'webTransform', true);116-117-const testSyncMethodsDuplex = (t, fdNumber, type) => {118- t.throws(() => {119- execaSync('empty.js', getStdio(fdNumber, generatorsMap[type].uppercase()));120- }, {message: type === 'duplex' ? /cannot be a Duplex stream/ : /cannot be a web TransformStream/});121-};122-123-test('Cannot use duplexes with sync methods and stdin', testSyncMethodsDuplex, 0, 'duplex');124-test('Cannot use duplexes with sync methods and stdout', testSyncMethodsDuplex, 1, 'duplex');125-test('Cannot use duplexes with sync methods and stderr', testSyncMethodsDuplex, 2, 'duplex');126-test('Cannot use duplexes with sync methods and stdio[*]', testSyncMethodsDuplex, 3, 'duplex');127-test('Cannot use webTransforms with sync methods and stdin', testSyncMethodsDuplex, 0, 'webTransform');128-test('Cannot use webTransforms with sync methods and stdout', testSyncMethodsDuplex, 1, 'webTransform');129-test('Cannot use webTransforms with sync methods and stderr', testSyncMethodsDuplex, 2, 'webTransform');130-test('Cannot use webTransforms with sync methods and stdio[*]', testSyncMethodsDuplex, 3, 'webTransform');modified:test/terminate/kill-signal.js+3 added-4 removed
1 import {once} from 'node:events';2-import {platform, version} from 'node:process';2+import {platform} from 'node:process';3 import {constants} from 'node:os';4 import {setImmediate} from 'node:timers/promises';5 import test from 'ava';6 import {execa, execaSync} from '../../index.js';7 import {setFixtureDirectory} from '../helpers/fixtures-directory.js';8+import {majorNodeVersion} from '../helpers/node-version.js';9 10 setFixtureDirectory();11 12 const isWindows = platform === 'win32';12-const majorNodeVersion = Number(version.split('.')[0].slice(1));13 14 const testKillSignal = async (t, killSignal) => {15 const {isTerminated, signal} = await t.throwsAsync(execa('forever.js', {killSignal, timeout: 1}));16 t.true(isTerminated);43 unmodified lines60 subprocess.kill();61 subprocess.kill();62 63 const {exitCode, isTerminated, signal, code} = await t.throwsAsync(subprocess);64-64 // On Windows, calling `subprocess.kill()` twice emits an `error` event on the subprocess.65 // This does not happen when passing an `error` argument, nor when passing a non-terminating signal.66 // There is no easy way to make this cross-platform, so we document the difference here.68- if (isWindows && majorNodeVersion >= 22) {67+ if (isWindows && majorNodeVersion === 22) {68 t.is(exitCode, undefined);69 t.false(isTerminated);70 t.is(signal, undefined);71 t.is(code, 'EPERM');83 unmodified lines