pending.js
This file
Path
test/ipc/pending.js
88 lines · 3.8 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
TweaksSindre Sorhusbefore adoption698a1b8
line 1why, one step back1import assert from 'node:assert/strict';Improve `buffer: false` option with IPC (#1094)ehmickybefore adoptiond8bdaf0
lines 2–3why, one step back2import {once} from 'node:events';3import {setTimeout} from 'node:timers/promises';TweaksSindre Sorhusbefore adoption698a1b8
line 4why, one step back4import test from 'node:test';Improve `buffer: false` option with IPC (#1094)ehmickybefore adoptiond8bdaf0
lines 5–10why, one step back5import {execa} from '../../index.js';6import {setFixtureDirectory} from '../helpers/fixtures-directory.js';7import {foobarString} from '../helpers/input.js';89setFixtureDirectory();10TweaksSindre Sorhusbefore adoption698a1b8
line 11why, one step back11const testBufferInitial = async buffer => {Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 12why, one step back12 const subprocess = execa('ipc-echo-wait.js', {buffer, ipcInput: foobarString});TweaksSindre Sorhusbefore adoption698a1b8
line 13why, one step back13 assert.equal(await subprocess.getOneMessage(), foobarString);Improve `buffer: false` option with IPC (#1094)ehmickybefore adoptiond8bdaf0
lines 14–15why, one step back1415 const {ipcOutput} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
line 16why, one step back16 assert.deepEqual(ipcOutput, buffer ? [foobarString] : []);Improve `buffer: false` option with IPC (#1094)ehmickybefore adoptiond8bdaf0
lines 17–18why, one step back17};18TweaksSindre Sorhusbefore adoption698a1b8
lines 19–20why, one step back19test('Buffers initial message to subprocess, buffer false', () => testBufferInitial(false));20test('Buffers initial message to subprocess, buffer true', () => testBufferInitial(true));Improve `buffer: false` option with IPC (#1094)ehmickybefore adoptiond8bdaf0
line 21why, one step back21TweaksSindre Sorhusbefore adoption698a1b8
line 22why, one step back22const testBufferInitialSend = async buffer => {Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 23why, one step back23 const subprocess = execa('ipc-send-echo-wait.js', {buffer, ipcInput: foobarString});TweaksSindre Sorhusbefore adoption698a1b8
lines 24–25why, one step back24 assert.equal(await subprocess.getOneMessage(), '.');25 assert.equal(await subprocess.getOneMessage(), foobarString);Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
lines 26–27why, one step back2627 const {ipcOutput} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
line 28why, one step back28 assert.deepEqual(ipcOutput, buffer ? ['.', foobarString] : []);Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
lines 29–30why, one step back29};30TweaksSindre Sorhusbefore adoption698a1b8
lines 31–32why, one step back31test('sendMessage() does not empty the initial message buffering, buffer false', () => testBufferInitialSend(false));32test('sendMessage() does not empty the initial message buffering, buffer true', () => testBufferInitialSend(true));Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 33why, one step back33TweaksSindre Sorhusbefore adoption698a1b8
line 34why, one step back34const testBufferInitialStrict = async buffer => {Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 35why, one step back35 const subprocess = execa('ipc-send-echo-strict.js', {buffer, ipcInput: foobarString});TweaksSindre Sorhusbefore adoption698a1b8
line 36why, one step back36 assert.equal(await subprocess.getOneMessage(), '.');Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
lines 37–39why, one step back37 await setTimeout(1e3);38 const promise = subprocess.getOneMessage();39 await subprocess.sendMessage('..');TweaksSindre Sorhusbefore adoption698a1b8
line 40why, one step back40 assert.equal(await promise, '..');Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
lines 41–42why, one step back4142 const {ipcOutput} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
line 43why, one step back43 assert.deepEqual(ipcOutput, buffer ? ['.', '..'] : []);Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
lines 44–45why, one step back44};45TweaksSindre Sorhusbefore adoption698a1b8
lines 46–47why, one step back46test('sendMessage() with "strict" empties the initial message buffering, buffer false', () => testBufferInitialStrict(false));47test('sendMessage() with "strict" empties the initial message buffering, buffer true', () => testBufferInitialStrict(true));Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 48why, one step back48TweaksSindre Sorhusbefore adoption698a1b8
line 49why, one step back49const testNoBufferInitial = async buffer => {Improve `buffer: false` option with IPC (#1094)ehmickybefore adoptiond8bdaf0
lines 50–51why, one step back50 const subprocess = execa('ipc-send-print.js', {ipc: true, buffer});51 const [chunk] = await once(subprocess.stdout, 'data');TweaksSindre Sorhusbefore adoption698a1b8
line 52why, one step back52 assert.equal(chunk.toString(), '.');Improve `buffer: false` option with IPC (#1094)ehmickybefore adoptiond8bdaf0
line 53why, one step back53 await setTimeout(1e3);TweaksSindre Sorhusbefore adoption698a1b8
line 54why, one step back54 assert.equal(await Promise.race([setTimeout(0), subprocess.getOneMessage()]), undefined);Improve `buffer: false` option with IPC (#1094)ehmickybefore adoptiond8bdaf0
lines 55–57why, one step back55 await subprocess.sendMessage('.');5657 const {ipcOutput} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
line 58why, one step back58 assert.deepEqual(ipcOutput, buffer ? [foobarString] : []);Improve `buffer: false` option with IPC (#1094)ehmickybefore adoptiond8bdaf0
lines 59–60why, one step back59};60TweaksSindre Sorhusbefore adoption698a1b8
lines 61–62why, one step back61test('Does not buffer initial message to current process, buffer false', () => testNoBufferInitial(false));62test('Does not buffer initial message to current process, buffer true', () => testNoBufferInitial(true));Improve `buffer: false` option with IPC (#1094)ehmickybefore adoptiond8bdaf0
line 63why, one step back63TweaksSindre Sorhusbefore adoption698a1b8
line 64why, one step back64const testReplay = async buffer => {Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 65why, one step back65 const subprocess = execa('ipc-replay.js', {buffer, ipcInput: foobarString});TweaksSindre Sorhusbefore adoption698a1b8
line 66why, one step back66 assert.equal(await subprocess.getOneMessage(), foobarString);Improve `buffer: false` option with IPC (#1094)ehmickybefore adoptiond8bdaf0
lines 67–69why, one step back67 await subprocess.sendMessage('.');68 await setTimeout(2e3);69 await subprocess.sendMessage(foobarString);TweaksSindre Sorhusbefore adoption698a1b8
line 70why, one step back70 assert.equal(await subprocess.getOneMessage(), foobarString);Improve `buffer: false` option with IPC (#1094)ehmickybefore adoptiond8bdaf0
lines 71–72why, one step back7172 const {ipcOutput} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
line 73why, one step back73 assert.deepEqual(ipcOutput, buffer ? [foobarString, foobarString] : []);Improve `buffer: false` option with IPC (#1094)ehmickybefore adoptiond8bdaf0
lines 74–75why, one step back74};75TweaksSindre Sorhusbefore adoption698a1b8
lines 76–77why, one step back76test('Does not replay missed messages in subprocess, buffer false', () => testReplay(false));77test('Does not replay missed messages in subprocess, buffer true', () => testReplay(true));Improve `buffer: false` option with IPC (#1094)ehmickybefore adoptiond8bdaf0
line 78why, one step back78TweaksSindre Sorhusbefore adoption698a1b8
line 79why, one step back79const testFastSend = async buffer => {Improve `buffer: false` option with IPC (#1094)ehmickybefore adoptiond8bdaf0
line 80why, one step back80 const subprocess = execa('ipc-send-native.js', {ipc: true, buffer});TweaksSindre Sorhusbefore adoption698a1b8
line 81why, one step back81 assert.equal(await subprocess.getOneMessage(), '.');Improve `buffer: false` option with IPC (#1094)ehmickybefore adoptiond8bdaf0
lines 82–83why, one step back8283 const {ipcOutput} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
line 84why, one step back84 assert.deepEqual(ipcOutput, buffer ? ['.'] : []);Improve `buffer: false` option with IPC (#1094)ehmickybefore adoptiond8bdaf0
lines 85–86why, one step back85};86TweaksSindre Sorhusbefore adoption698a1b8
lines 87–88why, one step back87test('Subprocess can send messages right away, buffer false', () => testFastSend(false));88test('Subprocess can send messages right away, buffer true', () => testFastSend(true));