| 16 | } |
| 17 | |
| 18 | function createTestScript(withFix) { |
| 19 | const buildPath = join(PROJECT_ROOT, "build/core/process-lifecycle.js").replace(/\\/g, "/"); |
| 20 | return ` |
| 21 | import { createIdleMonitor } from "file://${buildPath}"; |
| 22 | |
| 23 | const idleMonitor = createIdleMonitor({ |
| 24 | timeoutMs: 200, |
| 25 | onIdle: () => { |
| 26 | process.stderr.write("IDLE_SHUTDOWN\\n"); |
| 27 | process.exit(0); |
| 28 | }, |
| 29 | ${withFix ? 'isTransportAlive: () => process.stdin.readable && !process.stdin.destroyed,' : ''} |
| 30 | }); |
| 31 | |
| 32 | process.stderr.write("STARTED\\n"); |
| 33 | const keepAlive = setInterval(() => {}, 1000); |
| 34 | setTimeout(() => { |
| 35 | idleMonitor.stop(); |
| 36 | clearInterval(keepAlive); |
| 37 | process.stderr.write("SURVIVED\\n"); |
| 38 | process.exit(0); |
| 39 | }, 1500); |
| 40 | `; |
| 41 | } |
| 42 | |
| 43 | function runHarness(withFix) { |
| 44 | return new Promise((resolve) => { |