monocart-coverage-reports 2.10.0 → 2.10.1
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 +4 -2
- package/lib/converter/converter.js +16 -7
- package/lib/converter/find-original-range.js +20 -13
- package/lib/generate.js +3 -1
- package/lib/packages/monocart-coverage-assets.js +1 -1
- package/lib/platform/share.js +6 -0
- package/lib/reports/custom.js +34 -0
- package/lib/reports/markdown-details.js +1 -2
- package/lib/reports/markdown-summary.js +1 -2
- package/lib/utils/markdown.js +2 -2
- package/lib/utils/util.js +86 -30
- package/lib/v8/v8.js +2 -1
- package/package.json +116 -116
package/README.md
CHANGED
|
@@ -116,8 +116,10 @@ For more information, see [Command Line](#command-line)
|
|
|
116
116
|

|
|
117
117
|
|
|
118
118
|
- `v8-json`
|
|
119
|
-
- Save `CoverageResults` to a json file
|
|
120
|
-
-
|
|
119
|
+
- Save `CoverageResults` to a json file (defaults to [`coverage-report.json`](https://cenfun.github.io/monocart-coverage-reports/v8-and-istanbul/coverage-report.json)).
|
|
120
|
+
- Shows native V8 code coverage with VSCode extension [monocart-coverage-vscode](https://github.com/cenfun/monocart-coverage-vscode)
|
|
121
|
+
|
|
122
|
+

|
|
121
123
|
|
|
122
124
|
> Istanbul build-in reports (both V8 and Istanbul data):
|
|
123
125
|
|
|
@@ -66,8 +66,8 @@ const applyBytesToLines = (bytes, locator, lineMap) => {
|
|
|
66
66
|
start, end, count, ignored
|
|
67
67
|
} = range;
|
|
68
68
|
|
|
69
|
-
// no need handle ignored
|
|
70
|
-
if (
|
|
69
|
+
// no need handle ignored byte
|
|
70
|
+
if (ignored) {
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -141,9 +141,8 @@ const handleLinesCoverage = (bytes, locator, ignoredRanges) => {
|
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
lineItem
|
|
145
|
-
|
|
146
|
-
lineItem.uncoveredPieces = [];
|
|
144
|
+
Util.initLineCoverage(lineItem);
|
|
145
|
+
|
|
147
146
|
lineMap.set(line, lineItem);
|
|
148
147
|
});
|
|
149
148
|
|
|
@@ -507,6 +506,11 @@ const handleGeneratedBytesCoverage = (state) => {
|
|
|
507
506
|
if (js) {
|
|
508
507
|
coverageList.forEach((block) => {
|
|
509
508
|
block.ranges.forEach((range) => {
|
|
509
|
+
|
|
510
|
+
const { fixedStart, fixedEnd } = Util.fixSourceRange(state.locator, range.startOffset, range.endOffset);
|
|
511
|
+
range.startOffset = fixedStart;
|
|
512
|
+
range.endOffset = fixedEnd;
|
|
513
|
+
|
|
510
514
|
addJsBytesCoverage(state, range);
|
|
511
515
|
});
|
|
512
516
|
});
|
|
@@ -555,7 +559,9 @@ const handleOriginalFunctionsCoverage = (state, originalStateMap) => {
|
|
|
555
559
|
start, end, bodyStart, bodyEnd
|
|
556
560
|
} = it;
|
|
557
561
|
|
|
558
|
-
const result = findOriginalRange(start, end, state, originalStateMap,
|
|
562
|
+
const result = findOriginalRange(start, end, state, originalStateMap, {
|
|
563
|
+
checkName: true
|
|
564
|
+
});
|
|
559
565
|
if (result.error) {
|
|
560
566
|
logMappingErrors('function', result);
|
|
561
567
|
return;
|
|
@@ -796,6 +802,7 @@ const handleOriginalEmptyBytesCoverage = (state, originalStateMap) => {
|
|
|
796
802
|
});
|
|
797
803
|
};
|
|
798
804
|
|
|
805
|
+
|
|
799
806
|
const handleAllOriginalBytesCoverage = (state, originalStateMap) => {
|
|
800
807
|
|
|
801
808
|
const { js, coverageList } = state;
|
|
@@ -818,7 +825,9 @@ const handleAllOriginalBytesCoverage = (state, originalStateMap) => {
|
|
|
818
825
|
startOffset, endOffset, count
|
|
819
826
|
} = range;
|
|
820
827
|
|
|
821
|
-
const result = findOriginalRange(startOffset, endOffset, state, originalStateMap
|
|
828
|
+
const result = findOriginalRange(startOffset, endOffset, state, originalStateMap, {
|
|
829
|
+
fixOriginalRange: true
|
|
830
|
+
});
|
|
822
831
|
if (result.error) {
|
|
823
832
|
logMappingErrors('byte', result);
|
|
824
833
|
return;
|
|
@@ -534,13 +534,13 @@ const getGeneratedText = (m1, m2, state, offset) => {
|
|
|
534
534
|
};
|
|
535
535
|
|
|
536
536
|
// ========================================================================================================
|
|
537
|
-
const getFunctionName = (mp, state,
|
|
538
|
-
if (checkName && typeof mp.nameIndex !== 'undefined') {
|
|
537
|
+
const getFunctionName = (mp, state, options) => {
|
|
538
|
+
if (options.checkName && typeof mp.nameIndex !== 'undefined') {
|
|
539
539
|
return state.sourceMapNames[mp.nameIndex];
|
|
540
540
|
}
|
|
541
541
|
};
|
|
542
542
|
|
|
543
|
-
const getFixedOriginalStart = (start, mappings, state, cache,
|
|
543
|
+
const getFixedOriginalStart = (start, mappings, state, cache, options) => {
|
|
544
544
|
|
|
545
545
|
const [m1, m2] = mappings;
|
|
546
546
|
const { originalState, crossStart } = cache;
|
|
@@ -549,7 +549,7 @@ const getFixedOriginalStart = (start, mappings, state, cache, checkName) => {
|
|
|
549
549
|
if (crossStart) {
|
|
550
550
|
return {
|
|
551
551
|
originalStart: m2.originalOffset,
|
|
552
|
-
originalName: getFunctionName(m2, state,
|
|
552
|
+
originalName: getFunctionName(m2, state, options)
|
|
553
553
|
};
|
|
554
554
|
}
|
|
555
555
|
|
|
@@ -581,7 +581,7 @@ const getFixedOriginalStart = (start, mappings, state, cache, checkName) => {
|
|
|
581
581
|
|
|
582
582
|
return {
|
|
583
583
|
originalStart: originalOffset + originalPos,
|
|
584
|
-
originalName: getFunctionName(m1, state,
|
|
584
|
+
originalName: getFunctionName(m1, state, options)
|
|
585
585
|
};
|
|
586
586
|
};
|
|
587
587
|
|
|
@@ -642,18 +642,18 @@ const getFixedOriginalEnd = (end, mappings, state, cache) => {
|
|
|
642
642
|
|
|
643
643
|
// ========================================================================================================
|
|
644
644
|
|
|
645
|
-
const getOriginalStartPosition = (cache, state,
|
|
645
|
+
const getOriginalStartPosition = (cache, state, options) => {
|
|
646
646
|
|
|
647
647
|
const { start, startMappings } = cache;
|
|
648
648
|
|
|
649
649
|
if (Array.isArray(startMappings)) {
|
|
650
|
-
return getFixedOriginalStart(start, startMappings, state, cache,
|
|
650
|
+
return getFixedOriginalStart(start, startMappings, state, cache, options);
|
|
651
651
|
}
|
|
652
652
|
|
|
653
653
|
// Exact match
|
|
654
654
|
return {
|
|
655
655
|
originalStart: startMappings.originalOffset,
|
|
656
|
-
originalName: getFunctionName(startMappings, state,
|
|
656
|
+
originalName: getFunctionName(startMappings, state, options)
|
|
657
657
|
};
|
|
658
658
|
};
|
|
659
659
|
|
|
@@ -880,11 +880,12 @@ const getMappingInfo = (start, end, state) => {
|
|
|
880
880
|
};
|
|
881
881
|
};
|
|
882
882
|
|
|
883
|
-
|
|
883
|
+
|
|
884
|
+
const findOriginalRange = (start, end, state, originalMap, options = {}) => {
|
|
884
885
|
|
|
885
886
|
const { sourcePath, rangeCache } = state;
|
|
886
887
|
|
|
887
|
-
const key = `${start}_${end}`;
|
|
888
|
+
const key = `${start}_${end}_${Boolean(options.fixOriginalRange)}`;
|
|
888
889
|
if (rangeCache.has(key)) {
|
|
889
890
|
return rangeCache.get(key);
|
|
890
891
|
}
|
|
@@ -909,7 +910,7 @@ const findOriginalRange = (start, end, state, originalMap, checkName) => {
|
|
|
909
910
|
return createMappingError(cache.errors);
|
|
910
911
|
}
|
|
911
912
|
|
|
912
|
-
const originalStartResult = getOriginalStartPosition(cache, state,
|
|
913
|
+
const originalStartResult = getOriginalStartPosition(cache, state, options);
|
|
913
914
|
const { originalStart, originalName } = originalStartResult;
|
|
914
915
|
// could be used for end
|
|
915
916
|
cache.originalStart = originalStart;
|
|
@@ -926,13 +927,13 @@ const findOriginalRange = (start, end, state, originalMap, checkName) => {
|
|
|
926
927
|
}
|
|
927
928
|
|
|
928
929
|
const { originalState } = cache;
|
|
930
|
+
const locator = originalState.locator;
|
|
929
931
|
|
|
930
|
-
const inComment =
|
|
932
|
+
const inComment = locator.lineParser.commentParser.isComment(originalStart, originalEnd);
|
|
931
933
|
if (inComment) {
|
|
932
934
|
return createMappingError(['the range in a original comment']);
|
|
933
935
|
}
|
|
934
936
|
|
|
935
|
-
|
|
936
937
|
const res = {
|
|
937
938
|
start: originalStart,
|
|
938
939
|
end: originalEnd,
|
|
@@ -940,6 +941,12 @@ const findOriginalRange = (start, end, state, originalMap, checkName) => {
|
|
|
940
941
|
originalState
|
|
941
942
|
};
|
|
942
943
|
|
|
944
|
+
if (options.fixOriginalRange) {
|
|
945
|
+
const { fixedStart, fixedEnd } = Util.fixSourceRange(locator, originalStart, originalEnd);
|
|
946
|
+
res.start = fixedStart;
|
|
947
|
+
res.end = fixedEnd;
|
|
948
|
+
}
|
|
949
|
+
|
|
943
950
|
// cache response
|
|
944
951
|
rangeCache.set(key, res);
|
|
945
952
|
|
package/lib/generate.js
CHANGED
|
@@ -32,6 +32,8 @@ const { markdownSummaryReport } = require('./reports/markdown-summary.js');
|
|
|
32
32
|
|
|
33
33
|
const { rawReport } = require('./reports/raw.js');
|
|
34
34
|
|
|
35
|
+
const { customReport } = require('./reports/custom.js');
|
|
36
|
+
|
|
35
37
|
const allBuiltInReports = {
|
|
36
38
|
// v8
|
|
37
39
|
'v8': 'v8',
|
|
@@ -208,7 +210,7 @@ const generateCoverageReports = async (dataList, sourceCache, options) => {
|
|
|
208
210
|
if (builtInHandler) {
|
|
209
211
|
await builtInHandler(coverageResults, reportOptions, options);
|
|
210
212
|
} else {
|
|
211
|
-
await
|
|
213
|
+
await customReport(reportName, coverageResults, reportOptions, options);
|
|
212
214
|
}
|
|
213
215
|
Util.logTime(`┌ [generate] saved report: ${reportName}`, t1);
|
|
214
216
|
}
|