Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell lcov to ignore lines in the source files

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("*")
    }

And the necessary background:

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.

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).

Is what I ask for possible, or we just should live with this?

like image 287
Ferenc Deak Avatar asked Apr 24 '14 08:04

Ferenc Deak


1 Answers

You can use the following as comments in the source.

From http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php

  • LCOV_EXCL_LINE
    • Lines containing this marker will be excluded.
  • LCOV_EXCL_START
    • Marks the beginning of an excluded section. The current line is part of this section.
  • LCOV_EXCL_STOP
    • Marks the end of an excluded section. The current line not part of this section.
like image 173
PomfCaster Avatar answered Oct 01 '22 01:10

PomfCaster