Yuke Liao | d3b4627 | 2018-03-14 18:25:14 | [diff] [blame] | 1 | # Code coverage in Chromium |
| 2 | |
| 3 | ## Coverage script. |
| 4 | [Coverage script] helps to generate clang source-based code coverage report |
| 5 | locally and make it easy to identify under-covered areas. |
| 6 | |
| 7 | Currently, this script supports running on Linux, Mac, iOS and ChromeOS |
| 8 | platforms, and supports displaying code coverage results per directory, per |
| 9 | component and per file. |
| 10 | |
| 11 | In order to generate code coverage report, you need to first add |
| 12 | `use_clang_coverage=true` and `is_component_build=false` GN flags to args.gn |
| 13 | file in your build output directory (e.g. out/coverage). |
| 14 | |
| 15 | Existing implementation requires `is_component_build=false` flag |
| 16 | because coverage info for dynamic libraries may be missing and |
| 17 | `is_component_build` is set to true by `is_debug` unless it is explicitly set |
| 18 | to false. |
| 19 | |
| 20 | Example usage: |
| 21 | ``` |
| 22 | gn gen out/coverage --args='use_clang_coverage=true is_component_build=false' |
| 23 | gclient runhooks |
| 24 | python tools/code_coverage/coverage.py crypto_unittests url_unittests |
| 25 | -b out/coverage -o out/report -c 'out/coverage/crypto_unittests' |
| 26 | -c 'out/coverage/url_unittests --gtest_filter=URLParser.PathURL' |
| 27 | -f url/ -f crypto/ |
| 28 | ``` |
| 29 | |
| 30 | For more options, please refer to the script. |
| 31 | |
| 32 | ## Reporting problems |
| 33 | |
| 34 | For any breakage report and feature requests, please [file a bug]. |
| 35 | |
| 36 | [Coverage script]: https://cs.chromium.org/chromium/src/tools/code_coverage/coverage.py |
| 37 | [file a bug]: https://bugs.chromium.org/p/chromium/issues/entry?components=Tools%3ECodeCoverage |