Code coverage in Phobos
Basile B. via Digitalmars-d
digitalmars-d at puremagic.com
Mon Mar 28 16:45:10 PDT 2016
On Monday, 28 March 2016 at 16:44:26 UTC, Vladimir Panteleev
wrote:
> On Monday, 28 March 2016 at 16:10:48 UTC, Basile B. wrote:
>> On Monday, 28 March 2016 at 11:29:55 UTC, Vladimir Panteleev
>> wrote:
>>> Yep. The difficulties are:
>>>
>>> 1. Getting data off the autotester. Currently it's nearly
>>> impossible, as is making any changes to it.
>>>
>>> https://issues.dlang.org/show_bug.cgi?id=14381
>>>
>>> 2. Collating data from multiple platforms, as there is a lot
>>> of platform-specific code in e.g. std.stdio, std.file, and
>>> most of Druntime.
>>
>> 3. since the coverage is computed at run-time by the
>> application that runs the tests all the static code (+ CTFE)
>> is considered NOT covered. This gives misleading results.
>>
>> For example std.traits will probably have a bad coverage while
>> actually it's pretty good.
>
> Not really an issue since DMD only counts the code that goes
> into the binary for coverage. Uncovered lines will have seven
> zeroes before the |, whereas lines with no compiled code will
> have nothing.
Not true. I wouldn't be able to link an example in Phobos but
this is a more general issue with coverage. For example take a
file with:
template isSomething(T)
{
bool helper()
{
return true; // line 5
}
enum isSomething = helper;
}
unittest
{
bool test;
static if (isSomething!bool)
{test = true;}
assert(test);
}
and compile with -main -unittest -cov then run.
the lst file indicates 00000 for line 5.
Actually with `static if()` and helpers functions executed at
compile time, 100% coverage is unreachchable. This is more or
less the same that happens with if(__ctfe) branches.
More information about the Digitalmars-d
mailing list