LCOV_EXCL_START/STOP has no effect when using gcovr

自作多情 提交于 2019-12-02 21:09:24

问题


When I add LCOV_EXCL_START/STOP tags to my C++ code, it does not seem to have any effect on my gcovr report.

Does someone know why this occurs?

I have the following:

$ tree
.
├── build
├── include
│   └── a.h
└── tests
    └── test_a.cpp

and

$ cat include/a.h 
void f (bool x)
{
    // LCOV_EXCL_START
    if (x)
        throw 1;
    // LCOV_EXCL_STOP
}

and

$ cat tests/test_a.cpp 
#include "a.h"

int main ()
{
    f (false);
    return 0;
}

But line 5 throw 1; is included in the gcovr report, even though it is surrounded in exclude tags:

$ g++ -c -O0 -fprofile-arcs -ftest-coverage -fPIC --coverage -I include ./tests/test_a.cpp -o ./build/test_a.o
$ g++ ./build/test_a.o -o ./build/test_a -lgcov
$ ./build/test_a
$ gcovr -r .
------------------------------------------------------------------------------
                           GCC Code Coverage Report
Directory: .
------------------------------------------------------------------------------
File                                       Lines    Exec  Cover   Missing
------------------------------------------------------------------------------
include/a.h                                    4       3    75%   5
tests/test_a.cpp                               3       3   100%   
------------------------------------------------------------------------------
TOTAL                                          7       6    85%
------------------------------------------------------------------------------

回答1:


I upgraded to gcovr version 3.4, and it works now.



来源:https://stackoverflow.com/questions/38618136/lcov-excl-start-stop-has-no-effect-when-using-gcovr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!