buffer-messages.js
This file
Path
test/ipc/buffer-messages.js
88 lines · 3.5 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
TweaksSindre Sorhusbefore adoption698a1b8
lines 1–3why, one step back1import assert from 'node:assert/strict';2import test from 'node:test';3import {assertThrows, assertRejects} from '../helpers/assert.js';Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 4–6why, one step back4import {execa, execaSync} from '../../index.js';5import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6import {foobarString, foobarArray} from '../helpers/input.js';Refactor parallel tests (#1084)ehmickybefore adoption5cf6312
line 7why, one step back7import {PARALLEL_COUNT} from '../helpers/parallel.js';Fix fd-specific options to account for `ipc` (#1241)Sindre Sorhusbefore adoptionb886883
line 8why, one step back8import {fullStdio} from '../helpers/stdio.js';Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 9–11why, one step back910setFixtureDirectory();11TweaksSindre Sorhusbefore adoption698a1b8
line 12why, one step back12const testResultIpc = async options => {Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360
line 13why, one step back13 const {ipcOutput} = await execa('ipc-send-twice.js', {...options, ipc: true});TweaksSindre Sorhusbefore adoption698a1b8
line 14why, one step back14 assert.deepEqual(ipcOutput, foobarArray);Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 15–16why, one step back15};16TweaksSindre Sorhusbefore adoption698a1b8
lines 17–18why, one step back17test('Sets result.ipcOutput', () => testResultIpc({}));18test('Sets result.ipcOutput, fd-specific buffer', () => testResultIpc({buffer: {stdout: false}}));Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
line 19why, one step back19TweaksSindre Sorhusbefore adoption698a1b8
line 20why, one step back20const testResultNoBuffer = async options => {Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360
line 21why, one step back21 const {ipcOutput} = await execa('ipc-send.js', {...options, ipc: true});TweaksSindre Sorhusbefore adoption698a1b8
line 22why, one step back22 assert.deepEqual(ipcOutput, []);Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 23–24why, one step back23};24TweaksSindre Sorhusbefore adoption698a1b8
lines 25–26why, one step back25test('Sets empty result.ipcOutput if buffer is false', () => testResultNoBuffer({buffer: false}));26test('Sets empty result.ipcOutput if buffer is false, fd-specific buffer', () => testResultNoBuffer({buffer: {ipc: false}}));Fix fd-specific options to account for `ipc` (#1241)Sindre Sorhusbefore adoptionb886883
line 27why, one step back27TweaksSindre Sorhusbefore adoption698a1b8
lines 28–29why, one step back28test('buffer.fd3 is invalid without stdio[3], even with ipc', () => {29 const {message} = assertThrows(() => {Fix fd-specific options to account for `ipc` (#1241)Sindre Sorhusbefore adoptionb886883
lines 30–31why, one step back30 execa('ipc-send-twice.js', {ipc: true, buffer: {fd3: false}});31 });TweaksSindre Sorhusbefore adoption698a1b8
line 32why, one step back32 assert.ok(message.includes('"buffer.fd3" is invalid: that file descriptor does not exist.'));Fix fd-specific options to account for `ipc` (#1241)Sindre Sorhusbefore adoptionb886883
lines 33–34why, one step back33});34TweaksSindre Sorhusbefore adoption698a1b8
line 35why, one step back35test('buffer.fd3 does not affect result.ipcOutput', async () => {Fix fd-specific options to account for `ipc` (#1241)Sindre Sorhusbefore adoptionb886883
line 36why, one step back36 const {ipcOutput} = await execa('ipc-send-twice.js', {ipc: true, buffer: {fd3: false}, ...fullStdio});TweaksSindre Sorhusbefore adoption698a1b8
line 37why, one step back37 assert.deepEqual(ipcOutput, foobarArray);Fix fd-specific options to account for `ipc` (#1241)Sindre Sorhusbefore adoptionb886883
line 38why, one step back38});Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
line 39why, one step back39TweaksSindre Sorhusbefore adoption698a1b8
line 40why, one step back40test('Can use IPC methods when buffer is false', async () => {Improve `buffer: false` behavior with IPC (#1092)ehmickybefore adoption76d637a
line 41why, one step back41 const subprocess = execa('ipc-send.js', {ipc: true, buffer: false});TweaksSindre Sorhusbefore adoption698a1b8
line 42why, one step back42 assert.equal(await subprocess.getOneMessage(), foobarString);Improve `buffer: false` behavior with IPC (#1092)ehmickybefore adoption76d637a
line 43why, one step back43 const {ipcOutput} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
line 44why, one step back44 assert.deepEqual(ipcOutput, []);Improve `buffer: false` behavior with IPC (#1092)ehmickybefore adoption76d637a
lines 45–46why, one step back45});46TweaksSindre Sorhusbefore adoption698a1b8
line 47why, one step back47test('Sets empty result.ipcOutput if ipc is false', async () => {Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360
line 48why, one step back48 const {ipcOutput} = await execa('empty.js');TweaksSindre Sorhusbefore adoption698a1b8
line 49why, one step back49 assert.deepEqual(ipcOutput, []);Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 50–51why, one step back50});51TweaksSindre Sorhusbefore adoption698a1b8
line 52why, one step back52test('Sets empty result.ipcOutput, sync', () => {Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360
line 53why, one step back53 const {ipcOutput} = execaSync('empty.js');TweaksSindre Sorhusbefore adoption698a1b8
line 54why, one step back54 assert.deepEqual(ipcOutput, []);Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 55–56why, one step back55});56TweaksSindre Sorhusbefore adoption698a1b8
lines 57–59why, one step back57const testErrorIpc = async options => {58 const {ipcOutput} = await assertRejects(execa('ipc-send-fail.js', {...options, ipc: true}));59 assert.deepEqual(ipcOutput, [foobarString]);Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 60–61why, one step back60};61TweaksSindre Sorhusbefore adoption698a1b8
lines 62–63why, one step back62test('Sets error.ipcOutput', () => testErrorIpc({}));63test('Sets error.ipcOutput, fd-specific buffer', () => testErrorIpc({buffer: {stdout: false}}));Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
line 64why, one step back64TweaksSindre Sorhusbefore adoption698a1b8
lines 65–67why, one step back65const testErrorNoBuffer = async options => {66 const {ipcOutput} = await assertRejects(execa('ipc-send-fail.js', {...options, ipc: true}));67 assert.deepEqual(ipcOutput, []);Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 68–69why, one step back68};69TweaksSindre Sorhusbefore adoption698a1b8
lines 70–71why, one step back70test('Sets empty error.ipcOutput if buffer is false', () => testErrorNoBuffer({buffer: false}));71test('Sets empty error.ipcOutput if buffer is false, fd-specific buffer', () => testErrorNoBuffer({buffer: {ipc: false}}));Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
line 72why, one step back72TweaksSindre Sorhusbefore adoption698a1b8
lines 73–75why, one step back73test('Sets empty error.ipcOutput if ipc is false', async () => {74 const {ipcOutput} = await assertRejects(execa('fail.js'));75 assert.deepEqual(ipcOutput, []);Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
lines 76–77why, one step back76});77TweaksSindre Sorhusbefore adoption698a1b8
lines 78–80why, one step back78test('Sets empty error.ipcOutput, sync', () => {79 const {ipcOutput} = assertThrows(() => execaSync('fail.js'));80 assert.deepEqual(ipcOutput, []);Add `ipcInput` option (#1068)ehmickybefore adoption46cae30
line 81why, one step back81});Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052
line 82why, one step back82TweaksSindre Sorhusbefore adoption698a1b8
line 83why, one step back83test('Can retrieve initial IPC messages under heavy load', async () => {Require Node.js 22 (#1243)Sindre Sorhusbefore adoption04b4454
lines 84–85why, one step back84 await Promise.all(Array.from({length: PARALLEL_COUNT}, async (_, index) => {85 const {ipcOutput} = await execa('ipc-send-argv.js', [`${index}`], {ipc: true});TweaksSindre Sorhusbefore adoption698a1b8
line 86why, one step back86 assert.deepEqual(ipcOutput, [`${index}`]);Require Node.js 22 (#1243)Sindre Sorhusbefore adoption04b4454
line 87why, one step back87 }));Add `exchangeMessage()` method (#1077)ehmickybefore adoption7a0a1c6
line 88why, one step back88});