aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-cov/src/source_maps.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-06-22 01:28:35 +0800
committerGitHub <noreply@github.com>2018-06-22 01:28:35 +0800
commiteae2a4df8b8d8874f7e8115530e8f25ceb607b4e (patch)
treeb83b5de5e5948f85cd5ff5886fe3b43e50d8fef8 /packages/sol-cov/src/source_maps.ts
parent11b35b89f5b7d0f1b91bdc15fa3079a5ea57da38 (diff)
parentade8e95d2e1c46bb1a3f8212a6eac5f396bc3e94 (diff)
downloaddexon-sol-tools-eae2a4df8b8d8874f7e8115530e8f25ceb607b4e.tar
dexon-sol-tools-eae2a4df8b8d8874f7e8115530e8f25ceb607b4e.tar.gz
dexon-sol-tools-eae2a4df8b8d8874f7e8115530e8f25ceb607b4e.tar.bz2
dexon-sol-tools-eae2a4df8b8d8874f7e8115530e8f25ceb607b4e.tar.lz
dexon-sol-tools-eae2a4df8b8d8874f7e8115530e8f25ceb607b4e.tar.xz
dexon-sol-tools-eae2a4df8b8d8874f7e8115530e8f25ceb607b4e.tar.zst
dexon-sol-tools-eae2a4df8b8d8874f7e8115530e8f25ceb607b4e.zip
Merge pull request #702 from perissology/feature/missing-sources
[sol-cov] Only collect coverage for provided sources
Diffstat (limited to 'packages/sol-cov/src/source_maps.ts')
-rw-r--r--packages/sol-cov/src/source_maps.ts4
1 files changed, 2 insertions, 2 deletions
diff --git a/packages/sol-cov/src/source_maps.ts b/packages/sol-cov/src/source_maps.ts
index f9503e16c..90b21dda1 100644
--- a/packages/sol-cov/src/source_maps.ts
+++ b/packages/sol-cov/src/source_maps.ts
@@ -36,7 +36,7 @@ export function parseSourceMap(
): { [programCounter: number]: SourceRange } {
const bytecode = Uint8Array.from(Buffer.from(bytecodeHex, 'hex'));
const pcToInstructionIndex: { [programCounter: number]: number } = getPcToInstructionIndexMapping(bytecode);
- const locationByOffsetByFileIndex = _.map(sourceCodes, getLocationByOffset);
+ const locationByOffsetByFileIndex = _.map(sourceCodes, s => (_.isUndefined(s) ? {} : getLocationByOffset(s)));
const entries = srcMap.split(';');
let lastParsedEntry: SourceLocation = {} as any;
const instructionIndexToSourceRange: { [instructionIndex: number]: SourceRange } = {};
@@ -56,7 +56,7 @@ export function parseSourceMap(
length,
fileIndex,
};
- if (parsedEntry.fileIndex !== -1) {
+ if (parsedEntry.fileIndex !== -1 && !_.isUndefined(locationByOffsetByFileIndex[parsedEntry.fileIndex])) {
const sourceRange = {
location: {
start: locationByOffsetByFileIndex[parsedEntry.fileIndex][parsedEntry.offset],