Skip to content

Commit

Permalink
Add HTML coverage reporting with gcovr 3.2
Browse files Browse the repository at this point in the history
Change-Id: I711a417dd4e97b792add0998bf005bb6cb8ee451
Reviewed-on: http://gerrit.aldebaran.lan/65679
Reviewed-by: vbarbaresi <[email protected]>
Tested-by: dmerejkowsky <[email protected]>
  • Loading branch information
d0nn13 authored and dmerejkowsky committed Dec 4, 2015
1 parent e0dd980 commit 25195e9
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 20 deletions.
28 changes: 15 additions & 13 deletions python/qibuild/gcov.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@
from qisys import ui


def generate_coverage_xml_report(project):
""" Generate a XML coverage report
def generate_coverage_reports(project):
""" Generate XML and HTML coverage reports
"""
bdir = project.build_directory
sdir = project.path
base_report = os.path.join(bdir, project.name + ".xml")
cmd = ["gcovr",
"--root", sdir,
"--exclude", ".*test.*",
"--exclude", ".*external.*",
"--exclude", ".*example.*",
"--xml",
"--output", base_report]
qisys.command.call(cmd, cwd=sdir, quiet=True)
ui.info(ui.green, "*", ui.reset, "Generated XML coverage report in",
ui.reset, ui.bold, base_report)
formats = {"xml": ["--xml"],
"html": ["--html", "--html-details"]}
for fmt, opts in formats.iteritems():
base_report = os.path.join(bdir, project.name + "." + fmt)
cmd = ["gcovr",
"--root", sdir,
"--exclude", ".*test.*",
"--exclude", ".*external.*",
"--exclude", ".*example.*"] + opts + \
["--output", base_report]
qisys.command.call(cmd, cwd=sdir, quiet=True)
ui.info(ui.green, "*", ui.reset, "Generated", fmt.upper(),
"coverage report in", ui.reset, ui.bold, base_report)
11 changes: 7 additions & 4 deletions python/qibuild/test/test_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
import qibuild.gcov


def test_generate_xml(qibuild_action):
def test_generate_reports(qibuild_action):
gcovr = qisys.command.find_program("gcovr", raises=False)
if not gcovr:
return
proj = qibuild_action.add_test_project("cov")
qibuild_action("configure", "cov", "--coverage")
qibuild_action("make", "cov")
qibuild.gcov.generate_coverage_xml_report(proj)
expected_path = os.path.join(proj.build_directory, proj.name + ".xml")
assert os.path.exists(expected_path)
qibuild.gcov.generate_coverage_reports(proj)
expected_path_xml = os.path.join(proj.build_directory, proj.name + ".xml")
expected_path_html = os.path.join(proj.build_directory, proj.name + ".html")
assert os.path.exists(expected_path_xml)
assert os.path.exists(expected_path_html)

2 changes: 1 addition & 1 deletion python/qitest/actions/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def do(args):
if args.coverage:
build_worktree = qibuild.parsers.get_build_worktree(args, verbose=False)
build_project = qibuild.parsers.get_one_build_project(build_worktree, args)
qibuild.gcov.generate_coverage_xml_report(build_project)
qibuild.gcov.generate_coverage_reports(build_project)
global_res = global_res and res
if not global_res:
sys.exit(1)
2 changes: 1 addition & 1 deletion python/qitest/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_parser(parser, with_num_jobs=True):
help="Repeat tests until they fail (at most N times)")
group.add_argument("--qitest-json", dest="qitest_jsons", action="append")
group.add_argument("--root-output-dir", dest="root_output_dir",
help="Generate XML reports in the given directory " + \
help="Generate XML and HTML reports in the given directory " + \
"(instead of build-<platform>)")

group.add_argument("--no-capture", dest="capture", action="store_false")
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ sphinx-intl==0.9.5
# For coverage
cov-core==1.7
coverage==3.6
gcovr==2.4
gcovr==3.2


# For more checks, thanks pyflakes
Expand Down

0 comments on commit 25195e9

Please sign in to comment.