xref: /aosp_15_r20/external/pytorch/tools/code_coverage/package/oss/cov_json.py (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1from ..tool import clang_coverage
2from ..util.setting import CompilerType, Option, TestList, TestPlatform
3from ..util.utils import check_compiler_type
4from .init import detect_compiler_type  # type: ignore[attr-defined]
5from .run import clang_run, gcc_run
6
7
8def get_json_report(test_list: TestList, options: Option) -> None:
9    cov_type = detect_compiler_type()
10    check_compiler_type(cov_type)
11    if cov_type == CompilerType.CLANG:
12        # run
13        if options.need_run:
14            clang_run(test_list)
15        # merge && export
16        if options.need_merge:
17            clang_coverage.merge(test_list, TestPlatform.OSS)
18        if options.need_export:
19            clang_coverage.export(test_list, TestPlatform.OSS)
20    elif cov_type == CompilerType.GCC:
21        # run
22        if options.need_run:
23            gcc_run(test_list)
24