()
| 284 | } |
| 285 | |
| 286 | function runTest() { |
| 287 | const opts = tests.shift(); |
| 288 | if (!opts) return; // All done |
| 289 | |
| 290 | const { expected, skip } = opts; |
| 291 | |
| 292 | // Test unsupported on platform. |
| 293 | if (skip) { |
| 294 | setImmediate(runTestWrap, true); |
| 295 | return; |
| 296 | } |
| 297 | |
| 298 | const lastChunks = []; |
| 299 | let i = 0; |
| 300 | |
| 301 | REPL.createInternalRepl(opts.env, { |
| 302 | input: new ActionStream(), |
| 303 | output: new stream.Writable({ |
| 304 | write: common.mustCallAtLeast((chunk, _, next) => { |
| 305 | const output = chunk.toString(); |
| 306 | |
| 307 | if (!opts.showEscapeCodes && |
| 308 | (output[0] === '\x1B' || /^[\r\n]+$/.test(output))) { |
| 309 | return next(); |
| 310 | } |
| 311 | |
| 312 | lastChunks.push(output); |
| 313 | |
| 314 | if (expected.length && !opts.checkTotal) { |
| 315 | try { |
| 316 | assert.strictEqual(output, expected[i]); |
| 317 | } catch (e) { |
| 318 | console.error(`Failed test # ${numtests - tests.length}`); |
| 319 | console.error('Last outputs: ' + inspect(lastChunks, { |
| 320 | breakLength: 5, colors: true |
| 321 | })); |
| 322 | throw e; |
| 323 | } |
| 324 | i++; |
| 325 | } |
| 326 | |
| 327 | next(); |
| 328 | }), |
| 329 | }), |
| 330 | completer: opts.completer, |
| 331 | prompt, |
| 332 | useColors: opts.useColors || false, |
| 333 | terminal: true |
| 334 | }, common.mustCall((err, repl) => { |
| 335 | if (err) { |
| 336 | console.error(`Failed test # ${numtests - tests.length}`); |
| 337 | throw err; |
| 338 | } |
| 339 | |
| 340 | repl.once('close', common.mustCall(() => { |
| 341 | if (opts.clean) |
| 342 | cleanupTmpFile(); |
| 343 |
no test coverage detected
searching dependent graphs…