Skip to content

Commit

Permalink
fix merging uncovered ranges for server/client side coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
cenfun committed Sep 14, 2024
1 parent 4ba0ef2 commit 8986e4c
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions lib/converter/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1350,13 +1350,11 @@ const isCoveredInRanges = (range, uncoveredBytes) => {
const mergeV8Data = (state, stateList) => {
// console.log(stateList);

// const sourcePath = state.sourcePath;
// console.log(sourcePath);
// if (sourcePath.endsWith('scroll_zoom.ts')) {
// console.log('merge v8 data ===================================', sourcePath);
// console.log(stateList.map((it) => it.bytes));
// console.log(stateList.map((it) => it.functions));
// console.log(stateList.map((it) => it.branches.map((b) => [`${b.start}-${b.end}`, JSON.stringify(b.locations.map((l) => l.count))])));
// if (state.sourcePath.endsWith('test.tsx')) {
// console.log('merge v8 bytes ===================================', state.sourcePath);
// console.log('bytes before ============', stateList.map((it) => it.bytes));
// console.log('functions ==============', stateList.map((it) => it.functions));
// console.log('branches ======================', stateList.map((it) => it.branches.map((b) => [`${b.start}-${b.end}`, JSON.stringify(b.locations.map((l) => l.count))])));
// }

// ===========================================================
Expand All @@ -1373,13 +1371,23 @@ const mergeV8Data = (state, stateList) => {
uncoveredBytes.push(range);
}
});
uncoveredList.push(uncoveredBytes);
if (uncoveredBytes.length) {
uncoveredList.push(uncoveredBytes);
}
});

// if (state.sourcePath.endsWith('test.tsx')) {
// console.log('mergedBytes ============', mergedBytes);
// console.log('uncoveredList ============', uncoveredList);
// console.log('=======================================================');
// }

// just remove uncovered range
uncoveredList.forEach((currentBytes) => {
currentBytes.forEach((range) => {
for (const targetBytes of uncoveredList) {
if (targetBytes === currentBytes) {
// self
continue;
}
if (isCoveredInRanges(range, targetBytes)) {
Expand All @@ -1393,6 +1401,10 @@ const mergeV8Data = (state, stateList) => {
// will be dedupeCountRanges in collectFileCoverage
state.bytes = mergedBytes;

// if (state.sourcePath.endsWith('test.tsx')) {
// console.log('bytes after ============', mergedBytes);
// }

// ===========================================================
// functions
const allFunctions = stateList.map((it) => it.functions).flat();
Expand Down

0 comments on commit 8986e4c

Please sign in to comment.