Code Monkey home page Code Monkey logo

coverxygen's Introduction

Table of Contents

Coverxygen

Continuous Integration Coverage Status

How to

First, run doxygen with XML output on your project, Coverxygen will read generated file and produce an lcov compatible output. Finally, run lcov or genhtml to produce the coverage output.

Alternatively, Coverxygen can also calculate the coverage and print a summary table when given the option --format summary.

Prerequisites

Coverxygen relies on doxygen to generate the documentation information.

sudo apt-get install doxygen

Additionally, if you want to generate coverage reports using lcov, this needs to be installed as well:

sudo apt-get install lcov

Installation

From pip

pip3 install coverxygen

From PPA Packages

link : https://launchpad.net/~psycofdj/+archive/ubuntu/coverxygen

sudo add-apt-repository ppa:psycofdj/coverxygen
sudo apt-get update
sudo apt-get install python3-coverxygen

Configure doxygen

Tell doxygen to generate an XML version of your doxyfile.cfg configuration

GENERATE_XML = YES

Then run doxygen

doxygen <path_to_your_doxygen.cfg>

Run Coverxygen

python3 -m coverxygen --xml-dir <path_to_doxygen_xml_dir> --src-dir <path_to_root_source_dir> --output doc-coverage.info

Full usage :

usage: coverxygen [-h] [--version] [--verbose] [--json] [--format FORMAT]
                  [--prefix PREFIX] [--exclude EXCLUDE] [--include INCLUDE]
                  [--scope SCOPE] [--kind KIND] --xml-dir XML_DIR --output
                  OUTPUT --src-dir SRC_DIR

required arguments:
  --xml-dir XML_DIR  path to generated doxygen XML directory
  --output OUTPUT    destination output file (- for stdout)
  --src-dir SRC_DIR  root source directory used to match prefix for relative path generated files

optional arguments:
  -h, --help         show this help message and exit
  --version          print version and exit
  --verbose          enabled verbose output
  --json             (deprecated) same as --format json-legacy
  --format FORMAT    output file format :
                     lcov             : lcov compatible format (default)
                     json-v3          : json format which includes summary information
                     json-v2          : simpler json format
                     json-v1          : legacy json format
                     json             : (deprecated) same as json-v2
                     json-legacy      : (deprecated) same as json-v1
                     json-summary     : summary in json format
                     markdown-summary : ummary in markdown table format
                     summary          : textual summary table format
  --prefix PREFIX    keep only file matching given path prefix
  --exclude EXCLUDE  exclude files whose absolute path matches a regular expression;
                     this option can be given multiple times
  --include INCLUDE  include files whose absolute path matches a regular expression
                     even if they also match an exclude filter (see --exclude) or if they
                     are not matching the patch prefix (see --prefix);
                     this option can be given multiple times
  --scope SCOPE      comma-separated list of item scopes to include :
                      - public    : public member and global elements
                      - protected : protected member elements
                      - private   : private member elements
                      - all       : all above
  --kind KIND        comma-separated list of item types to include :
                      - enum      : enum definitions
                      - enumvalue : enum value definitions
                                    Note: a single undocumented enum value will mark
                                    the containing enum as undocumented
                      - friend    : friend declarations
                      - typedef   : type definitions
                      - variable  : variable definitions
                      - function  : function definitions
                      - signal    : Qt signal definitions
                      - slot      : Qt slot definitions
                      - class     : class definitions
                      - struct    : struct definitions
                      - union     : union definitions
                      - define    : define definitions
                      - file      : files
                      - namespace : namespace definitions
                      - page      : documentation pages
                      - all       : all above

Run lcov or genhtml

lcov can be used to generate a simple console output based on documented lines :

lcov --summary doc-coverage.info

More interesting, produce a html-browsable coverage detail :

genhtml --no-function-coverage --no-branch-coverage doc-coverage.info -o .
# browse results in index.html

Results

summary Format

Classes    :  90.5% (38/42)
Defines    :   0.0% (0/2)
Enum Values:  12.3% (8/65)
Enums      :  75.0% (3/4)
Files      :   8.3% (2/24)
Functions  :  64.8% (175/270)
Namespaces :  75.0% (6/8)
Pages      : 100.0% (7/7)
Signals    :  83.3% (5/6)
Slots      :  28.6% (2/7)
Structs    :  80.0% (4/5)
Typedefs   :  39.1% (9/23)
Variables  :  20.0% (8/40)
-----------------------------------
Total      :  53.1% (267/503)

lcov

Overview

Summary

Details

Details

Credits

Special thanks to Alvaro Lopez Ortega <[email protected]> who found a smart and efficient solution to retrieve doxygen informations from the generated xml.

