Code coverage in Phobos

Vladimir Panteleev via Digitalmars-d digitalmars-d at puremagic.com
Mon Mar 28 21:38:29 PDT 2016


On Monday, 28 March 2016 at 23:45:10 UTC, Basile B. wrote:
> 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:

Ah, OK. Though, this is something that could be improved in the 
implementation without changing the language. DMD should not emit 
code that's not called in the module, and not callable from 
outside the module due to e.g. being private. Probably would help 
with template bloat, too. LTO would probably take care of that in 
theory, I wonder if LDC's or GDC's LTO doesn't have this issue 
(not that it would help testing Phobos coverage).



More information about the Digitalmars-d mailing list