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

When invoked with --calls, show call coverage #666

Merged
merged 26 commits into from Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a3dd58f
When invoked with --calls, show call coverage
pablmart Aug 31, 2022
6686c6c
Fix CallCoverage class documentation
pablmart Aug 31, 2022
fae82e7
Extra colgroups for decisions and calls if enabled.
pablmart Aug 31, 2022
4b1a45c
Fix {%if indentations
pablmart Aug 31, 2022
7d45c6f
Use separate styles and variables for call coverage
pablmart Aug 31, 2022
3640cd5
Added a test for call coverage
pablmart Aug 31, 2022
b5155a2
State that calls coverage only is for HTML (not json yet)
pablmart Aug 31, 2022
c805992
Fix PEP-8 formatting errors
pablmart Sep 1, 2022
b5ea922
Update CHANGELOG and AUTHORS
pablmart Sep 1, 2022
a3c57b6
Fix misplaced item in ChangeLog
pablmart Sep 1, 2022
f5d08f6
Fix more formatting errors
pablmart Sep 1, 2022
f4d8a7f
Remove white line that made many expected html output to fail
pablmart Sep 1, 2022
fa7490c
Updated example_html.details.css
pablmart Sep 1, 2022
717c054
Updated test references retrieved from Ubuntu 18.04 vm
pablmart Sep 7, 2022
c611c87
Extend test with logical expression.
Spacetown Sep 7, 2022
e04dbb1
Generate reference data.
Spacetown Sep 7, 2022
d3ee569
Fix test failure.
Spacetown Sep 7, 2022
f49826d
Insert call coverage (optionally) in json output
pablmart Sep 14, 2022
37881e3
Merge branch 'master' of github.com:odkq/gcovr
pablmart Sep 14, 2022
61aa9b1
Support for merging call coverage from json reports
pablmart Sep 16, 2022
e6194ec
Preserve call number when writing the json file
pablmart Sep 20, 2022
1b0f9e7
assert that callno's are the same on call cov merging
pablmart Sep 22, 2022
2d76487
Fix PEP-8 issues
pablmart Sep 27, 2022
a733f02
Fix PEP-8 issues
Spacetown Sep 27, 2022
6ab7cd4
Fix test and update reference.
Spacetown Sep 27, 2022
c316796
Fix some version identifiers in JSON test data.
Spacetown Sep 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion gcovr/coverage.py
Expand Up @@ -80,13 +80,15 @@ class CallCoverage:
Whether the call was performed.
"""

__slots__ = "covered"
__slots__ = "covered", "callno"

def __init__(
self,
callno: int,
covered: bool,
) -> None:
self.covered = covered
self.callno = callno

@property
def is_covered(self) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion gcovr/gcov_parser.py
Expand Up @@ -516,8 +516,8 @@ def _gather_coverage_from_line(
if context.flags & ParserFlags.PARSE_CALLS:
insert_call_coverage(
line_cov,
callno,
CallCoverage(
callno=callno,
covered=(returned > 0),
),
)
Expand Down
4 changes: 2 additions & 2 deletions gcovr/merging.py
Expand Up @@ -309,12 +309,11 @@ def merge_branch(

def insert_call_coverage(
target: LineCoverage,
call_id: int,
call: CallCoverage,
options: MergeOptions = DEFAULT_MERGE_OPTIONS,
) -> CallCoverage:
"""Insert BranchCoverage into LineCoverage."""
return _insert_coverage_item(target.calls, call_id, call, merge_call, options)
return _insert_coverage_item(target.calls, call.callno, call, merge_call, options)


def merge_call(
Expand All @@ -328,6 +327,7 @@ def merge_call(
Do not use 'left' or 'right' objects afterwards!
"""
left.covered |= right.covered
left.callno = right.callno
odkq marked this conversation as resolved.
Show resolved Hide resolved
return left


Expand Down
12 changes: 7 additions & 5 deletions gcovr/writer/json.py
Expand Up @@ -54,7 +54,7 @@
logger = logging.getLogger("gcovr")


JSON_FORMAT_VERSION = "0.3"
JSON_FORMAT_VERSION = "0.4"
JSON_SUMMARY_FORMAT_VERSION = "0.5"
PRETTY_JSON_INDENT = 4

Expand Down Expand Up @@ -275,7 +275,8 @@ def _json_from_calls(calls: Dict[int, CallCoverage]) -> list:

def _json_from_call(call: CallCoverage) -> dict:
return {
"covered": call.covered
"covered": call.covered,
"callno": call.callno
}


Expand Down Expand Up @@ -313,8 +314,8 @@ def _line_from_json(json_line: dict) -> LineCoverage:
insert_decision_coverage(line, _decision_from_json(json_line.get("gcovr/decision")))

if "gcovr/calls" in json_line:
for callno, json_call in enumerate(json_line["gcovr/calls"]):
insert_call_coverage(line, callno, _call_from_json(json_call))
for json_call in json_line["gcovr/calls"]:
insert_call_coverage(line, _call_from_json(json_call))

return line

Expand All @@ -329,7 +330,8 @@ def _branch_from_json(json_branch: dict) -> BranchCoverage:

def _call_from_json(json_call: dict) -> CallCoverage:
return CallCoverage(
covered=json_call["covered"]
covered=json_call["covered"],
callno=json_call["callno"]
)


Expand Down