(report, fields = [])
| 54 | } |
| 55 | |
| 56 | function _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. |
no test coverage detected
searching dependent graphs…