(t, getReader, shouldAbortBeforePipe = false)
| 217 | }); |
| 218 | |
| 219 | const 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 | |
| 242 | test('The .pipe() return value .getEachMessage() waits for pipe cancellation before IPC messages', async t => { |
| 243 | await assertCanceledPipeMessageReader(t, piped => piped.getEachMessage().next()); |
no test coverage detected