Skip to content
Myr

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

9 files+175 added−152 removed

modified:.github/workflows/main.yml+2 added-2 removed
modified:test/convert/duplex.js+15 added-6 removed
21 unmodified lines
22 assertPromiseError,23 getReadWriteSubprocess,24} from '../helpers/convert.js';25import {foobarString} from '../helpers/input.js';26import {majorNodeVersion} from '../helpers/node-version.js';27import {prematureClose, fullStdio, fullReadableStdio} from '../helpers/stdio.js';28import {defaultHighWaterMark} from '../helpers/stream.js';2930setFixtureDirectory();
117 unmodified lines
148149 const cause = new Error('test');150 outputStream.destroy(cause);151152 // 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));161154 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});168169test('.duplex() can be piped to errored stream with Stream.pipeline()', async t => {170 const subprocess = execa('stdin-fail.js');
34 unmodified lines
modified:test/convert/readable.js+13 added-8 removed
1import {once} from 'node:events';2import process from 'node:process';2import {3 compose,4 Readable,5 Writable,
21 unmodified lines
27 getReadWriteSubprocess,28} from '../helpers/convert.js';29import {foobarString, foobarBuffer, foobarObject} from '../helpers/input.js';30import {simpleFull} from '../helpers/lines.js';31import {majorNodeVersion} from '../helpers/node-version.js';32import {prematureClose, fullStdio} from '../helpers/stdio.js';33import {outputObjectGenerator, getOutputsAsyncGenerator} from '../helpers/generator.js';34import {defaultHighWaterMark, defaultObjectHighWaterMark} from '../helpers/stream.js';35
194 unmodified lines
230231 const cause = new Error('test');232 outputStream.destroy(cause);233234 // 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));241237 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});247248test('.readable() can be used with Stream.compose()', async t => {249 const subprocess = getReadableSubprocess();
176 unmodified lines
426});427428// This feature does not work on Node 18.429// @todo: remove after dropping support for Node 18.424const majorVersion = Number(process.version.split('.')[0].slice(1));425if (majorVersion >= 20) {430if (majorNodeVersion >= 20) {431 const testHighWaterMark = async (t, methodName) => {432 const subprocess = execa('stdin.js');433 const stream = subprocess[methodName]();434
31 unmodified lines
modified:test/fixtures/graceful-ref.js+1 added-2 removed
added:test/helpers/node-version.js+3 added
added:test/stdio/type-invalid.js+63 added
added:test/stdio/type-undefined.js+75 added
deleted:test/stdio/type.js-130 removed
1import test from 'ava';2import {execa, execaSync} from '../../index.js';3import {getStdio} from '../helpers/stdio.js';4import {noopGenerator, uppercaseGenerator} from '../helpers/generator.js';5import {uppercaseBufferDuplex} from '../helpers/duplex.js';6import {uppercaseBufferWebTransform} from '../helpers/web-transform.js';7import {generatorsMap} from '../helpers/map.js';8import {setFixtureDirectory} from '../helpers/fixtures-directory.js';910setFixtureDirectory();1112const 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};1718test('Cannot use invalid "transform" with stdin', testInvalidGenerator, 0, {transform: true}, execa);19test('Cannot use invalid "transform" with stdout', testInvalidGenerator, 1, {transform: true}, execa);20test('Cannot use invalid "transform" with stderr', testInvalidGenerator, 2, {transform: true}, execa);21test('Cannot use invalid "transform" with stdio[*]', testInvalidGenerator, 3, {transform: true}, execa);22test('Cannot use invalid "final" with stdin', testInvalidGenerator, 0, {final: true}, execa);23test('Cannot use invalid "final" with stdout', testInvalidGenerator, 1, {final: true}, execa);24test('Cannot use invalid "final" with stderr', testInvalidGenerator, 2, {final: true}, execa);25test('Cannot use invalid "final" with stdio[*]', testInvalidGenerator, 3, {final: true}, execa);26test('Cannot use invalid "transform" with stdin, sync', testInvalidGenerator, 0, {transform: true}, execaSync);27test('Cannot use invalid "transform" with stdout, sync', testInvalidGenerator, 1, {transform: true}, execaSync);28test('Cannot use invalid "transform" with stderr, sync', testInvalidGenerator, 2, {transform: true}, execaSync);29test('Cannot use invalid "transform" with stdio[*], sync', testInvalidGenerator, 3, {transform: true}, execaSync);30test('Cannot use invalid "final" with stdin, sync', testInvalidGenerator, 0, {final: true}, execaSync);31test('Cannot use invalid "final" with stdout, sync', testInvalidGenerator, 1, {final: true}, execaSync);32test('Cannot use invalid "final" with stderr, sync', testInvalidGenerator, 2, {final: true}, execaSync);33test('Cannot use invalid "final" with stdio[*], sync', testInvalidGenerator, 3, {final: true}, execaSync);3435// eslint-disable-next-line max-params36const 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};4142test('Cannot use invalid "binary" with stdin', testInvalidBinary, 0, 'binary', 'generator', execa);43test('Cannot use invalid "binary" with stdout', testInvalidBinary, 1, 'binary', 'generator', execa);44test('Cannot use invalid "binary" with stderr', testInvalidBinary, 2, 'binary', 'generator', execa);45test('Cannot use invalid "binary" with stdio[*]', testInvalidBinary, 3, 'binary', 'generator', execa);46test('Cannot use invalid "objectMode" with stdin, generators', testInvalidBinary, 0, 'objectMode', 'generator', execa);47test('Cannot use invalid "objectMode" with stdout, generators', testInvalidBinary, 1, 'objectMode', 'generator', execa);48test('Cannot use invalid "objectMode" with stderr, generators', testInvalidBinary, 2, 'objectMode', 'generator', execa);49test('Cannot use invalid "objectMode" with stdio[*], generators', testInvalidBinary, 3, 'objectMode', 'generator', execa);50test('Cannot use invalid "binary" with stdin, sync', testInvalidBinary, 0, 'binary', 'generator', execaSync);51test('Cannot use invalid "binary" with stdout, sync', testInvalidBinary, 1, 'binary', 'generator', execaSync);52test('Cannot use invalid "binary" with stderr, sync', testInvalidBinary, 2, 'binary', 'generator', execaSync);53test('Cannot use invalid "binary" with stdio[*], sync', testInvalidBinary, 3, 'binary', 'generator', execaSync);54test('Cannot use invalid "objectMode" with stdin, generators, sync', testInvalidBinary, 0, 'objectMode', 'generator', execaSync);55test('Cannot use invalid "objectMode" with stdout, generators, sync', testInvalidBinary, 1, 'objectMode', 'generator', execaSync);56test('Cannot use invalid "objectMode" with stderr, generators, sync', testInvalidBinary, 2, 'objectMode', 'generator', execaSync);57test('Cannot use invalid "objectMode" with stdio[*], generators, sync', testInvalidBinary, 3, 'objectMode', 'generator', execaSync);58test('Cannot use invalid "objectMode" with stdin, duplexes', testInvalidBinary, 0, 'objectMode', 'duplex', execa);59test('Cannot use invalid "objectMode" with stdout, duplexes', testInvalidBinary, 1, 'objectMode', 'duplex', execa);60test('Cannot use invalid "objectMode" with stderr, duplexes', testInvalidBinary, 2, 'objectMode', 'duplex', execa);61test('Cannot use invalid "objectMode" with stdio[*], duplexes', testInvalidBinary, 3, 'objectMode', 'duplex', execa);62test('Cannot use invalid "objectMode" with stdin, webTransforms', testInvalidBinary, 0, 'objectMode', 'webTransform', execa);63test('Cannot use invalid "objectMode" with stdout, webTransforms', testInvalidBinary, 1, 'objectMode', 'webTransform', execa);64test('Cannot use invalid "objectMode" with stderr, webTransforms', testInvalidBinary, 2, 'objectMode', 'webTransform', execa);65test('Cannot use invalid "objectMode" with stdio[*], webTransforms', testInvalidBinary, 3, 'objectMode', 'webTransform', execa);6667// eslint-disable-next-line max-params68const 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};7374test('Cannot use "binary" with duplexes and stdin', testUndefinedOption, 0, 'binary', 'duplex', true);75test('Cannot use "binary" with duplexes and stdout', testUndefinedOption, 1, 'binary', 'duplex', true);76test('Cannot use "binary" with duplexes and stderr', testUndefinedOption, 2, 'binary', 'duplex', true);77test('Cannot use "binary" with duplexes and stdio[*]', testUndefinedOption, 3, 'binary', 'duplex', true);78test('Cannot use "final" with duplexes and stdin', testUndefinedOption, 0, 'final', 'duplex', uppercaseBufferDuplex().transform);79test('Cannot use "final" with duplexes and stdout', testUndefinedOption, 1, 'final', 'duplex', uppercaseBufferDuplex().transform);80test('Cannot use "final" with duplexes and stderr', testUndefinedOption, 2, 'final', 'duplex', uppercaseBufferDuplex().transform);81test('Cannot use "final" with duplexes and stdio[*]', testUndefinedOption, 3, 'final', 'duplex', uppercaseBufferDuplex().transform);82test('Cannot use "binary" with webTransforms and stdin', testUndefinedOption, 0, 'binary', 'webTransform', true);83test('Cannot use "binary" with webTransforms and stdout', testUndefinedOption, 1, 'binary', 'webTransform', true);84test('Cannot use "binary" with webTransforms and stderr', testUndefinedOption, 2, 'binary', 'webTransform', true);85test('Cannot use "binary" with webTransforms and stdio[*]', testUndefinedOption, 3, 'binary', 'webTransform', true);86test('Cannot use "final" with webTransforms and stdin', testUndefinedOption, 0, 'final', 'webTransform', uppercaseBufferWebTransform().transform);87test('Cannot use "final" with webTransforms and stdout', testUndefinedOption, 1, 'final', 'webTransform', uppercaseBufferWebTransform().transform);88test('Cannot use "final" with webTransforms and stderr', testUndefinedOption, 2, 'final', 'webTransform', uppercaseBufferWebTransform().transform);89test('Cannot use "final" with webTransforms and stdio[*]', testUndefinedOption, 3, 'final', 'webTransform', uppercaseBufferWebTransform().transform);9091const 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};99100test('Cannot use "final" with duplexes and stdin, without transform', testUndefinedFinal, 0, 'duplex', false);101test('Cannot use "final" with duplexes and stdout, without transform', testUndefinedFinal, 1, 'duplex', false);102test('Cannot use "final" with duplexes and stderr, without transform', testUndefinedFinal, 2, 'duplex', false);103test('Cannot use "final" with duplexes and stdio[*], without transform', testUndefinedFinal, 3, 'duplex', false);104test('Cannot use "final" with duplexes and stdin, with transform', testUndefinedFinal, 0, 'duplex', true);105test('Cannot use "final" with duplexes and stdout, with transform', testUndefinedFinal, 1, 'duplex', true);106test('Cannot use "final" with duplexes and stderr, with transform', testUndefinedFinal, 2, 'duplex', true);107test('Cannot use "final" with duplexes and stdio[*], with transform', testUndefinedFinal, 3, 'duplex', true);108test('Cannot use "final" with webTransforms and stdin, without transform', testUndefinedFinal, 0, 'webTransform', false);109test('Cannot use "final" with webTransforms and stdout, without transform', testUndefinedFinal, 1, 'webTransform', false);110test('Cannot use "final" with webTransforms and stderr, without transform', testUndefinedFinal, 2, 'webTransform', false);111test('Cannot use "final" with webTransforms and stdio[*], without transform', testUndefinedFinal, 3, 'webTransform', false);112test('Cannot use "final" with webTransforms and stdin, with transform', testUndefinedFinal, 0, 'webTransform', true);113test('Cannot use "final" with webTransforms and stdout, with transform', testUndefinedFinal, 1, 'webTransform', true);114test('Cannot use "final" with webTransforms and stderr, with transform', testUndefinedFinal, 2, 'webTransform', true);115test('Cannot use "final" with webTransforms and stdio[*], with transform', testUndefinedFinal, 3, 'webTransform', true);116117const 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};122123test('Cannot use duplexes with sync methods and stdin', testSyncMethodsDuplex, 0, 'duplex');124test('Cannot use duplexes with sync methods and stdout', testSyncMethodsDuplex, 1, 'duplex');125test('Cannot use duplexes with sync methods and stderr', testSyncMethodsDuplex, 2, 'duplex');126test('Cannot use duplexes with sync methods and stdio[*]', testSyncMethodsDuplex, 3, 'duplex');127test('Cannot use webTransforms with sync methods and stdin', testSyncMethodsDuplex, 0, 'webTransform');128test('Cannot use webTransforms with sync methods and stdout', testSyncMethodsDuplex, 1, 'webTransform');129test('Cannot use webTransforms with sync methods and stderr', testSyncMethodsDuplex, 2, 'webTransform');130test('Cannot use webTransforms with sync methods and stdio[*]', testSyncMethodsDuplex, 3, 'webTransform');
modified:test/terminate/kill-signal.js+3 added-4 removed
1import {once} from 'node:events';2import {platform, version} from 'node:process';2import {platform} from 'node:process';3import {constants} from 'node:os';4import {setImmediate} from 'node:timers/promises';5import test from 'ava';6import {execa, execaSync} from '../../index.js';7import {setFixtureDirectory} from '../helpers/fixtures-directory.js';8import {majorNodeVersion} from '../helpers/node-version.js';910setFixtureDirectory();1112const isWindows = platform === 'win32';12const majorNodeVersion = Number(version.split('.')[0].slice(1));1314const testKillSignal = async (t, killSignal) => {15 const {isTerminated, signal} = await t.throwsAsync(execa('forever.js', {killSignal, timeout: 1}));16 t.true(isTerminated);
43 unmodified lines
60 subprocess.kill();61 subprocess.kill();6263 const {exitCode, isTerminated, signal, code} = await t.throwsAsync(subprocess);6464 // 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