本文介绍了使用gcovr时LCOV_EXCL_START/STOP不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我在我的C ++代码中添加LCOV_EXCL_START/STOP标记时,它似乎对我的gcovr报告没有任何影响.
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?
我有以下内容:
$ tree
.
├── build
├── include
│ └── a.h
└── tests
└── test_a.cpp
和
$ cat include/a.h
void f (bool x)
{
// LCOV_EXCL_START
if (x)
throw 1;
// LCOV_EXCL_STOP
}
和
$ cat tests/test_a.cpp
#include "a.h"
int main ()
{
f (false);
return 0;
}
但是第5行throw 1;
包含在gcovr报告中,即使它被排除标记括起来也是如此:
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%
------------------------------------------------------------------------------
推荐答案
我已升级到gcovr 3.4版,并且现在可以使用.
I upgraded to gcovr version 3.4, and it works now.
这篇关于使用gcovr时LCOV_EXCL_START/STOP不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!