MCPcopy Index your code
hub / github.com/nodejs/node / runTest

Function runTest

test/parallel/test-repl-persistent-history.js:191–266  ·  view source on GitHub ↗
(assertCleaned)

Source from the content-addressed store, hash-verified

189const runTestWrap = common.mustCall(runTest, numtests);
190
191function 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();

Callers 1

Calls 12

beforeFunction · 0.70
nextFunction · 0.70
onCloseFunction · 0.70
cleanupTmpFileFunction · 0.70
setImmediateFunction · 0.50
shiftMethod · 0.45
readFileSyncMethod · 0.45
errorMethod · 0.45
toStringMethod · 0.45
testMethod · 0.45
onceMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…