Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not remove contract from coverage report if a function is missing statements or branches #1178

Merged
merged 1 commit into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased](https://github.com/eth-brownie/brownie)
### Fixed
- Recursively kill all RPC child processes on exit ([#1200](https://github.com/eth-brownie/brownie/pull/1200))

### Fixed
- Issue with testing reverted contracts not found in deployment map ([#1195](https://github.com/eth-brownie/brownie/pull/1195))
- Fix issue with missing contracts in coverage report ([#1178](https://github.com/eth-brownie/brownie/pull/1178))

## [1.16.0](https://github.com/eth-brownie/brownie/tree/v1.16.0) - 2021-08-08
### Added
Expand Down
17 changes: 10 additions & 7 deletions brownie/test/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,19 +223,22 @@ def _split_by_fn(build, coverage_eval):

def _split(coverage_eval, coverage_map, key):
results = {}
for fn, map_ in coverage_map["statements"][key].items():
results[fn] = [[i for i in map_ if int(i) in coverage_eval[0]], [], []]
for fn, map_ in coverage_map["branches"][key].items():
results[fn][1] = [i for i in map_ if int(i) in coverage_eval[1]]
results[fn][2] = [i for i in map_ if int(i) in coverage_eval[2]]
branches = coverage_map["branches"][key]
statements = coverage_map["statements"][key]
for fn in branches.keys() & statements.keys():
results[fn] = [
[i for i in statements[fn] if int(i) in coverage_eval[0]],
[i for i in branches[fn] if int(i) in coverage_eval[1]],
[i for i in branches[fn] if int(i) in coverage_eval[2]],
]
return results


def _statement_totals(coverage_eval, coverage_map, exclude_contracts):
result = {}
count, total = 0, 0
for path, fn in [(k, x) for k, v in coverage_eval.items() for x in v]:
if fn.split(".")[0] in exclude_contracts:
if fn.split(".")[0] in exclude_contracts or fn not in coverage_eval[path]:
continue
count += len(coverage_eval[path][fn][0])
total += len(coverage_map[path][fn])
Expand All @@ -249,7 +252,7 @@ def _branch_totals(coverage_eval, coverage_map, exclude_contracts):
for path, fn in [(k, x) for k, v in coverage_map.items() for x in v]:
if fn.split(".")[0] in exclude_contracts:
continue
if path not in coverage_eval:
if path not in coverage_eval or fn not in coverage_eval[path]:
true, false = 0, 0
else:
true = len(coverage_eval[path][fn][2])
Expand Down