outgoing.js
This file
Path
test/ipc/outgoing.js
93 lines · 5.1 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
TweaksSindre Sorhusbefore adoption698a1b8
lines 1–2why, one step back1import assert from 'node:assert/strict';2import test from 'node:test';Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 3–5why, one step back3import {execa} from '../../index.js';4import {setFixtureDirectory} from '../helpers/fixtures-directory.js';5import {foobarString} from '../helpers/input.js';Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d
line 6why, one step back6import {isAlwaysTrue, subprocessGetOne, subprocessGetFirst} from '../helpers/ipc.js';Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 7–10why, one step back7import {PARALLEL_COUNT} from '../helpers/parallel.js';89setFixtureDirectory();10TweaksSindre Sorhusbefore adoption698a1b8
line 11why, one step back11const testSendHoldParent = async (getMessage, buffer, filter) => {Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 12–14why, one step back12 const subprocess = execa('ipc-iterate.js', {ipc: true, buffer});1314 await subprocess.sendMessage(0);TweaksSindre Sorhusbefore adoption698a1b8
line 15why, one step back15 assert.equal(await subprocess.getOneMessage({filter}), 0);Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 16–20why, one step back1617 const messages = Array.from({length: PARALLEL_COUNT}, (_, index) => index + 1);18 await Promise.all([19 ...messages.map(message => subprocess.sendMessage(message)),20 subprocess.sendMessage(foobarString),Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
line 21why, one step back21 subprocess.nodeChildProcess.emit('message', '.'),Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 22why, one step back22 ]);TweaksSindre Sorhusbefore adoption698a1b8
line 23why, one step back23 assert.equal(await getMessage(subprocess, {filter}), '.');Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 24–25why, one step back2425 const {ipcOutput} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
lines 26–27why, one step back26 if (!buffer) {27 return;Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 28why, one step back28 }TweaksSindre Sorhusbefore adoption698a1b8
lines 29–31why, one step back2930 const expectedOutput = [0, '.', ...messages];31 assert.deepEqual(ipcOutput, expectedOutput);Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 32–33why, one step back32};33TweaksSindre Sorhusbefore adoption698a1b8
lines 34–39why, one step back34test('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer false', () => testSendHoldParent(subprocessGetOne, false, undefined));35test('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer true', () => testSendHoldParent(subprocessGetOne, true, undefined));36test('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer false, filter', () => testSendHoldParent(subprocessGetOne, false, isAlwaysTrue));37test('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer true, filter', () => testSendHoldParent(subprocessGetOne, true, isAlwaysTrue));38test('Multiple parallel subprocess.sendMessage() + subprocess.getEachMessage(), buffer false', () => testSendHoldParent(subprocessGetFirst, false, undefined));39test('Multiple parallel subprocess.sendMessage() + subprocess.getEachMessage(), buffer true', () => testSendHoldParent(subprocessGetFirst, true, undefined));Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 40why, one step back40TweaksSindre Sorhusbefore adoption698a1b8
line 41why, one step back41const testSendHoldSubprocess = async (filter, isGetEach) => {Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 42why, one step back42 const {ipcOutput} = await execa('ipc-iterate-back.js', [`${filter}`, `${isGetEach}`], {ipcInput: 0});Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 43why, one step back43 const expectedOutput = [...Array.from({length: PARALLEL_COUNT + 1}, (_, index) => index), '.'];TweaksSindre Sorhusbefore adoption698a1b8
line 44why, one step back44 assert.deepEqual(ipcOutput, expectedOutput);Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 45–46why, one step back45};46TweaksSindre Sorhusbefore adoption698a1b8
lines 47–49why, one step back47test('Multiple parallel exports.sendMessage() + exports.getOneMessage()', () => testSendHoldSubprocess(false, false));48test('Multiple parallel exports.sendMessage() + exports.getOneMessage(), filter', () => testSendHoldSubprocess(true, false));49test('Multiple parallel exports.sendMessage() + exports.getEachMessage()', () => testSendHoldSubprocess(false, true));Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 50why, one step back50TweaksSindre Sorhusbefore adoption698a1b8
line 51why, one step back51const testSendHoldParentSerial = async (getMessage, buffer, filter) => {Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 52–54why, one step back52 const subprocess = execa('ipc-iterate.js', {ipc: true, buffer});5354 await subprocess.sendMessage(0);TweaksSindre Sorhusbefore adoption698a1b8
line 55why, one step back55 assert.equal(await subprocess.getOneMessage({filter}), 0);Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 56–57why, one step back5657 const promise = subprocess.sendMessage(1);Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
line 58why, one step back58 subprocess.nodeChildProcess.emit('message', '.');Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 59–69why, one step back59 await promise;6061 const messages = Array.from({length: PARALLEL_COUNT}, (_, index) => index + 2);62 for (const message of messages) {63 // eslint-disable-next-line no-await-in-loop64 await subprocess.sendMessage(message);65 }6667 await subprocess.sendMessage(foobarString);6869 const {ipcOutput} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
lines 70–71why, one step back70 if (!buffer) {71 return;Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 72why, one step back72 }TweaksSindre Sorhusbefore adoption698a1b8
lines 73–75why, one step back7374 const expectedOutput = [0, '.', 1, ...messages];75 assert.deepEqual(ipcOutput, expectedOutput);Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 76–77why, one step back76};77TweaksSindre Sorhusbefore adoption698a1b8
lines 78–83why, one step back78test('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer false', () => testSendHoldParentSerial(subprocessGetOne, false, undefined));79test('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer true', () => testSendHoldParentSerial(subprocessGetOne, true, undefined));80test('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer false, filter', () => testSendHoldParentSerial(subprocessGetOne, false, isAlwaysTrue));81test('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer true, filter', () => testSendHoldParentSerial(subprocessGetOne, true, isAlwaysTrue));82test('Multiple serial subprocess.sendMessage() + subprocess.getEachMessage(), buffer false', () => testSendHoldParentSerial(subprocessGetFirst, false, undefined));83test('Multiple serial subprocess.sendMessage() + subprocess.getEachMessage(), buffer true', () => testSendHoldParentSerial(subprocessGetFirst, true, undefined));Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 84why, one step back84TweaksSindre Sorhusbefore adoption698a1b8
line 85why, one step back85const testSendHoldSubprocessSerial = async (filter, isGetEach) => {Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 86why, one step back86 const {ipcOutput} = await execa('ipc-iterate-back-serial.js', [`${filter}`, `${isGetEach}`], {ipcInput: 0});Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 87why, one step back87 const expectedOutput = [...Array.from({length: PARALLEL_COUNT + 2}, (_, index) => index), '.'];TweaksSindre Sorhusbefore adoption698a1b8
line 88why, one step back88 assert.deepEqual(ipcOutput, expectedOutput);Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 89–90why, one step back89};90TweaksSindre Sorhusbefore adoption698a1b8
lines 91–93why, one step back91test('Multiple serial exports.sendMessage() + exports.getOneMessage()', () => testSendHoldSubprocessSerial(false, false));92test('Multiple serial exports.sendMessage() + exports.getOneMessage(), filter', () => testSendHoldSubprocessSerial(true, false));93test('Multiple serial exports.sendMessage() + exports.getEachMessage()', () => testSendHoldSubprocessSerial(false, true));