| 73 | } |
| 74 | |
| 75 | function onChildClose(code, signal) { |
| 76 | tearDown(); |
| 77 | let message = 'Child exited'; |
| 78 | if (code) { |
| 79 | message += `, code ${code}`; |
| 80 | } |
| 81 | if (signal) { |
| 82 | message += `, signal ${signal}`; |
| 83 | } |
| 84 | message += ` while waiting for ${pattern}; found: ${this.output}`; |
| 85 | if (stderrOutput) { |
| 86 | message += `\n STDERR: ${stderrOutput}`; |
| 87 | } |
| 88 | reject(new Error(message)); |
| 89 | } |
| 90 | |
| 91 | // Capture stack trace here to show where waitFor was called from when it times out. |
| 92 | const timeoutErr = new Error(`Timeout (${TIMEOUT}) while waiting for ${pattern}`); |