Skip to content
Myr

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 file

Take it

TweaksSindre Sorhusbefore adoption698a1b8

lines 1–3why, one step back
1import 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 back
4import {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 back
7import {PARALLEL_COUNT} from '../helpers/parallel.js';

Fix fd-specific options to account for `ipc` (#1241)Sindre Sorhusbefore adoptionb886883

line 8why, one step back
8import {fullStdio} from '../helpers/stdio.js';

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 9–11why, one step back
9
10setFixtureDirectory();11

TweaksSindre Sorhusbefore adoption698a1b8

line 12why, one step back
12const testResultIpc = async options => {

Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360

line 13why, one step back
13 const {ipcOutput} = await execa('ipc-send-twice.js', {...options, ipc: true});

TweaksSindre Sorhusbefore adoption698a1b8

line 14why, one step back
14 assert.deepEqual(ipcOutput, foobarArray);

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 15–16why, one step back
15};
16

TweaksSindre Sorhusbefore adoption698a1b8

lines 17–18why, one step back
17test('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 back
19

TweaksSindre Sorhusbefore adoption698a1b8

line 20why, one step back
20const testResultNoBuffer = async options => {

Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360

line 21why, one step back
21 const {ipcOutput} = await execa('ipc-send.js', {...options, ipc: true});

TweaksSindre Sorhusbefore adoption698a1b8

line 22why, one step back
22 assert.deepEqual(ipcOutput, []);

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 23–24why, one step back
23};
24

TweaksSindre Sorhusbefore adoption698a1b8

lines 25–26why, one step back
25test('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 back
27

TweaksSindre Sorhusbefore adoption698a1b8

lines 28–29why, one step back
28test('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 back
30 execa('ipc-send-twice.js', {ipc: true, buffer: {fd3: false}});
31 });

TweaksSindre Sorhusbefore adoption698a1b8

line 32why, one step back
32 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 back
33});
34

TweaksSindre Sorhusbefore adoption698a1b8

line 35why, one step back
35test('buffer.fd3 does not affect result.ipcOutput', async () => {

Fix fd-specific options to account for `ipc` (#1241)Sindre Sorhusbefore adoptionb886883

line 36why, one step back
36 const {ipcOutput} = await execa('ipc-send-twice.js', {ipc: true, buffer: {fd3: false}, ...fullStdio});

TweaksSindre Sorhusbefore adoption698a1b8

line 37why, one step back
37 assert.deepEqual(ipcOutput, foobarArray);

Fix fd-specific options to account for `ipc` (#1241)Sindre Sorhusbefore adoptionb886883

line 38why, one step back
38});

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

line 39why, one step back
39

TweaksSindre Sorhusbefore adoption698a1b8

line 40why, one step back
40test('Can use IPC methods when buffer is false', async () => {

Improve `buffer: false` behavior with IPC (#1092)ehmickybefore adoption76d637a

line 41why, one step back
41 const subprocess = execa('ipc-send.js', {ipc: true, buffer: false});

TweaksSindre Sorhusbefore adoption698a1b8

line 42why, one step back
42 assert.equal(await subprocess.getOneMessage(), foobarString);

Improve `buffer: false` behavior with IPC (#1092)ehmickybefore adoption76d637a

line 43why, one step back
43 const {ipcOutput} = await subprocess;

TweaksSindre Sorhusbefore adoption698a1b8

line 44why, one step back
44 assert.deepEqual(ipcOutput, []);

Improve `buffer: false` behavior with IPC (#1092)ehmickybefore adoption76d637a

lines 45–46why, one step back
45});
46

TweaksSindre Sorhusbefore adoption698a1b8

line 47why, one step back
47test('Sets empty result.ipcOutput if ipc is false', async () => {

Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360

line 48why, one step back
48 const {ipcOutput} = await execa('empty.js');

TweaksSindre Sorhusbefore adoption698a1b8

line 49why, one step back
49 assert.deepEqual(ipcOutput, []);

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 50–51why, one step back
50});
51

TweaksSindre Sorhusbefore adoption698a1b8

line 52why, one step back
52test('Sets empty result.ipcOutput, sync', () => {

Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360

line 53why, one step back
53 const {ipcOutput} = execaSync('empty.js');

TweaksSindre Sorhusbefore adoption698a1b8

line 54why, one step back
54 assert.deepEqual(ipcOutput, []);

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 55–56why, one step back
55});
56

TweaksSindre Sorhusbefore adoption698a1b8

lines 57–59why, one step back
57const 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 back
60};
61

TweaksSindre Sorhusbefore adoption698a1b8

lines 62–63why, one step back
62test('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 back
64

TweaksSindre Sorhusbefore adoption698a1b8

lines 65–67why, one step back
65const 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 back
68};
69

TweaksSindre Sorhusbefore adoption698a1b8

lines 70–71why, one step back
70test('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 back
72

TweaksSindre Sorhusbefore adoption698a1b8

lines 73–75why, one step back
73test('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 back
76});
77

TweaksSindre Sorhusbefore adoption698a1b8

lines 78–80why, one step back
78test('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 back
81});

Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052

line 82why, one step back
82

TweaksSindre Sorhusbefore adoption698a1b8

line 83why, one step back
83test('Can retrieve initial IPC messages under heavy load', async () => {

Require Node.js 22 (#1243)Sindre Sorhusbefore adoption04b4454

lines 84–85why, one step back
84 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 back
86 assert.deepEqual(ipcOutput, [`${index}`]);

Require Node.js 22 (#1243)Sindre Sorhusbefore adoption04b4454

line 87why, one step back
87 }));

Add `exchangeMessage()` method (#1077)ehmickybefore adoption7a0a1c6

line 88why, one step back
88});