From de094a6fd62791fe5d348139fa91d94b2fe16568 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Mon, 28 Oct 2024 05:15:42 +0000 Subject: [PATCH] Test on Node 23 (#84) --- .github/workflows/main.yml | 2 +- test/helpers/main.js | 2 ++ test/pipe.js | 18 ++++++++++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 397379c..a215fa8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: node-version: - - 22 + - 23 - 18 os: - ubuntu diff --git a/test/helpers/main.js b/test/helpers/main.js index d9a53e3..b574012 100644 --- a/test/helpers/main.js +++ b/test/helpers/main.js @@ -12,6 +12,8 @@ export const fixturesPath = fileURLToPath(FIXTURES_URL); export const nodeDirectory = path.dirname(process.execPath); +export const NODE_VERSION = Number(process.version.slice(1).split('.')[0]); + export const earlyErrorOptions = {detached: 'true'}; // TODO: replace with Array.fromAsync() after dropping support for Node <22.0.0 diff --git a/test/pipe.js b/test/pipe.js index 05a70bd..ef53676 100644 --- a/test/pipe.js +++ b/test/pipe.js @@ -9,6 +9,7 @@ import { FIXTURES_URL, earlyErrorOptions, arrayFromAsync, + NODE_VERSION, } from './helpers/main.js'; import { testString, @@ -113,11 +114,20 @@ test('.pipe() destination fails due to stream error', async t => { const nodeChildProcess = await second.nodeChildProcess; nodeChildProcess.stdin.destroy(cause); const secondError = await t.throwsAsync(second); - const firstError = await t.throwsAsync(first); assertErrorEvent(t, secondError, cause); - assertErrorEvent(t, firstError, cause); - t.is(firstError.pipedFrom, undefined); - t.is(secondError.pipedFrom, firstError); + + // Node 23 changed the behavior of `stream.pipeline()` + if (NODE_VERSION >= 23) { + const firstResult = await first; + t.is(firstResult.stdout, testString); + t.is(firstResult.pipedFrom, undefined); + t.is(secondError.pipedFrom, firstResult); + } else { + const firstError = await t.throwsAsync(first); + assertErrorEvent(t, firstError, cause); + t.is(firstError.pipedFrom, undefined); + t.is(secondError.pipedFrom, firstError); + } }); test('.pipe() source and destination fail', async t => {