This repository has been archived by the owner on Jul 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 465
[sol-cov] Only collect coverage for provided sources #702
Merged
LogvinovLeon
merged 3 commits into
0xProject:v2-prototype
from
ewingrj:feature/missing-sources
Jun 21, 2018
Merged
[sol-cov] Only collect coverage for provided sources #702
LogvinovLeon
merged 3 commits into
0xProject:v2-prototype
from
ewingrj:feature/missing-sources
Jun 21, 2018
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When solidity generates source maps during contract compilation, the contracts are referred to by an id, which corresponds to an array index. We may not want to cover all sources that were included in a compilation, but because we use array indexes (vs. the id that is provided by solidity compiler) to map the contract to the sourceMap, the provided sourceCodes array must include the code at the correct index. This can result in empty slots in the sourceCodes array. This commit allows the coverage to only be collected for the contracts with provided sourceCode.
ewingrj
changed the title
Only collect coverage for provided sources
[sol-cov] Only collect coverage for provided sources
Jun 14, 2018
LogvinovLeon
suggested changes
Jun 19, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM except for one nit.
packages/sol-cov/src/source_maps.ts
Outdated
@@ -12,6 +12,9 @@ export interface SourceLocation { | |||
} | |||
|
|||
export function getLocationByOffset(str: string): LocationByOffset { | |||
if (_.isUndefined(str)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we check that above and just not call this function?
I'd prefer that solution because now we're checking for undefined the variable that's guaranteed to be undefined by the type system. Let's either change the types or check before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, I checked before
Prettier fails on CI. Please run |
LogvinovLeon
approved these changes
Jun 21, 2018
This was referenced Dec 17, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
When solidity generates source maps during contract compilation, the
contracts are referred to by an id, which corresponds to an array index.
We may not want to cover all sources that were included in a compilation,
but because we use array indexes (vs. the id that is provided by solidity
compiler) to map the contract to the sourceMap, the provided sourceCodes
array must include the code at the correct index. This can result in
empty slots in the sourceCodes array.
This commit allows the coverage to only be collected for the contracts
with provided sourceCode.
How Has This Been Tested?
Tested with our repos. I was not able to run
yarn test
as it failed before I made any changesTypes of changes
Checklist: