Skip to content

Code Coverage

Franz Miltz edited this page Aug 18, 2021 · 2 revisions

What is code coverage?

Code coverage is a measurement of how comphrehensive your test suite is. It measures the percentage of lines that your tests execute during a run.

How do I see it?

Online: Visit this link: https://codecov.io/github/Hyp-ed/hyped-2022/. Code cov provides a cloud hosted coverage analysis; this is updated during the Travis CI PR execution.

Locally:

  1. Create an empty build directory, e.g. by deleting build and recreating it.
  2. Enter it and configure CMake with the coverage flag:
    $ cmake -DCOVERAGE=ON ..
    
  3. Now run make coverage.

This will produce a html document in the build/test/coverage/html directory. Open this to see a similar report to that of Code Cov.

For more information, read Build system.

Installation

Run git clone https://github.com/linux-test-project/lcov.git to clone the lcov git repo. (Be careful not to accidentally run this inside the Hyped repo., remove the lcov directory if you did)

Run cd lcov then make install on osx or sudo make install on Linux. Return to the HYPED repo. and run make coverage.

Missing Modules

You may get errors about Perl modules missing, which would have to be installed. The errors look like these: Can't locate PerlIO/gzip.pm or Can't locate JSON.pm.

For Mac osx users, run brew install cpanm to install cpanminus only once, followed by sudo cpanm <module name> one time for each module.

For Linux, Debian users run sudo apt-get install <apt package name> (and the equivalent for non-Debian). Alternatively, install cpanminus and proceed similar to the above.

In general, if the missing module is (Module)/(Name).pm, the module name for cpanm would be Module::Name while the apt package name would be lib(Module)-(Name)-perl. i.e. for the error above, OS X would run brew install cpanm followed by sudo cpanm PerlIO::gzip and sudo cpanm JSON. For Linux Debian users, run sudo apt-get install libperlio-gzip-perl and sudo apt-get install libjson-perl.

For Windows users, please consult the CPAN Website for your options.

Clone this wiki locally