(t, getReader, shouldAbortBeforePipe = false)
| 376 | }); |
| 377 | |
| 378 | const assertCanceledPipeReader = async (t, getReader, shouldAbortBeforePipe = false) => { |
| 379 | const abortController = new AbortController(); |
| 380 | if (shouldAbortBeforePipe) { |
| 381 | abortController.abort(); |
| 382 | } |
| 383 | |
| 384 | const source = execa('stdin.js'); |
| 385 | const destination = execa('stdin.js', {all: true}); |
| 386 | t.teardown(async () => { |
| 387 | await cleanupSubprocesses(source, destination); |
| 388 | }); |
| 389 | |
| 390 | const piped = source.pipe(destination, {unpipeSignal: abortController.signal}); |
| 391 | const readerPromise = t.throwsAsync(getReader(piped), {message: /Pipe canceled/}); |
| 392 | |
| 393 | if (!shouldAbortBeforePipe) { |
| 394 | abortController.abort(); |
| 395 | } |
| 396 | |
| 397 | await assertSettles(t, readerPromise, 200); |
| 398 | }; |
| 399 | |
| 400 | test('The .pipe() return value .readable() waits for pipe cancellation', async t => { |
| 401 | await assertCanceledPipeReader(t, piped => text(piped.readable())); |
no test coverage detected