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

Function runTest

test/parallel/test-repl-permission-model.js:64–134  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

62const runTestWrap = common.mustCall(runTest, numtests);
63
64function 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

Callers 1

Calls 10

nextFunction · 0.70
inspectFunction · 0.70
setImmediateFunction · 0.50
shiftMethod · 0.45
toStringMethod · 0.45
testMethod · 0.45
pushMethod · 0.45
errorMethod · 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…