()
| 39 | } |
| 40 | |
| 41 | function parent() { |
| 42 | const spawn = require('child_process').spawn; |
| 43 | const child = spawn(process.execPath, [__filename, 'child']); |
| 44 | let sent = 0; |
| 45 | |
| 46 | let n = ''; |
| 47 | child.stdout.setEncoding('ascii'); |
| 48 | child.stdout.on('data', mustCallAtLeast((c) => { |
| 49 | n += c; |
| 50 | })); |
| 51 | child.stdout.on('end', mustCall(() => { |
| 52 | assert.strictEqual(+n, sent); |
| 53 | debug('ok'); |
| 54 | })); |
| 55 | |
| 56 | // Write until the buffer fills up. |
| 57 | let buf; |
| 58 | do { |
| 59 | bufsize += 1024; |
| 60 | buf = Buffer.alloc(bufsize, '.'); |
| 61 | sent += bufsize; |
| 62 | } while (child.stdin.write(buf)); |
| 63 | |
| 64 | // Then write a bunch more times. |
| 65 | for (let i = 0; i < 100; i++) { |
| 66 | const buf = Buffer.alloc(bufsize, '.'); |
| 67 | sent += bufsize; |
| 68 | child.stdin.write(buf); |
| 69 | } |
| 70 | |
| 71 | // Now end, before it's all flushed. |
| 72 | child.stdin.end(); |
| 73 | |
| 74 | // now we wait... |
| 75 | } |
| 76 | |
| 77 | function child() { |
| 78 | let received = 0; |
no test coverage detected
searching dependent graphs…