MCPcopy Create free account
hub / github.com/sindresorhus/execa / assertCanceledPipeMessageReader

Function assertCanceledPipeMessageReader

test/pipe/methods.js:219–240  ·  view source on GitHub ↗
(t, getReader, shouldAbortBeforePipe = false)

Source from the content-addressed store, hash-verified

217});
218
219const assertCanceledPipeMessageReader = async (t, getReader, shouldAbortBeforePipe = false) => {
220 const abortController = new AbortController();
221 if (shouldAbortBeforePipe) {
222 abortController.abort();
223 }
224
225 const source = execa('noop-repeat.js');
226 const destination = execa('ipc-get.js', {ipc: true});
227 t.teardown(async () => {
228 await cleanupSubprocesses(source, destination);
229 });
230
231 const piped = source.pipe(destination, {unpipeSignal: abortController.signal});
232 const readerPromise = t.throwsAsync(getReader(piped), {message: /Pipe canceled/});
233
234 if (!shouldAbortBeforePipe) {
235 abortController.abort();
236 }
237
238 await assertSettles(t, readerPromise);
239 await t.throwsAsync(piped, {message: /Pipe canceled/});
240};
241
242test('The .pipe() return value .getEachMessage() waits for pipe cancellation before IPC messages', async t => {
243 await assertCanceledPipeMessageReader(t, piped => piped.getEachMessage().next());

Callers 1

methods.jsFile · 0.85

Calls 2

cleanupSubprocessesFunction · 0.85
assertSettlesFunction · 0.85

Tested by

no test coverage detected