Skip to main content

Extension for colcon to gather test results.

Project description

colcon-lcov-result

An extension for colcon-core to provide aggregate coverage results using LCOV.

LCOV is a graphical front-end for GCC’s coverage testing tool gcov, producing the following coverage metrics:

  • Statement coverage

  • Function coverage

  • Branch coverage

For more information, see this paper and this Wikipedia page.

Usage

  1. Build your packages with coverage flags, using colcon:

    $ colcon build \
          --symlink-install \
          --cmake-args \
              -DCMAKE_CXX_FLAGS='-fprofile-arcs -ftest-coverage' \
              -DCMAKE_C_FLAGS='-fprofile-arcs -ftest-coverage'
  2. Create a baseline for zero coverage:

    $ colcon lcov-result --initial
    • This step is optional, but will help reveal any files that are untouched by tests

  3. Run tests:

    $ colcon test
  4. Gather the lcov results:

    $ colcon lcov-result
    Reading tracefile /home/user/workspace/my_cool_ws/lcov/total_coverage.info
    Summary coverage rate:
      lines......: 78.6% (44 of 56 lines)
      functions..: 94.4% (34 of 36 functions)
      branches...: 37.0% (34 of 92 branches)
  5. Browse the coverage report by opening lcov/index.html in a browser

  6. Zero the coverage counters and re-run tests:

    $ colcon lcov-result --zero-counters
    $ colcon lcov-result --initial
    $ colcon test
    $ colcon lcov-result
    Reading tracefile /home/user/workspace/my_cool_ws/lcov/total_coverage.info
    Summary coverage rate:
      lines......: 78.6% (44 of 56 lines)
      functions..: 94.4% (34 of 36 functions)
      branches...: 37.0% (34 of 92 branches)

Tips and Tricks

  • When running locally, use the --packages-select option to generate coverage information for relevant packages

    • This will also suppress warnings for packages that were either not built with coverage flags or for which tests did not run

  • The --verbose flag can be used to print the coverage summary of each individual package as the results are analyzed

Troubleshooting

  • The following warning when running colcon lcov-result --initial implies that the package was not built with the correct flags:

    --- stderr: my_pkg
    geninfo: WARNING: no .gcno files found in /home/user/workspace/build/my_pkg - skipping!
    ---
    • The package will not show up in the final results. Use --packages-skip to suppress the warning

  • The following warning when running colcon lcov-result implies that no tests ran for that package

    [0.576s] ERROR:colcon.colcon_lcov_result.task.lcov:lcov:
    ERROR: no valid records found in tracefile /home/user/workspace/build/my_pkg/coverage.info
    --- stderr: my_pkg
    geninfo: WARNING: no .gcda files found in /home/user/workspace/build/my_pkg - skipping!
    ---
    • The package will show up in the final results with 0% coverage. Use --packages-skip to suppress these packages from the total

Known Issues

  1. The final step of aggregating all the result files can be slow depending on the number of packages that were analyzed

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

colcon-lcov-result-0.1.2.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

colcon_lcov_result-0.1.2-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file colcon-lcov-result-0.1.2.tar.gz.

File metadata

  • Download URL: colcon-lcov-result-0.1.2.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.5.2

File hashes

Hashes for colcon-lcov-result-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7e61582f54be76c75e569b15ad7347d8cb25c0b2ed7fa42e22ca1075dee81487
MD5 3cbc3c4e251ac21d8c878f2904c156c9
BLAKE2b-256 c501ea51dd1c1e5cf9f374cfe17374631281fdddd8d5b30e6ef4f40c1a4b8c1c

See more details on using hashes here.

Provenance

File details

Details for the file colcon_lcov_result-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: colcon_lcov_result-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.5.2

File hashes

Hashes for colcon_lcov_result-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3196fdda1ec6d734818e06ac7f4d67977ac9ff61f8aa3a3f1f65fe90e2a0a5e7
MD5 a665e27c24eaa62baa5e644bd7a6f2fe
BLAKE2b-256 2a71ca7333a4880b0b835a4a849d474395ae23d6652cccd8c613bfba7367be12

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page