No description
Find a file
2020-10-18 11:47:30 +02:00
attachments Code coverage as a binary instead of a nimble task 2018-10-21 17:47:31 +02:00
coverage Code coverage as a binary instead of a nimble task 2018-10-21 17:47:31 +02:00
tests Temporary workaround for #18 2020-09-27 00:25:25 -07:00
.gitignore Temporary workaround for #18 2020-09-27 00:25:25 -07:00
.travis.yml Test travis conf 2018-10-22 21:58:56 +02:00
coco.html Code coverage as a binary instead of a nimble task 2018-10-21 17:47:31 +02:00
coco.nim Temporary workaround for #18 2020-09-27 00:25:25 -07:00
coco.nimble fix warning skipDirs 2018-10-24 08:27:58 +02:00
lcov.info Code coverage as a binary instead of a nimble task 2018-10-21 17:47:31 +02:00
LICENSE Nimble task - Code coverage for Nim 2018-10-17 22:37:09 +02:00
Readme.md Install through Nimble official repo 2018-11-02 08:50:40 +01:00

43c4b9c5.png

Code coverage for Nim using LCOV.


Features

  • Line & Branch coverage support
  • Forwards nim compiler options
  • Works out-of-the box with Nim unittests
  • API + CLI
  • HTML report

Installation & usage

Install using Nimble:

nimble install coco

CLI

Generate a code coverage report:

coco --target "tests/**/*.nim" --cov '!tests' --compiler="--hints:off" 

The flag --target tells Coco to run and compile nim files in the tests/ directory (and subdirectories if any).

The flag --cov is helpful for extracting or removing data from the file *.info. Here we don't want code coverage for our tests, only for our main library coco.

The flag --compiler forwards its value directly to the Nim compiler.

To get the full list of available flags, type in your shell coco -h


By default, Coco will generate a lcov.info file on your project root folder and create a report under coverage/.

To check your report, open the file coverage/index.htmlin your browser:

a74b8ce4.png

VScode visualization

Install Coverage Gutters.

This nice plugin will map your coverage to your source code right into VScode:

b5193c3c.png

Library

import and use:

import coco

discard coverage(target = "tests/foo.nim", branch = true)

You can find the full documentation here: API Coco

Tests

This task has only been tested under MacOSX. Feel free to open a pull request to share your experiments to code coverage Nim projects.

TODO

  • Support for subdirectories in tests/
  • Coveralls.io integration

Dependencies

Linux Test Project - Coverage » lcov