()
| 62 | const runTestWrap = common.mustCall(runTest, numtests); |
| 63 | |
| 64 | function runTest() { |
| 65 | const opts = tests.shift(); |
| 66 | if (!opts) return; // All done |
| 67 | |
| 68 | const { expected, skip } = opts; |
| 69 | |
| 70 | // Test unsupported on platform. |
| 71 | if (skip) { |
| 72 | setImmediate(runTestWrap, true); |
| 73 | return; |
| 74 | } |
| 75 | const lastChunks = []; |
| 76 | let i = 0; |
| 77 | |
| 78 | REPL.createInternalRepl(opts.env, { |
| 79 | input: new ActionStream(), |
| 80 | output: new stream.Writable({ |
| 81 | write: common.mustCallAtLeast((chunk, _, next) => { |
| 82 | const output = chunk.toString(); |
| 83 | |
| 84 | if (!opts.showEscapeCodes && |
| 85 | (output[0] === '\x1B' || /^[\r\n]+$/.test(output))) { |
| 86 | return next(); |
| 87 | } |
| 88 | |
| 89 | lastChunks.push(output); |
| 90 | |
| 91 | if (expected.length && !opts.checkTotal) { |
| 92 | try { |
| 93 | assert.strictEqual(output, expected[i]); |
| 94 | } catch (e) { |
| 95 | console.error(`Failed test # ${numtests - tests.length}`); |
| 96 | console.error('Last outputs: ' + inspect(lastChunks, { |
| 97 | breakLength: 5, colors: true |
| 98 | })); |
| 99 | throw e; |
| 100 | } |
| 101 | // TODO(BridgeAR): Auto close on last chunk! |
| 102 | i++; |
| 103 | } |
| 104 | |
| 105 | next(); |
| 106 | }), |
| 107 | }), |
| 108 | allowBlockingCompletions: true, |
| 109 | completer: opts.completer, |
| 110 | prompt, |
| 111 | useColors: false, |
| 112 | preview: opts.preview, |
| 113 | terminal: true |
| 114 | }, common.mustCall((err, repl) => { |
| 115 | if (err) { |
| 116 | console.error(`Failed test # ${numtests - tests.length}`); |
| 117 | throw err; |
| 118 | } |
| 119 | |
| 120 | repl.once('close', common.mustCall(() => { |
| 121 |
no test coverage detected
searching dependent graphs…