MCPcopy Index your code
hub / github.com/forloopcodes/contextplus / createTestScript

Function createTestScript

test/main/idle-timeout-spawn.test.mjs:18–41  ·  view source on GitHub ↗
(withFix)

Source from the content-addressed store, hash-verified

16}
17
18function 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
43function runHarness(withFix) {
44 return new Promise((resolve) => {

Callers 1

runHarnessFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected