blob: ba98485ee832602d214ab52709a9f3a7fc37cbb9 [file] [log] [blame] [view]
Yuke Liao8bc00852019-01-29 19:22:391# Code Coverage in Gerrit
2
Yuke Liao0e5a20e2019-06-17 19:52:573Tests are critical because they find bugs and regressions, enforce better
4designs and make code easier to maintain. **Code coverage helps you ensure your
5tests are thorough**.
Yuke Liao8bc00852019-01-29 19:22:396
Yuke Liao0e5a20e2019-06-17 19:52:577Chromium CLs can show a line-by-line breakdown of test coverage. **You can use
Yuke Liao78aa43b2019-08-29 16:58:178it to ensure you only submit well-tested code**.
Yuke Liao0e5a20e2019-06-17 19:52:579
Yuke Liao78aa43b2019-08-29 16:58:1710To see code coverage for a Chromium CL, **trigger a CQ dry run**, and once the
Yuke Liaoa085b982019-10-24 21:37:1111builds finish and code coverage data is processed successfully, **look at the
12change view to see absolute and incremental code coverage percentages**:
13
14![code_coverage_percentages]
15
16Absolute coverage percentage is the percentage of lines covered by tests
17out of **all the lines** in the file, while incremental coverage percentage only
18accounts for **newly added or modified lines**.
19
20To further dig into specific lines that are not covered by tests, **look at the
21right column of the side by side diff view**:
Yuke Liao8bc00852019-01-29 19:22:3922
Yuke Liao0e5a20e2019-06-17 19:52:5723![code_coverage_annotations]
24
Yuke Liao78aa43b2019-08-29 16:58:1725**Code coverage data is shared between patchsets that are commit-message-edit or
26trivial-rebase away**, however, if a newly uploaded patchset has
27non-trivial code change, a new CQ dry run must be triggered before coverage data
28shows up again.
29
Yuke Liao0e5a20e2019-06-17 19:52:5730The code coverage tool currently **supports C/C++ code for Chrome on Linux**;
31support for more platforms and more languages is in progress.
32
Yuke Liao8bc00852019-01-29 19:22:3933## Contacts
34
35### Reporting problems
36For any breakage report and feature requests, please [file a bug].
37
38### Mailing list
39For questions and general discussions, please join [code-coverage group].
40
41## FAQ
Yuke Liao8bc00852019-01-29 19:22:3942### Why is coverage not shown even though the try job finished successfully?
43
44There are several possible reasons:
Yuke Liao8bc00852019-01-29 19:22:3945* A particular source file/test may not be available on a particular project or
46platform. As of now, only `chromium/src` project and `Linux` platform is
47supported.
48* There is a bug in the pipeline. Please [file a bug] to report the breakage.
49
50### How does it work?
51
52Please refer to [code_coverage.md] for how code coverage works in Chromium in
53general, and specifically, for per-CL coverage in Gerrit, the
54[clang_code_coverage_wrapper] is used to compile and instrument ONLY the source
Yuke Liao0e5a20e2019-06-17 19:52:5755files that are affected by the CL for the sake of performance and a
56[chromium-coverage Gerrit plugin] is used to display code coverage information
57in Gerrit.
Yuke Liao8bc00852019-01-29 19:22:3958
59
60[choose_tryjobs]: images/code_coverage_choose_tryjobs.png
61[linux_coverage_rel]: images/code_coverage_linux_coverage_rel.png
Yuke Liao0e5a20e2019-06-17 19:52:5762[code_coverage_annotations]: images/code_coverage_annotations.png
Yuke Liaoa085b982019-10-24 21:37:1163[code_coverage_percentages]: images/code_coverage_percentages.png
Yuke Liao03c644072019-07-30 18:33:4064[file a bug]: https://bugs.chromium.org/p/chromium/issues/entry?components=Infra%3ETest%3ECodeCoverage
Yuke Liao8bc00852019-01-29 19:22:3965[code-coverage group]: https://groups.google.com/a/chromium.org/forum/#!forum/code-coverage
66[code_coverage.md]: code_coverage.md
67[clang_code_coverage_wrapper]: clang_code_coverage_wrapper.md
68[chromium-coverage Gerrit plugin]: https://chromium.googlesource.com/infra/gerrit-plugins/code-coverage/