Skip to content

Commit

Permalink
Test on Node 23 (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky authored Oct 28, 2024
1 parent cc818fd commit de094a6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .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 Down
2 changes: 2 additions & 0 deletions test/helpers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 14 additions & 4 deletions test/pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
FIXTURES_URL,
earlyErrorOptions,
arrayFromAsync,
NODE_VERSION,
} from './helpers/main.js';
import {
testString,
Expand Down Expand Up @@ -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 => {
Expand Down

0 comments on commit de094a6

Please sign in to comment.