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

Function runTest

test/parallel/test-repl-programmatic-history.js:185–264  ·  view source on GitHub ↗
(assertCleaned)

Source from the content-addressed store, hash-verified

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

Calls 14

setupHistoryMethod · 0.80
beforeFunction · 0.70
nextFunction · 0.70
onCloseFunction · 0.70
cleanupTmpFileFunction · 0.70
setImmediateFunction · 0.50
shiftMethod · 0.45
readFileSyncMethod · 0.45
errorMethod · 0.45
startMethod · 0.45
toStringMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…