Chromium Chronicle image

The Chromium Chronicle #18: Chromium Code Coverage

Published on

Episode 18: by Veenita Joshi and Prakhar Asthana in Mountain View, CA (February 2021)
Previous episodes

Test coverage measures how much source code is executed when a particular test suite runs. Generating coverage data has three major steps: compiling with instrumentation, gathering data from running instrumented tests, and post-processing the data. The coverage team has tools to automate this process.

The Coverage script can generate code coverage reports in just one command, without waiting for Gerrit UI to be updated. This script is currently supported on Linux, Mac, iOS and ChromeOS.

Here is a sample usage:

$ gn gen out/coverage \
--args='use_clang_coverage=true is_component_build=false'
$ python tools/code_coverage/coverage.py \
crypto_unittests url_unittests \
-b out/coverage -o out/report \
-c 'out/coverage/crypto_unittests' \
-c 'out/coverage/url_unittests --gtest_filter=URLParser.PathURL' \
-f url/ -f crypto/

This builds and runs the crypto_unittests and url_unittests targets. For url_unittests, it only runs the test URLParser.PathURL. The coverage report is filtered to include only files and sub-directories under url/ and crypto/. Aside from automating the process, this script provides additional features to view code coverage by directories and components.

Screenshot of output from coverage script. Directory View
Screenshot of output from coverage script. Component View

The Code Coverage tool provides a code coverage breakdown by directory and component for the whole codebase, for Windows, iOS, Android, Linux and ChromeOS.

Share your feedback: Contact code-coverage @ chromium.org or file a bug on crbug.com.

Resources

Published on Improve article

Back

CSS-in-JS support in DevTools

Next

Updates in hardware-accelerated animation capabilities

This site uses cookies to deliver and enhance the quality of its services and to analyze traffic. If you agree, cookies are also used to serve advertising and to personalize the content and advertisements that you see. Learn more about our use of cookies.