monocart-coverage-reports 2.0.6 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -22
- package/lib/converter/ast.js +2 -3
- package/lib/converter/branches.js +1 -37
- package/lib/converter/converter.js +398 -394
- package/lib/converter/find-in-ranges.js +39 -0
- package/lib/converter/ignore.js +130 -0
- package/lib/default/options.js +3 -0
- package/lib/generate.js +75 -67
- package/lib/index.d.ts +8 -2
- package/lib/index.js +1 -5
- package/lib/istanbul/istanbul-summary.js +1 -2
- package/lib/istanbul/istanbul.js +2 -2
- package/lib/packages/monocart-coverage-v8.js +1 -1
- package/lib/packages/monocart-coverage-vendor.js +28 -28
- package/lib/utils/dedupe.js +0 -5
- package/lib/v8/v8-summary.js +85 -34
- package/lib/v8/v8.js +27 -83
- package/package.json +1 -1
package/lib/utils/dedupe.js
CHANGED
|
@@ -62,11 +62,6 @@ const dedupeRanges = (ranges) => {
|
|
|
62
62
|
// apply to js count ranges
|
|
63
63
|
const dedupeCountRanges = (ranges) => {
|
|
64
64
|
|
|
65
|
-
// v8 ranges format
|
|
66
|
-
// { startOffset: 0, endOffset: 6, count: 0 },
|
|
67
|
-
// { startOffset: 0, endOffset: 6, count: 1 },
|
|
68
|
-
// { startOffset: 0, endOffset: 297, count: 1 }
|
|
69
|
-
|
|
70
65
|
// count ranges format
|
|
71
66
|
// { start: 0, end: 6, count: 0 }
|
|
72
67
|
|
package/lib/v8/v8-summary.js
CHANGED
|
@@ -1,32 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// url, text, ranges: [ {start, end} ]
|
|
4
|
-
const getCssSummaryBytes = (item) => {
|
|
5
|
-
|
|
6
|
-
const source = item.source;
|
|
7
|
-
const total = source.length;
|
|
8
|
-
|
|
9
|
-
let covered = 0;
|
|
10
|
-
const bytes = item.data.bytes;
|
|
11
|
-
if (bytes) {
|
|
12
|
-
bytes.forEach((range) => {
|
|
13
|
-
if (range.count > 0) {
|
|
14
|
-
covered += range.end - range.start;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// no functions for css
|
|
20
|
-
return {
|
|
21
|
-
total,
|
|
22
|
-
covered
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// url, source, ranges:[{start,end, count}]
|
|
28
|
-
const getJsSummaryBytes = (item) => {
|
|
1
|
+
const Util = require('../utils/util.js');
|
|
29
2
|
|
|
3
|
+
// both css and js
|
|
4
|
+
const getV8SummaryBytes = (item) => {
|
|
30
5
|
const source = item.source;
|
|
31
6
|
const total = source.length;
|
|
32
7
|
|
|
@@ -36,6 +11,10 @@ const getJsSummaryBytes = (item) => {
|
|
|
36
11
|
|
|
37
12
|
let endPos = 0;
|
|
38
13
|
uncoveredBytes.forEach((range) => {
|
|
14
|
+
if (range.ignored) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
39
18
|
const { start, end } = range;
|
|
40
19
|
|
|
41
20
|
if (start > endPos) {
|
|
@@ -63,13 +42,85 @@ const getJsSummaryBytes = (item) => {
|
|
|
63
42
|
};
|
|
64
43
|
};
|
|
65
44
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
45
|
+
// calculate uncovered, pct, status
|
|
46
|
+
const calculatePctAndStatus = (item, watermarks) => {
|
|
47
|
+
Object.keys(item).forEach((k) => {
|
|
48
|
+
const indicateData = item[k];
|
|
49
|
+
indicateData.uncovered = indicateData.total - indicateData.covered;
|
|
50
|
+
|
|
51
|
+
let pct = '';
|
|
52
|
+
let status = 'unknown';
|
|
53
|
+
|
|
54
|
+
if (indicateData.total) {
|
|
55
|
+
pct = Util.PNF(indicateData.covered, indicateData.total, 2);
|
|
56
|
+
status = Util.getStatus(pct, watermarks[k]);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
indicateData.pct = pct;
|
|
60
|
+
indicateData.status = status;
|
|
61
|
+
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const getV8Summary = (v8list, watermarks) => {
|
|
66
|
+
|
|
67
|
+
// get bytes summary
|
|
68
|
+
v8list.forEach((entry) => {
|
|
69
|
+
entry.summary.bytes = getV8SummaryBytes(entry);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// overall summary
|
|
73
|
+
const summary = {
|
|
74
|
+
bytes: {
|
|
75
|
+
total: 0,
|
|
76
|
+
covered: 0
|
|
77
|
+
},
|
|
78
|
+
functions: {
|
|
79
|
+
total: 0,
|
|
80
|
+
covered: 0
|
|
81
|
+
},
|
|
82
|
+
branches: {
|
|
83
|
+
total: 0,
|
|
84
|
+
covered: 0
|
|
85
|
+
},
|
|
86
|
+
lines: {
|
|
87
|
+
total: 0,
|
|
88
|
+
covered: 0,
|
|
89
|
+
blank: 0,
|
|
90
|
+
comment: 0
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
v8list.forEach((entry) => {
|
|
95
|
+
const entrySummary = entry.summary;
|
|
96
|
+
calculatePctAndStatus(entrySummary, watermarks);
|
|
97
|
+
|
|
98
|
+
// do NOT add debug file
|
|
99
|
+
if (entry.debug) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
Object.keys(entrySummary).forEach((k) => {
|
|
104
|
+
const indicateData = entrySummary[k];
|
|
105
|
+
if (!indicateData) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
summary[k].total += indicateData.total;
|
|
109
|
+
summary[k].covered += indicateData.covered;
|
|
110
|
+
|
|
111
|
+
if (k === 'lines') {
|
|
112
|
+
summary[k].blank += indicateData.blank;
|
|
113
|
+
summary[k].comment += indicateData.comment;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// calculate overall summary
|
|
119
|
+
calculatePctAndStatus(summary, watermarks);
|
|
120
|
+
|
|
121
|
+
return summary;
|
|
71
122
|
};
|
|
72
123
|
|
|
73
124
|
module.exports = {
|
|
74
|
-
|
|
125
|
+
getV8Summary
|
|
75
126
|
};
|
package/lib/v8/v8.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const Util = require('../utils/util.js');
|
|
3
|
-
const {
|
|
3
|
+
const { getV8Summary } = require('./v8-summary.js');
|
|
4
4
|
const { dedupeRanges } = require('../utils/dedupe.js');
|
|
5
5
|
const { getSourcePath } = require('../utils/source-path.js');
|
|
6
6
|
const { mergeScriptCovs } = require('../packages/monocart-coverage-vendor.js');
|
|
@@ -186,17 +186,9 @@ const saveV8JsonReport = async (reportData, options, v8JsonOptions) => {
|
|
|
186
186
|
|
|
187
187
|
const saveV8HtmlReport = async (reportData, options, v8HtmlOptions) => {
|
|
188
188
|
|
|
189
|
-
// V8 only options, merged with root options
|
|
190
|
-
const v8MergedOptions = {
|
|
191
|
-
outputFile: options.outputFile,
|
|
192
|
-
inline: options.inline,
|
|
193
|
-
assetsPath: options.assetsPath,
|
|
194
|
-
... v8HtmlOptions
|
|
195
|
-
};
|
|
196
|
-
|
|
197
189
|
const {
|
|
198
190
|
outputFile, inline, assetsPath
|
|
199
|
-
} =
|
|
191
|
+
} = v8HtmlOptions;
|
|
200
192
|
|
|
201
193
|
// resolve full report path
|
|
202
194
|
const reportPath = path.resolve(options.outputDir, outputFile);
|
|
@@ -229,27 +221,8 @@ const saveV8HtmlReport = async (reportData, options, v8HtmlOptions) => {
|
|
|
229
221
|
return htmlPath;
|
|
230
222
|
};
|
|
231
223
|
|
|
232
|
-
// calculate uncovered, pct, status
|
|
233
|
-
const calculatePctAndStatus = (item, watermarks) => {
|
|
234
|
-
Object.keys(item).forEach((k) => {
|
|
235
|
-
const indicateData = item[k];
|
|
236
|
-
indicateData.uncovered = indicateData.total - indicateData.covered;
|
|
237
|
-
|
|
238
|
-
let pct = '';
|
|
239
|
-
let status = 'unknown';
|
|
240
|
-
|
|
241
|
-
if (indicateData.total) {
|
|
242
|
-
pct = Util.PNF(indicateData.covered, indicateData.total, 2);
|
|
243
|
-
status = Util.getStatus(pct, watermarks[k]);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
indicateData.pct = pct;
|
|
247
|
-
indicateData.status = status;
|
|
248
|
-
|
|
249
|
-
});
|
|
250
|
-
};
|
|
251
|
-
|
|
252
224
|
const saveV8Report = async (v8list, options) => {
|
|
225
|
+
|
|
253
226
|
const defaultWatermarks = {
|
|
254
227
|
bytes: [50, 80],
|
|
255
228
|
functions: [50, 80],
|
|
@@ -258,51 +231,7 @@ const saveV8Report = async (v8list, options) => {
|
|
|
258
231
|
};
|
|
259
232
|
const watermarks = Util.resolveWatermarks(defaultWatermarks, options.watermarks);
|
|
260
233
|
|
|
261
|
-
|
|
262
|
-
v8list.forEach((entry) => {
|
|
263
|
-
entry.summary.bytes = getV8SummaryBytes(entry);
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
// overall summary
|
|
267
|
-
const summaryList = v8list.map((entry) => entry.summary);
|
|
268
|
-
const summary = {
|
|
269
|
-
bytes: {
|
|
270
|
-
total: 0,
|
|
271
|
-
covered: 0
|
|
272
|
-
},
|
|
273
|
-
functions: {
|
|
274
|
-
total: 0,
|
|
275
|
-
covered: 0
|
|
276
|
-
},
|
|
277
|
-
branches: {
|
|
278
|
-
total: 0,
|
|
279
|
-
covered: 0
|
|
280
|
-
},
|
|
281
|
-
lines: {
|
|
282
|
-
total: 0,
|
|
283
|
-
covered: 0,
|
|
284
|
-
blank: 0,
|
|
285
|
-
comment: 0
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
summaryList.forEach((item) => {
|
|
289
|
-
calculatePctAndStatus(item, watermarks);
|
|
290
|
-
Object.keys(item).forEach((k) => {
|
|
291
|
-
const indicateData = item[k];
|
|
292
|
-
if (!indicateData) {
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
summary[k].total += indicateData.total;
|
|
296
|
-
summary[k].covered += indicateData.covered;
|
|
297
|
-
|
|
298
|
-
if (k === 'lines') {
|
|
299
|
-
summary[k].blank += indicateData.blank;
|
|
300
|
-
summary[k].comment += indicateData.comment;
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
calculatePctAndStatus(summary, watermarks);
|
|
234
|
+
const summary = getV8Summary(v8list, watermarks);
|
|
306
235
|
|
|
307
236
|
const reportData = {
|
|
308
237
|
name: options.name,
|
|
@@ -317,23 +246,38 @@ const saveV8Report = async (v8list, options) => {
|
|
|
317
246
|
// v8 reports
|
|
318
247
|
const v8Map = options.reportGroup.v8;
|
|
319
248
|
|
|
249
|
+
// v8 html
|
|
250
|
+
const v8Options = v8Map.v8;
|
|
251
|
+
if (v8Options) {
|
|
252
|
+
|
|
253
|
+
// V8 only options, merged with root options
|
|
254
|
+
const v8HtmlOptions = {
|
|
255
|
+
outputFile: options.outputFile,
|
|
256
|
+
inline: options.inline,
|
|
257
|
+
assetsPath: options.assetsPath,
|
|
258
|
+
metrics: options.metrics,
|
|
259
|
+
... v8Options
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// add metrics to data
|
|
263
|
+
reportData.metrics = v8HtmlOptions.metrics;
|
|
264
|
+
|
|
265
|
+
outputPath = await saveV8HtmlReport(reportData, options, v8HtmlOptions);
|
|
266
|
+
}
|
|
267
|
+
|
|
320
268
|
// v8 json
|
|
321
269
|
const v8JsonOptions = v8Map['v8-json'];
|
|
322
270
|
if (v8JsonOptions) {
|
|
323
271
|
outputPath = await saveV8JsonReport(reportData, options, v8JsonOptions);
|
|
324
272
|
}
|
|
325
273
|
|
|
326
|
-
// v8 html
|
|
327
|
-
const v8HtmlOptions = v8Map.v8;
|
|
328
|
-
if (v8HtmlOptions) {
|
|
329
|
-
outputPath = await saveV8HtmlReport(reportData, options, v8HtmlOptions);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
274
|
const reportPath = Util.resolveReportPath(options, () => {
|
|
333
275
|
return outputPath;
|
|
334
276
|
});
|
|
335
277
|
|
|
336
|
-
const
|
|
278
|
+
const summaryList = v8list.map((entry) => entry.summary);
|
|
279
|
+
|
|
280
|
+
const coverageResults = {
|
|
337
281
|
type: 'v8',
|
|
338
282
|
reportPath,
|
|
339
283
|
name: options.name,
|
|
@@ -342,7 +286,7 @@ const saveV8Report = async (v8list, options) => {
|
|
|
342
286
|
files: summaryList
|
|
343
287
|
};
|
|
344
288
|
|
|
345
|
-
return
|
|
289
|
+
return coverageResults;
|
|
346
290
|
};
|
|
347
291
|
|
|
348
292
|
module.exports = {
|