add lcov to oss for beautiful html report (#44568)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/44568

By `lcov`, we can generate beautiful html. It's better than current file report and line report. Therefore in oss gcc, remove `export` code and `file/line level report` code, only use the html report.

But in clang, since such tool is not available, we will still use file-report and line-report generated by ourself.

Test Plan:
Test in docker ubuntu machine.
## Mesurement
1. After running `atest`, it takes about 15 mins to collect code coverage and genrate the report.
```
# gcc code coverage
python oss_coverage.py --run-only=atest
```

## Presentation
**The html result looks like:**

*Top Level:*

{F328330856}

*File Level:*

{F328336709}

Reviewed By: malfet

Differential Revision: D23550784

fbshipit-source-id: 1fff050e7f7d1cc8e86a6a200fd8db04b47f5f3e
This commit is contained in:
Yujun Zhao
2020-09-11 15:22:14 -07:00
committed by Facebook GitHub Bot
parent c2b40b056a
commit f3a79b881f
5 changed files with 77 additions and 57 deletions

View File

@ -19,7 +19,11 @@ from ..util.utils import (
from .parser.coverage_record import CoverageRecord
from .parser.gcov_coverage_parser import GcovCoverageParser
from .parser.llvm_coverage_parser import LlvmCoverageParser
from .print_report import file_oriented_report, line_oriented_report
from .print_report import (
file_oriented_report,
html_oriented_report,
line_oriented_report,
)
# coverage_records: Dict[str, LineInfo] = dict()
@ -186,26 +190,27 @@ def summarize_jsons(
interested_folders: List[str],
coverage_only: List[str],
platform: TestPlatform,
program_start_time: float,
) -> None:
start_time = time.time()
parse_jsons(test_list, interested_folders, platform)
update_set()
line_oriented_report(
test_list,
tests_type,
interested_folders,
coverage_only,
covered_lines,
uncovered_lines,
)
file_oriented_report(
test_list,
tests_type,
interested_folders,
coverage_only,
program_start_time,
covered_lines,
uncovered_lines,
)
if detect_compiler_type(platform) == CompilerType.GCC:
html_oriented_report()
else:
parse_jsons(test_list, interested_folders, platform)
update_set()
line_oriented_report(
test_list,
tests_type,
interested_folders,
coverage_only,
covered_lines,
uncovered_lines,
)
file_oriented_report(
test_list,
tests_type,
interested_folders,
coverage_only,
covered_lines,
uncovered_lines,
)
print_time("summary jsons take time: ", start_time)