(
pid: number,
condition: (children: any[]) => boolean,
maxWaitMs = 3000,
)
| 10 | |
| 11 | // Helper to poll for a condition on process tree |
| 12 | async function waitForCondition( |
| 13 | pid: number, |
| 14 | condition: (children: any[]) => boolean, |
| 15 | maxWaitMs = 3000, |
| 16 | ): Promise<any[]> { |
| 17 | const startTime = Date.now(); |
| 18 | while (Date.now() - startTime < maxWaitMs) { |
| 19 | const children = await psTree(pid); |
| 20 | if (condition(children)) { |
| 21 | return children; |
| 22 | } |
| 23 | await new Promise((resolve) => setTimeout(resolve, 100)); |
| 24 | } |
| 25 | return psTree(pid); // Final attempt |
| 26 | } |
| 27 | |
| 28 | describe('psTree()', () => { |
| 29 | test('Spawn a Parent process which has Ten Child Processes', async () => { |
no test coverage detected
searching dependent graphs…