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

Function runTestFile

lib/internal/test_runner/runner.js:492–601  ·  view source on GitHub ↗
(path, filesWatcher, opts)

Source from the content-addressed store, hash-verified

490}
491
492function runTestFile(path, filesWatcher, opts) {
493 const watchMode = filesWatcher != null;
494 const testPath = path === kIsolatedProcessName ? '' : path;
495 const testOpts = { __proto__: null, signal: opts.signal };
496 const subtest = opts.root.createSubtest(FileTest, testPath, testOpts, async (t) => {
497 const args = getRunArgs(path, opts);
498 const stdio = ['pipe', 'pipe', 'pipe'];
499 const env = { __proto__: null, NODE_TEST_CONTEXT: 'child-v8', ...(opts.env || process.env) };
500
501 // Acquire a worker ID from the pool for process isolation mode
502 let workerId;
503 if (opts.workerIdPool) {
504 workerId = opts.workerIdPool.acquire();
505 env.NODE_TEST_WORKER_ID = String(workerId);
506 debug('Assigned worker ID %d to test file: %s', workerId, path);
507 }
508
509 if (watchMode) {
510 stdio.push('ipc');
511 env.WATCH_REPORT_DEPENDENCIES = '1';
512 }
513 if (opts.root.harness.shouldColorizeTestFiles) {
514 env.FORCE_COLOR = '1';
515 }
516
517 const child = spawn(
518 process.execPath, args,
519 {
520 __proto__: null,
521 signal: t.signal,
522 encoding: 'utf8',
523 env,
524 stdio,
525 cwd: opts.cwd,
526 },
527 );
528 if (watchMode) {
529 filesWatcher.runningProcesses.set(path, child);
530 filesWatcher.watcher.watchChildProcessModules(child, path);
531 }
532
533 let err;
534
535 child.on('error', (error) => {
536 err = error;
537 });
538
539 child.stdout.on('data', (data) => {
540 subtest.parseMessage(data);
541 });
542
543 const rl = new Interface({ __proto__: null, input: child.stderr });
544 rl.on('line', (line) => {
545 if (isInspectorMessage(line)) {
546 process.stderr.write(line + '\n');
547 return;
548 }
549

Callers 2

restartTestFileFunction · 0.85
runFunction · 0.85

Calls 15

closeMethod · 0.95
getRunArgsFunction · 0.85
StringClass · 0.85
isInspectorMessageFunction · 0.85
ObjectAssignFunction · 0.85
createSubtestMethod · 0.80
acquireMethod · 0.80
parseMessageMethod · 0.80
addToReportMethod · 0.80
deleteMethod · 0.65
debugFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…