(input: string, options: ExecuteInReplOptions)
| 61 | } |
| 62 | |
| 63 | async function executeInRepl(input: string, options: ExecuteInReplOptions) { |
| 64 | const { |
| 65 | waitPattern, |
| 66 | // Wait longer if there's a signal to end it early |
| 67 | waitMs = waitPattern != null ? 20e3 : 1e3, |
| 68 | startInternalOptions, |
| 69 | ...rest |
| 70 | } = options; |
| 71 | const { stdin, stdout, stderr, replService } = createReplViaApi(rest); |
| 72 | |
| 73 | if (startInternalOptions) { |
| 74 | replService.startInternal(startInternalOptions); |
| 75 | } else { |
| 76 | replService.start(); |
| 77 | } |
| 78 | |
| 79 | stdin.write(input); |
| 80 | stdin.end(); |
| 81 | const stdoutPromise = getStream(stdout, waitPattern); |
| 82 | const stderrPromise = getStream(stderr, waitPattern); |
| 83 | // Wait for expected output pattern or timeout, whichever comes first |
| 84 | await Promise.race([delay(waitMs), stdoutPromise, stderrPromise]); |
| 85 | stdout.end(); |
| 86 | stderr.end(); |
| 87 | |
| 88 | return { |
| 89 | stdin, |
| 90 | stdout: await stdoutPromise, |
| 91 | stderr: await stderrPromise, |
| 92 | }; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | export const macroReplNoErrorsAndStdoutContains = test.macro( |
nothing calls this directly
no test coverage detected
searching dependent graphs…