Skip to content

Commit

Permalink
Run CI tests on Node 23
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Oct 27, 2024
1 parent 4d1e55a commit 68e667f
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
fail-fast: false
matrix:
node-version:
- 22
- 23
- 18
os:
- ubuntu
Expand All @@ -31,7 +31,7 @@ jobs:
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
Expand Down
23 changes: 16 additions & 7 deletions test/convert/duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
getReadWriteSubprocess,
} from '../helpers/convert.js';
import {foobarString} from '../helpers/input.js';
import {majorNodeVersion} from '../helpers/node-version.js';
import {prematureClose, fullStdio, fullReadableStdio} from '../helpers/stdio.js';
import {defaultHighWaterMark} from '../helpers/stream.js';

Expand Down Expand Up @@ -148,13 +149,21 @@ test('.duplex() can pipe to errored stream with Stream.pipeline()', async t => {
const cause = new Error('test');
outputStream.destroy(cause);

await assertPromiseError(t, pipeline(inputStream, stream, outputStream), cause);
await t.throwsAsync(finishedStream(stream));

await assertStreamError(t, inputStream, cause);
const error = await assertStreamError(t, stream, cause);
await assertStreamReadError(t, outputStream, cause);
await assertSubprocessError(t, subprocess, {cause: error});
// Node 23 does not allow calling `stream.pipeline()` with an already errored stream
if (majorNodeVersion >= 23) {
outputStream.on('error', () => {});
stream.on('error', () => {});
await t.throwsAsync(pipeline(stream, outputStream), {code: 'ERR_STREAM_UNABLE_TO_PIPE'});
stream.end();
} else {
await assertPromiseError(t, pipeline(inputStream, stream, outputStream), cause);
await t.throwsAsync(finishedStream(stream));

await assertStreamError(t, inputStream, cause);
const error = await assertStreamError(t, stream, cause);
await assertStreamReadError(t, outputStream, cause);
await assertSubprocessError(t, subprocess, {cause: error});
}
});

test('.duplex() can be piped to errored stream with Stream.pipeline()', async t => {
Expand Down
19 changes: 13 additions & 6 deletions test/convert/readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
} from '../helpers/convert.js';
import {foobarString, foobarBuffer, foobarObject} from '../helpers/input.js';
import {simpleFull} from '../helpers/lines.js';
import {majorNodeVersion} from '../helpers/node-version.js';
import {prematureClose, fullStdio} from '../helpers/stdio.js';
import {outputObjectGenerator, getOutputsAsyncGenerator} from '../helpers/generator.js';
import {defaultHighWaterMark, defaultObjectHighWaterMark} from '../helpers/stream.js';
Expand Down Expand Up @@ -231,12 +232,18 @@ test('.readable() can pipe to errored stream with Stream.pipeline()', async t =>
const cause = new Error('test');
outputStream.destroy(cause);

await assertPromiseError(t, pipeline(stream, outputStream), cause);
await t.throwsAsync(finishedStream(stream));

const error = await assertStreamError(t, stream, cause);
await assertStreamReadError(t, outputStream, cause);
await assertSubprocessError(t, subprocess, {cause: error});
// Node 23 does not allow calling `stream.pipeline()` with an already errored stream
if (majorNodeVersion >= 23) {
outputStream.on('error', () => {});
await t.throwsAsync(pipeline(stream, outputStream), {code: 'ERR_STREAM_UNABLE_TO_PIPE'});
} else {
await assertPromiseError(t, pipeline(stream, outputStream), cause);
await t.throwsAsync(finishedStream(stream));

const error = await assertStreamError(t, stream, cause);
await assertStreamReadError(t, outputStream, cause);
await assertSubprocessError(t, subprocess, {cause: error});
}
});

test('.readable() can be used with Stream.compose()', async t => {
Expand Down
3 changes: 1 addition & 2 deletions test/fixtures/graceful-ref.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env node
import {once} from 'node:events';
import {getCancelSignal} from 'execa';

const cancelSignal = await getCancelSignal();
once(cancelSignal, 'abort');
cancelSignal.addEventListener('abort', () => {});
3 changes: 3 additions & 0 deletions test/helpers/node-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {version} from 'node:process';

export const majorNodeVersion = Number(version.split('.')[0].slice(1));
4 changes: 2 additions & 2 deletions test/terminate/kill-signal.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {once} from 'node:events';
import {platform, version} from 'node:process';
import {platform} from 'node:process';
import {constants} from 'node:os';
import {setImmediate} from 'node:timers/promises';
import test from 'ava';
import {execa, execaSync} from '../../index.js';
import {setFixtureDirectory} from '../helpers/fixtures-directory.js';
import {majorNodeVersion} from '../helpers/node-version.js';

setFixtureDirectory();

const isWindows = platform === 'win32';
const majorNodeVersion = Number(version.split('.')[0].slice(1));

const testKillSignal = async (t, killSignal) => {
const {isTerminated, signal} = await t.throwsAsync(execa('forever.js', {killSignal, timeout: 1}));
Expand Down

0 comments on commit 68e667f

Please sign in to comment.