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

Function _validateContent

test/common/report.js:56–338  ·  view source on GitHub ↗
(report, fields = [])

Source from the content-addressed store, hash-verified

54}
55
56function _validateContent(report, fields = []) {
57 const isWindows = process.platform === 'win32';
58 const isJavaScriptThreadReport = report.javascriptHeap != null;
59
60 // Verify that all sections are present as own properties of the report.
61 const sections = ['header', 'nativeStack', 'javascriptStack', 'libuv',
62 'sharedObjects', 'resourceUsage', 'workers'];
63
64 if (!process.report.excludeEnv) {
65 sections.push('environmentVariables');
66 }
67
68 if (!isWindows)
69 sections.push('userLimits');
70
71 if (report.uvthreadResourceUsage)
72 sections.push('uvthreadResourceUsage');
73
74 if (isJavaScriptThreadReport)
75 sections.push('javascriptHeap');
76
77 checkForUnknownFields(report, sections);
78 sections.forEach((section) => {
79 assert(Object.hasOwn(report, section));
80 assert(typeof report[section] === 'object' && report[section] !== null);
81 });
82
83 fields.forEach((field) => {
84 function checkLoop(actual, rest, expect) {
85 actual = actual[rest.shift()];
86 if (rest.length === 0 && actual !== undefined) {
87 assert.strictEqual(actual, expect);
88 } else {
89 assert(actual);
90 checkLoop(actual, rest, expect);
91 }
92 }
93 let actual, expect;
94 if (Array.isArray(field)) {
95 [actual, expect] = field;
96 } else {
97 actual = field;
98 expect = undefined;
99 }
100 checkLoop(report, actual.split('.'), expect);
101 });
102
103 // Verify the format of the header section.
104 const header = report.header;
105 const headerFields = ['event', 'trigger', 'filename', 'dumpEventTime',
106 'dumpEventTimeStamp', 'processId', 'commandLine',
107 'nodejsVersion', 'wordSize', 'arch', 'platform',
108 'componentVersions', 'release', 'osName', 'osRelease',
109 'osVersion', 'osMachine', 'cpus', 'host',
110 'glibcVersionRuntime', 'glibcVersionCompiler', 'cwd',
111 'reportVersion', 'networkInterfaces', 'threadId'];
112 checkForUnknownFields(header, headerFields);
113 assert.strictEqual(header.reportVersion, 5); // Increment as needed.

Callers 1

validateContentFunction · 0.85

Calls 15

checkForUnknownFieldsFunction · 0.85
checkLoopFunction · 0.85
StringClass · 0.85
releaseMethod · 0.80
someMethod · 0.80
forEachMethod · 0.65
matchMethod · 0.65
keysMethod · 0.65
assertFunction · 0.50
pushMethod · 0.45
splitMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…