This repository has been archived by the owner on Apr 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 296
Coverage: remove function signature lines that are never report as hit #2156
Open
neewy
wants to merge
2
commits into
develop
Choose a base branch
from
fix/coverage-fx-decl
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# https://github.com/JeremyAgost/lcov-llvm-function-mishit-filter | ||
# https://github.com/linux-test-project/lcov/issues/30 | ||
|
||
import argparse | ||
import subprocess | ||
|
||
def demangle(symbol): | ||
p = subprocess.Popen(['c++filt','-n'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) | ||
return p.communicate(input=symbol.encode())[0].decode().strip() | ||
|
||
def filter_lcov(lines, verbose=False): | ||
defs, srcfile = {}, '' | ||
for line in lines: | ||
if line.startswith('SF:'): | ||
defs = {} | ||
srcfile = line[3:].strip() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this line can be placed behind |
||
elif line.startswith('end_of_record'): | ||
defs = {} | ||
elif line.startswith('FN:'): | ||
lineno, symbol = line[3:].split(',') | ||
if verbose: | ||
defs[lineno] = demangle(symbol) | ||
else: | ||
defs[lineno] = True | ||
elif line.startswith('DA:'): | ||
lineno = line[3:].split(',')[0] | ||
if lineno in defs: | ||
if verbose: | ||
printf('Ignoring: {srcfile}:{lineno}:{defs[lineno]}') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this work? I see such syntax for the first time and did not find any docs on such There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this did not work on my setup. I suggest removing verbose stuff: srcfile, demangle, printf, cli arg, etc. because we do not use it and it is bogous. |
||
continue | ||
yield line | ||
|
||
def main(): | ||
p = argparse.ArgumentParser() | ||
p.add_argument('input', type=str) | ||
p.add_argument('output', type=str) | ||
p.add_argument('--verbose', '-v', action='store_true') | ||
args = p.parse_args() | ||
with open(args.input, 'r') as fin: | ||
lines = list(fin) | ||
with open(args.output, 'w') as fout: | ||
for line in filter_lcov(lines, verbose=args.verbose): | ||
fout.write(line) | ||
|
||
if __name__ == '__main__': | ||
main() |
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.
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.
Coverage almost always runs at
gcc5
, but it possible to run coverage at any other compilerwith
Custom command
:ex. parameters to run build:
or on mac:
This python code looks simple and hope it won't fail on mac, also until now nobody used coverage at mac