本文介绍了如何告诉lcov忽略源文件中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能告诉lcov忽略源文件中的某些行,即。不要报告为未访问。我正在寻找一个可以放在代码本身的解决方案,如:

I am wondering if there is the possibility to tell lcov to ignore some lines in a source files, ie. do not report them as unvisited. I am looking for a solution that can be put in the code itself, like:

int some_method(char some_var, char some_other_var)
{
    if(some_var == 'A')
    {
         if(some_other_var == 'B')
         {
               /* do some real stuff here */
         }
         else
         {
                LCOV_DO_NOT_REPORT_NEXT_LINE // **<-- this?? **
                NOT_IMPLEMENTED("A*")
         }
    }
    else
    {
         NOT_IMPLEMENTED("*")
    }

以及必要的背景:

的代码像上面的代码正在一系列的单元测试中测试,但由于这个代码仍在开发中有很多 NOT_IMPLEMENTED(A *)宏它只是在屏幕上用行号/文件名和退出应用程序的消息。

A big piece of code like the one above is being tested in a series of unit tests, but since this code is still under development there are a lot of NOT_IMPLEMENTED("A*") macros which just put a message on the screen with the line number/filename and exit the application. There are no tests for the not implemented branches, obviously they will be written when the feature is implemented.

但是,lcov报告了这些 NOT_IMPLEMENTED 行,并且他们在覆盖率报告中看起来很丑陋(即:它们使得红线的比率较高)。

However lcov reports these NOT_IMPLEMENTED lines and they look very ugly in the coverage report (ie: they make a high ratio of red lines).

这是我要求的可能,

推荐答案

您可以在源代码中使用以下注释。

You can use the following as comments in the source.


  • 排除部分的开始。当前行是此部分的一部分。


  • 的排除部分。当前行不是此部分的一部分。

这篇关于如何告诉lcov忽略源文件中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 19:13