Add capability to ignore *.h and *.hpp in coverage report 18/144618/5 accepted/tizen_4.0_unified tizen_4.0 accepted/tizen/4.0/unified/20170828.223016 accepted/tizen/unified/20170822.113011 submit/tizen/20170821.165212 submit/tizen_4.0/20170828.100009 tizen_4.0.IoT.p1_release tizen_4.0.IoT.p2_release tizen_4.0.m2_release
authorDmitry Kovalenko <d.kovalenko@samsung.com>
Thu, 17 Aug 2017 08:26:01 +0000 (11:26 +0300)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Mon, 21 Aug 2017 16:49:30 +0000 (16:49 +0000)
--exclude-headers enable excluding all headers
--exclude-headers <path> exclude all headers from this path

Change-Id: Ia1749272af3bbc58bc25d8b4102bd264bc5ad451
Signed-off-by: Dmitry Kovalenko <d.kovalenko@samsung.com>
scripts/coverage-report-dump.py

index bf15ac8..1134fb7 100755 (executable)
@@ -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()