pytorch/tools/code_coverage/package/oss/cov_json.py
yujunzhao@devvm229.ftw0.facebook.com 0564d7a652 Land code coverage tool for OSS (#43778)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/43778

Move code_coverage_tool from experimental folder to caffe2/tools folder.

Delete `TODO` and fb-related code.

Test Plan: Test locally

Reviewed By: malfet

Differential Revision: D23399983

fbshipit-source-id: 92316fd3cc88409d087d2dc6ed0be674155b3762
2020-08-28 13:56:15 -07:00

36 lines
1.1 KiB
Python

import time
from ..tool import clang_coverage, gcc_coverage
from ..util.setting import Option, TestList, TestPlatform
from ..util.utils import check_compiler_type, get_cov_type, print_time
from .init import gcc_export_init
from .run import clang_run, gcc_run
def get_json_report(test_list: TestList, options: Option):
start_time = time.time()
cov_type = get_cov_type()
# TODO change to enum
check_compiler_type(cov_type)
if cov_type == "CLANG":
# run
if options.need_run:
clang_run(test_list)
# merge && export
if options.need_merge:
clang_coverage.merge(test_list, TestPlatform.OSS)
if options.need_export:
clang_coverage.export(test_list, TestPlatform.OSS)
elif cov_type == "GCC":
# run
if options.need_run:
gcc_run(test_list)
# export
if options.need_export:
gcc_export_init()
gcc_coverage.export()
print_time(
"collect coverage for cpp tests take time: ", start_time, summary_time=True
)