You can find his work at alobbs/doxy-coverage

Hall of Fame

Project status

Unstable but usable. PyPI version

coverxygen's People

Contributors

alessandropellegrini avatar antoniovazquezblanco avatar j-ulrich avatar psycofdj avatar shuky-shukrun avatar uthidata avatar wiegandm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

coverxygen's Issues

How to ignore `#pragma once` from report

Hi, coverxygen developers

I'm using doxygen together with coverxygen, lcov to generate document coverage report, for a very naive C++ header file.
It confuse me by considering #pragma once as function, thus make wrong coverage percentage (25%, instead of expected 33%)

图片

图片

The source code I'm using is :

hello.h:

#pragma once

void nice();

void hello(const char* name);


/// @brief the int data version
void hello(int data);

The doxygen configuration file I'm using is

PROJECT_NAME = "MyProject"
EXTRACT_ALL = YES
HTML_TIMESTAMP = YES
RECURSIVE = YES

GENERATE_XML=YES
GENERATE_HTML=YES
GENERATE_LATEX=NO

GENERATE_LEGEND        = YES
INPUT = /home/zz/work/test/doxygen_example3/src/hello.h

The commands to generate document coverage report is:

#!/bin/bash
doxygen Doxyfile.in
python -m coverxygen --xml-dir ./xml --src-dir ../src --output doc-coverage.info --kind function
rm doc-coverage.info
lcov --summary doc-coverage.info
genhtml --no-function-coverage --no-branch-coverage doc-coverage.info -o .
echo "python -m http.server 7088"

Add setuptools to prerequisites

I tried to install this, and it fails because there is not setuptools module

root@9c426af140c0:/usr/src/app# pip3 install coverxygen
Collecting coverxygen
  Using cached coverxygen-1.3.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named 'setuptools'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-_8m3d7_m/coverxygen/
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

I was able to install it after installing setuptools

root@9c426af140c0:/usr/src/app# pip3 install setuptools
Collecting setuptools
  Downloading setuptools-36.2.7-py2.py3-none-any.whl (477kB)
    100% |################################| 481kB 2.1MB/s
Installing collected packages: setuptools
Successfully installed setuptools-36.2.7
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
root@9c426af140c0:/usr/src/app# pip3 install coverxygen
Collecting coverxygen
  Using cached coverxygen-1.3.0.tar.gz
Building wheels for collected packages: coverxygen
  Running setup.py bdist_wheel for coverxygen ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-z6ddhwqk/coverxygen/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmps3fokatxpip-wheel- --python-tag cp35:
  usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: -c --help [cmd1 cmd2 ...]
     or: -c --help-commands
     or: -c cmd --help

  error: invalid command 'bdist_wheel'

  ----------------------------------------
  Failed building wheel for coverxygen
  Running setup.py clean for coverxygen
Failed to build coverxygen
Installing collected packages: coverxygen
  Running setup.py install for coverxygen ... done
Successfully installed coverxygen-1.3.0
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
root@9c426af140c0:/usr/src/app#

PPA has no hammy release

From a recent CI job:

E: The repository 'https://ppa.launchpadcontent.net/psycofdj/coverxygen/ubuntu jammy Release' does not have a Release file.

c# support

Hi,

This project looks great, thanks!

I tried it with doxygen output for a c# project and run into some issues where the coverage is not reflected correctly.

I was wondering if this is meant to be supported and if you could point me in the right direction?

Unfortunately I cannot share the project and didn't get around to creating a minimum reproducible example, but the two issues im seeing at first glance are:

  • top level file comment block is incorrectly recognised as code giving a false miss

EDIT: this is same as #15

Screenshot 2023-10-31 at 13 50 24

  • c# properties are not recognised as code, but methods work as expected

Screenshot 2023-10-31 at 13 51 54

I'd be happy to share more debug output, create a minimum example or test stuff or submit a PR if this project scope would include c# support.

Best,
wiktor

Many source file directories, `src-dir` not supported

Hi, coverxygen developers

I'm using doxygen together with coverxygen for document coverage report. The C++ project I'm using is big, containing many modules, thus header files are distributed in each module's own including directory.

Here comes the question, coverxygen's --src-dir option does not support multiple directories?

Releases are not tagged in git

Although this may not be such a big deal to be reported as a "bug", it is a requirement to correctly describe package versioning in Archlinux AUR packages in an automated way. It would be a nice to have feature!

Thanks!

Error with special characters

I am using Doxygen to generate documentation for an application in Brazilian Portuguese and I want to check documentation coverage, but I am facing a bit of an odd error.

Some of the comments happen to make use of accents for that language. For example, "não" (Portuguese for "no") or "instruções" (for "instructions").

