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

Function runTest

test/v8-updates/test-linux-perf-logger.js:96–137  ·  view source on GitHub ↗
(test)

Source from the content-addressed store, hash-verified

94];
95
96function runTest(test) {
97 const report = {
98 title: test.title,
99 perfMap: '[uninitialized]',
100 errors: [],
101 };
102
103 const args = test.nodeFlags.concat(fixtures.path('linux-perf-logger.js'));
104 const run = spawnSync(process.execPath, args, { cwd: tmpdir.path, encoding: 'utf8' });
105 if (run.error) {
106 report.errors.push(run.error.stack);
107 return report;
108 }
109 if (run.status !== 0) {
110 report.errors.push(`running script:\n${run.stderr}`);
111 return report;
112 }
113
114 try {
115 report.perfMap = readFileSync(`/tmp/perf-${run.pid}.map`, 'utf8');
116 } catch (err) {
117 report.errors.push(`reading perf map: ${err.stack}`);
118 return report;
119 }
120
121 const hexRegex = '[a-fA-F0-9]+';
122 for (const testRegex of test.matches) {
123 const lineRegex = new RegExp(`${hexRegex} ${hexRegex}.* ${testRegex}`);
124 if (!lineRegex.test(report.perfMap)) {
125 report.errors.push(`Expected to match ${lineRegex}`);
126 }
127 }
128
129 for (const regex of test.noMatches) {
130 const noMatch = new RegExp(regex);
131 if (noMatch.test(report.perfMap)) {
132 report.errors.push(`Expected not to match ${noMatch}`);
133 }
134 }
135
136 return report;
137}
138
139function serializeError(report, index) {
140 return `[ERROR ${index + 1}] ${report.title}

Callers 1

runSuiteFunction · 0.70

Calls 6

concatMethod · 0.80
spawnSyncFunction · 0.50
readFileSyncFunction · 0.50
pathMethod · 0.45
pushMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…