| 40 | } |
| 41 | |
| 42 | function parent() { |
| 43 | const { spawn } = require('child_process'); |
| 44 | const node = process.execPath; |
| 45 | const f = __filename; |
| 46 | const option = { stdio: [ 0, 1, 'ignore' ] }; |
| 47 | |
| 48 | const test = common.mustCallAtLeast((arg, name = 'child', exit) => { |
| 49 | spawn(node, [f, arg], option).on('exit', common.mustCall((code) => { |
| 50 | assert.strictEqual( |
| 51 | code, exit, |
| 52 | `wrong exit for ${arg}-${name}\nexpected:${exit} but got:${code}`); |
| 53 | debug(`ok - ${arg} exited with ${exit}`); |
| 54 | })); |
| 55 | }); |
| 56 | |
| 57 | testCases.forEach((tc, i) => test(i, tc.func.name, tc.result)); |
| 58 | } |