When I try to run coveryxgen, I receive the following error:

Command:
$ python3 -m coverxygen --xml-dir docs/xml/ --src-dir . --output -
error: error while parsing xml file docs/xml/.xml : not well-formed (invalid token): line 567, column 138

When I look at the XML file in the corresponding line and column I find one of those symbols (in the example above it was a c-cedil (ç), but a-tilde (ã) or a-acute (á) were also flagged. And there may be several others.

Integration with codecov.io

See codecov/support#364, in short coverxygen can be used to get doxygen coverage numbers on codecov.io by simply adding something like:

make doxygen
python -m coverxygen --xml-dir xml/ --src-dir . --output doxygen.coverage.info
bash <(curl -s https://codecov.io/bash) -R . -F doxygen -X gcov -f doxygen.coverage.info

coverxygen does not generate output

Hi,

I followed your instructions in the readme file. My problem is that the python module isn't generating any output. When I use

python3 -m coverxygen --xml-dir ./doc/xml --output doc-coverage.info

the doc-coverage.info file is generated, but it's empty. There isn't any log output or error message, so i have no idea how to fix that problem.

I am developing on Ubuntu 16.04 4.4.0-57-generic x86_64.
The python tool doxy-coverage by Alvaro Lopez Ortega works properly. I hope you have an idea how to fix this issue.

Thanks in advance

coverxygen produces negative execution counts for undocumented functions

Thanks a lot for this very useful tool!

I noticed that the output_print_lcov method will produce negative execution counts in the lcov output format when it encounters an undocumented object:

l_value = -1

This results in output like the following:

...
DA:53,1
DA:49,1
DA:61,-1
DA:62,-1
DA:63,-1
DA:64,-1
DA:60,1
...

lcov (at least in version 1.13) will process the file properly, but complains:

lcov: WARNING: negative counts found in tracefile

The service codecov.io on the other hand processes the output, but counts negative counts as covered, leading to an incorrect 100% coverage.

Replacing all counts of -1 in the output with 0 (e.g. with sed -i -e 's/,-1$/,0/g' <outputfile>) causes the warning to disappear from the lcov and genhtml output while still producing the correct coverage report.

More importantly (at least for me), submitting the file with the counts set to 0 instead of -1 to codecov.io results in the results being parsed correctly and the coverage information being available through codecov.io.

Difficulties in getting started

Hi all!

Thanks to the doxy-coverage and coverxygen project members for all the time & effort that has been put into the projects.

I am currently evaluating the use of coverxygen - working with a C/C++ code base.

I hade some starting difficulties, so I am currently playing around with a reduced code sample. It basically seems to work.

My flow:

# change directory to coverxygen repository, then generate Doxygen documentation from my example in ./test/average
$ cd ./test/average/ && doxygen && cd ../..

# run coverxygen
$ python3 -m coverxygen --xml-dir ./test/average/doc/xml/ --output ./test/average/doc/average.info --output ./test/average/doc/coverage.info --src-dir ./test/average/

# output lcov
$ lcov --summary ./test/average/doc/coverage.info
Reading tracefile ./test/average/doc/coverage.info
Summary coverage rate:
  lines......: 60.0% (3 of 5 lines)
  functions..: no data found
  branches...: no data found

# generate HTML report and view it in the browser
$ genhtml --no-function-coverage --no-branch-coverage ./test/average/doc/coverage.info -o ./test/average/doc/coverage
Reading data file ./test/average/doc/coverage.info
Found 2 entries.
Found common filename prefix "/mnt/somepath/coverxygen/test"
Writing .css and .png files.
Generating output.
Processing file average/average.cpp
Processing file average/doc/xml/todo.xml
Writing directory view page.
Overall coverage rate:
  lines......: 60.0% (3 of 5 lines)

Undocumented functions are detected as expected.

Before:

LcovTest

After:

LcovTest2


Where (if at all) can I exclude the check for #includes, usings and probably other keywords/expressions/statements?

Your README.md shows the following example:

summary Format

Classes    :  90.5% (38/42)
Defines    :   0.0% (0/2)
Enum Values:  12.3% (8/65)
Enums      :  75.0% (3/4)
Files      :   8.3% (2/24)
Functions  :  64.8% (175/270)
Namespaces :  75.0% (6/8)
Pages      : 100.0% (7/7)
Signals    :  83.3% (5/6)
Slots      :  28.6% (2/7)
Structs    :  80.0% (4/5)
Typedefs   :  39.1% (9/23)
Variables  :  20.0% (8/40)
-----------------------------------
Total      :  53.1% (267/503)

What needs to be done to get this detailed summary?

Can you also check if all parameters of a function/method have been commented?

Any help is very much appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.