(assertCleaned)
| 189 | const runTestWrap = common.mustCall(runTest, numtests); |
| 190 | |
| 191 | function runTest(assertCleaned) { |
| 192 | const opts = tests.shift(); |
| 193 | if (!opts) return; // All done |
| 194 | |
| 195 | if (assertCleaned) { |
| 196 | try { |
| 197 | assert.strictEqual(fs.readFileSync(defaultHistoryPath, 'utf8'), ''); |
| 198 | } catch (e) { |
| 199 | if (e.code !== 'ENOENT') { |
| 200 | console.error(`Failed test # ${numtests - tests.length}`); |
| 201 | throw e; |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | const env = opts.env; |
| 207 | const test = opts.test; |
| 208 | const expected = opts.expected; |
| 209 | const clean = opts.clean; |
| 210 | const before = opts.before; |
| 211 | |
| 212 | if (before) before(); |
| 213 | |
| 214 | REPL.createInternalRepl(env, { |
| 215 | input: new ActionStream(), |
| 216 | output: new stream.Writable({ |
| 217 | write: common.mustCallAtLeast((chunk, _, next) => { |
| 218 | const output = chunk.toString(); |
| 219 | |
| 220 | // Ignore escapes and blank lines |
| 221 | if (output.charCodeAt(0) === 27 || /^[\r\n]+$/.test(output)) |
| 222 | return next(); |
| 223 | |
| 224 | try { |
| 225 | assert.strictEqual(output, expected.shift()); |
| 226 | } catch (err) { |
| 227 | console.error(`Failed test # ${numtests - tests.length}`); |
| 228 | throw err; |
| 229 | } |
| 230 | next(); |
| 231 | }), |
| 232 | }), |
| 233 | prompt, |
| 234 | useColors: false, |
| 235 | terminal: true |
| 236 | }, common.mustCall((err, repl) => { |
| 237 | if (err) { |
| 238 | console.error(`Failed test # ${numtests - tests.length}`); |
| 239 | throw err; |
| 240 | } |
| 241 | |
| 242 | repl.once('close', () => { |
| 243 | if (repl.historyManager.isFlushing) { |
| 244 | repl.once('flushHistory', onClose); |
| 245 | return; |
| 246 | } |
| 247 | |
| 248 | onClose(); |
no test coverage detected
searching dependent graphs…