Skip to content

Commit

Permalink
try to support remix client code
Browse files Browse the repository at this point in the history
  • Loading branch information
cenfun committed Sep 15, 2024
1 parent ee19c06 commit 91151a3
Showing 1 changed file with 44 additions and 32 deletions.
76 changes: 44 additions & 32 deletions lib/converter/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,44 @@ const convertCoverages = (list, options, untested) => {

// ========================================================================================================

const isUncoveredRange = (range, key, uncoveredGroups) => {

let uncovered = true;
uncoveredGroups.forEach((group) => {
const { groupMap, state } = group;

// ========================================================
// self key
if (groupMap.has(key)) {
return;
}

// ========================================================
// in all group
for (const item of groupMap.values()) {
if (range.start >= item.start && range.end <= item.end) {
return;
}
}

// ========================================================
// no sourcemap mappings in range
// check original range in decodedMappings
const { decodedMappings } = state;
const item = decodedMappings.find((it) => it.originalOffset >= range.start && it.originalOffset <= range.end);
if (!item) {
return;
}

// ========================================================
uncovered = false;

});

return uncovered;

};

const mergeV8Data = (state, stateList) => {
// console.log(stateList);

Expand Down Expand Up @@ -1473,7 +1511,11 @@ const mergeV8Data = (state, stateList) => {
groupMap.set(key, range);
}
});
uncoveredGroups.push(groupMap);

uncoveredGroups.push({
groupMap,
state: st
});
});

// if (debug) {
Expand All @@ -1482,47 +1524,17 @@ const mergeV8Data = (state, stateList) => {
// console.log('uncoveredGroups ============', uncoveredGroups);
// }

const inAllUncoveredGroups = (range, key) => {

let num = 0;
uncoveredGroups.forEach((groupMap) => {
if (groupMap.has(key)) {
num += 1;
return;
}

for (const item of groupMap.values()) {
if (range.start >= item.start && range.end <= item.end) {
num += 1;
return;
}
}

});

if (num >= uncoveredGroups.length) {
return true;
}

return false;

};

uncoveredMap.forEach((range, key) => {

// in covered range
if (coveredMap.has(key)) {
return;
}

if (inAllUncoveredGroups(range, key)) {
if (isUncoveredRange(range, key, uncoveredGroups)) {
mergedBytes.push(range);
// return;
}

// remix tree shacking
// console.log(range);

});

// will be dedupeCountRanges in collectFileCoverage
Expand Down

0 comments on commit 91151a3

Please sign in to comment.