From c35b593f3d6270f19f8ae4e3d2d01143fd525ae0 Mon Sep 17 00:00:00 2001 From: Dmitry Kovalenko Date: Thu, 17 Aug 2017 11:26:01 +0300 Subject: [PATCH] Add capability to ignore *.h and *.hpp in coverage report --exclude-headers enable excluding all headers --exclude-headers exclude all headers from this path Change-Id: Ia1749272af3bbc58bc25d8b4102bd264bc5ad451 Signed-off-by: Dmitry Kovalenko --- scripts/coverage-report-dump.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/coverage-report-dump.py b/scripts/coverage-report-dump.py index bf15ac8..1134fb7 100755 --- a/scripts/coverage-report-dump.py +++ b/scripts/coverage-report-dump.py @@ -14,7 +14,8 @@ Usage: ./coverage-report-dump.py \ --symcov coverage_data.symcov \ --srcpath root_src_dir \ - --dump dump-path + --dump dump-path \ + --exclude-headers [path] ''' @@ -163,7 +164,7 @@ class DumpCov(): with open(html_file, 'wb') as f: f.write(response.encode('UTF-8', 'replace')) - def do_Dump(self, symcov_data, src_path, dump_path): + def do_Dump(self, symcov_data, src_path, dump_path, exclude_headers=None): filelist = [] self.__symcov_data = symcov_data self.__src_path = src_path @@ -173,6 +174,11 @@ class DumpCov(): if not os.path.exists(os.path.abspath(self.__dump_root)): os.makedirs(self.__dump_root) for filename in sorted(self.__symcov_data.filenames()): + if exclude_headers: + # ignore headers *.h/*.hpp + if filename.startswith(tuple(exclude_headers)) and\ + filename.endswith((".h", ".hpp")): + continue file_coverage = self.__symcov_data.file_coverage[filename] if not file_coverage: continue @@ -199,6 +205,9 @@ def main(): parser = argparse.ArgumentParser(description="symcov report dump.") parser.add_argument('--symcov', required=True, type=argparse.FileType('r')) parser.add_argument('--srcpath', required=True) + parser.add_argument('--exclude-headers', nargs='?', const="", + default=None, required=False, + dest="ex_headers", action='append') parser.add_argument('--dump', required=True, help="Path to dump coverage") args = parser.parse_args() @@ -207,7 +216,8 @@ def main(): symcov_json = json.load(args.symcov) Dumper = DumpCov() - Dumper.do_Dump(SymcovData(symcov_json), args.srcpath, args.dump) + Dumper.do_Dump(SymcovData(symcov_json), args.srcpath, + args.dump, args.ex_headers) if __name__ == '__main__': main() -- 2.34.1