reference.js
This file
Path
test/ipc/reference.js
132 lines · 5.2 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 {assertRejects} from '../helpers/assert.js';Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 4–10why, one step back4import {execa} from '../../index.js';5import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6import {foobarString} from '../helpers/input.js';7import {PARALLEL_COUNT} from '../helpers/parallel.js';89setFixtureDirectory();10TweaksSindre Sorhusbefore adoption698a1b8
lines 11–13why, one step back11const testReference = async fixtureName => {12 const {timedOut} = await assertRejects(execa(fixtureName, {ipc: true, timeout: 1e3}));13 assert.equal(timedOut, true);Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 14–15why, one step back14};15TweaksSindre Sorhusbefore adoption698a1b8
lines 16–17why, one step back16test('exports.getOneMessage() keeps the subprocess alive', () => testReference('ipc-get-ref.js'));17test('exports.getEachMessage() keeps the subprocess alive', () => testReference('ipc-iterate-ref.js'));Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6
line 18why, one step back18TweaksSindre Sorhusbefore adoption698a1b8
line 19why, one step back19const testUnreference = async fixtureName => {Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6
line 20why, one step back20 const {ipcOutput} = await execa(fixtureName, {ipc: true});TweaksSindre Sorhusbefore adoption698a1b8
line 21why, one step back21 assert.deepEqual(ipcOutput, []);Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6
lines 22–23why, one step back22};23TweaksSindre Sorhusbefore adoption698a1b8
lines 24–25why, one step back24test('exports.getOneMessage() does not keep the subprocess alive, reference false', () => testUnreference('ipc-get-unref.js'));25test('exports.getEachMessage() does not keep the subprocess alive, reference false', () => testUnreference('ipc-iterate-unref.js'));Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 26why, one step back26TweaksSindre Sorhusbefore adoption698a1b8
line 27why, one step back27test('exports.sendMessage() keeps the subprocess alive', async () => {Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 28–29why, one step back28 const {ipcOutput} = await execa('ipc-send-repeat.js', [`${PARALLEL_COUNT}`], {ipc: true});29 const expectedOutput = Array.from({length: PARALLEL_COUNT}, (_, index) => index);TweaksSindre Sorhusbefore adoption698a1b8
line 30why, one step back30 assert.deepEqual(ipcOutput, expectedOutput);Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 31–32why, one step back31});32TweaksSindre Sorhusbefore adoption698a1b8
line 33why, one step back33test('process.send() keeps the subprocess alive', async () => {Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 34why, one step back34 const {ipcOutput, stdout} = await execa('ipc-process-send.js', {ipc: true});TweaksSindre Sorhusbefore adoption698a1b8
lines 35–36why, one step back35 assert.deepEqual(ipcOutput, [foobarString]);36 assert.equal(stdout, '.');Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 37–38why, one step back37});38TweaksSindre Sorhusbefore adoption698a1b8
line 39why, one step back39test('process.send() keeps the subprocess alive, after getOneMessage()', async () => {Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10
line 40why, one step back40 const {ipcOutput, stdout} = await execa('ipc-process-send-get.js', {ipcInput: 0});TweaksSindre Sorhusbefore adoption698a1b8
lines 41–42why, one step back41 assert.deepEqual(ipcOutput, [foobarString]);42 assert.equal(stdout, '.');Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 43–44why, one step back43});44TweaksSindre Sorhusbefore adoption698a1b8
line 45why, one step back45test('process.send() keeps the subprocess alive, after sendMessage()', async () => {Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 46why, one step back46 const {ipcOutput, stdout} = await execa('ipc-process-send-send.js', {ipc: true});TweaksSindre Sorhusbefore adoption698a1b8
lines 47–48why, one step back47 assert.deepEqual(ipcOutput, ['.', foobarString]);48 assert.equal(stdout, '.');Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 49–50why, one step back49});50TweaksSindre Sorhusbefore adoption698a1b8
line 51why, one step back51test('process.once("message") keeps the subprocess alive', async () => {Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 52why, one step back52 const subprocess = execa('ipc-once-message.js', {ipc: true});TweaksSindre Sorhusbefore adoption698a1b8
line 53why, one step back53 assert.equal(await subprocess.getOneMessage(), '.');Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 54–56why, one step back54 await subprocess.sendMessage(foobarString);5556 const {ipcOutput, stdout} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
lines 57–58why, one step back57 assert.deepEqual(ipcOutput, ['.']);58 assert.equal(stdout, foobarString);Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 59–60why, one step back59});60TweaksSindre Sorhusbefore adoption698a1b8
line 61why, one step back61test('process.once("message") keeps the subprocess alive, after sendMessage()', async () => {Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 62why, one step back62 const subprocess = execa('ipc-once-message-send.js', {ipc: true});TweaksSindre Sorhusbefore adoption698a1b8
line 63why, one step back63 assert.equal(await subprocess.getOneMessage(), '.');Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 64–66why, one step back64 await subprocess.sendMessage(foobarString);6566 const {ipcOutput, stdout} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
lines 67–68why, one step back67 assert.deepEqual(ipcOutput, ['.']);68 assert.equal(stdout, foobarString);Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 69–70why, one step back69});70TweaksSindre Sorhusbefore adoption698a1b8
line 71why, one step back71test('process.once("message") keeps the subprocess alive, after getOneMessage()', async () => {Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 72–73why, one step back72 const subprocess = execa('ipc-once-message-get.js', {ipc: true});73 await subprocess.sendMessage('.');TweaksSindre Sorhusbefore adoption698a1b8
line 74why, one step back74 assert.equal(await subprocess.getOneMessage(), '.');Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 75–77why, one step back75 await subprocess.sendMessage(foobarString);7677 const {ipcOutput, stdout} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
lines 78–79why, one step back78 assert.deepEqual(ipcOutput, ['.']);79 assert.equal(stdout, foobarString);Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 80–81why, one step back80});81TweaksSindre Sorhusbefore adoption698a1b8
line 82why, one step back82test('process.once("disconnect") keeps the subprocess alive', async () => {Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 83why, one step back83 const subprocess = execa('ipc-once-disconnect.js', {ipc: true});TweaksSindre Sorhusbefore adoption698a1b8
line 84why, one step back84 assert.equal(await subprocess.getOneMessage(), '.');Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
line 85why, one step back85 subprocess.nodeChildProcess.disconnect();Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 86–87why, one step back8687 const {ipcOutput, stdout} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
lines 88–89why, one step back88 assert.deepEqual(ipcOutput, ['.']);89 assert.equal(stdout, '.');Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 90–91why, one step back90});91TweaksSindre Sorhusbefore adoption698a1b8
line 92why, one step back92test('process.once("disconnect") keeps the subprocess alive, after sendMessage()', async () => {Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 93why, one step back93 const subprocess = execa('ipc-once-disconnect-send.js', {ipc: true});TweaksSindre Sorhusbefore adoption698a1b8
lines 94–96why, one step back94 assert.equal(await subprocess.getOneMessage(), '.');95 // eslint-disable-next-line node-test/no-duplicate-assertions -- the same message is read twice on purpose96 assert.equal(await subprocess.getOneMessage(), '.');Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
line 97why, one step back97 subprocess.nodeChildProcess.disconnect();Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 98–99why, one step back9899 const {ipcOutput, stdout} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
lines 100–101why, one step back100 assert.deepEqual(ipcOutput, ['.', '.']);101 assert.equal(stdout, '.');Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 102–103why, one step back102});103TweaksSindre Sorhusbefore adoption698a1b8
line 104why, one step back104test('process.once("disconnect") does not keep the subprocess alive, after getOneMessage()', async () => {Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 105–106why, one step back105 const subprocess = execa('ipc-once-disconnect-get.js', {ipc: true});106 await subprocess.sendMessage('.');TweaksSindre Sorhusbefore adoption698a1b8
line 107why, one step back107 assert.equal(await subprocess.getOneMessage(), '.');Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
line 108why, one step back108 subprocess.nodeChildProcess.disconnect();Debounce `message` events (#1087)ehmickybefore adoptione8bab97
lines 109–110why, one step back109110 const {ipcOutput, stdout} = await subprocess;TweaksSindre Sorhusbefore adoption698a1b8
lines 111–112why, one step back111 assert.deepEqual(ipcOutput, ['.']);112 assert.equal(stdout, '.');Debounce `message` events (#1087)ehmickybefore adoptione8bab97
line 113why, one step back113});Refactor reference counting with IPC (#1089)ehmickybefore adoption18e607c
line 114why, one step back114TweaksSindre Sorhusbefore adoption698a1b8
line 115why, one step back115test('Can call subprocess.disconnect() right away', async () => {Refactor reference counting with IPC (#1089)ehmickybefore adoption18e607c
line 116why, one step back116 const subprocess = execa('ipc-send.js', {ipc: true});Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
line 117why, one step back117 subprocess.nodeChildProcess.disconnect();TweaksSindre Sorhusbefore adoption698a1b8
line 118why, one step back118 assert.equal(subprocess.nodeChildProcess.channel, null);Refactor reference counting with IPC (#1089)ehmickybefore adoption18e607c
line 119why, one step back119TweaksSindre Sorhusbefore adoption698a1b8
line 120why, one step back120 await assertRejects(subprocess.getOneMessage(), {Refactor reference counting with IPC (#1089)ehmickybefore adoption18e607c
lines 121–122why, one step back121 message: /subprocess.getOneMessage\(\) could not complete/,122 });TweaksSindre Sorhusbefore adoption698a1b8
line 123why, one step back123 await assertRejects(subprocess, {Refactor reference counting with IPC (#1089)ehmickybefore adoption18e607c
lines 124–127why, one step back124 message: /Error: sendMessage\(\) cannot be used/,125 });126});127TweaksSindre Sorhusbefore adoption698a1b8
lines 128–131why, one step back128test('Can call process.disconnect() right away', async () => {129 const {stdout, stderr} = await assertRejects(execa('ipc-disconnect-get.js', {ipc: true}));130 assert.equal(stdout, 'null');131 assert.ok(stderr.includes('Error: getOneMessage() cannot be used'));Refactor reference counting with IPC (#1089)ehmickybefore adoption18e607c
line 132why, one step back132});