Jump to page: 1 2
Thread overview
CTFE in coverage reports - I finally fixed it
Jun 15, 2020
Stefan Koch
Jun 15, 2020
Bruce Carneal
Jun 15, 2020
Stefan Koch
Jun 15, 2020
Ali Çehreli
Jun 15, 2020
Max Samukha
Jun 15, 2020
Stefan Koch
Jun 15, 2020
Faux Amis
Jun 16, 2020
Stefan Koch
Jun 16, 2020
aberba
Jun 16, 2020
Stefan Koch
Jun 16, 2020
aberba
Jun 17, 2020
Stefan Koch
Jun 15, 2020
Stanislav Blinov
Jun 16, 2020
Jesse Phillips
June 15, 2020
Hi Guys,

CTFE not being in coverage reports has made 100% coverage unattainable
for code which has if (__ctfe) branches.

Well fret no more.
A few hours ago I've gotten this result.

---
      4|int f(int n) { int acc;
     42|    foreach(i;0 .. n)
       |    {
     10|        acc += i;
       |    }
      4|    return acc;
       |}
       |
       |
       |pragma(msg, f2(4));
       |pragma(msg, f(4));
       |pragma(msg, f2(4));
       |
       |void main()
       |{
       |    import core.stdc.stdio;
      1|    printf("%d %d %d\n", f(1), f(2), f(3));
       |}
       |
       |int f2(int n)
       |{
      2|    int acc;
     30|    foreach(i;0 .. n)
       |    {
      8|        acc += i;
       |    }
      2|    return acc;}
test_ctfe.d is 100% covered
---

the function f2() is never called at runtime at yet we are 100% covered.

The way it works is quite simple.
During CTFE we keep an array which counts the lines we hit.
When it comes time to do codegen we simply initialize the hidden __coverge symbol.
Which is a uint[]  representing the coverage counts for line numbers with that information rather than filling it with zeros.

Therefore no modification to the runtime is necessary at all.

It's open as DMD pr: https://github.com/dlang/dmd/pull/11279

and hopefully passing on all platforms.

Cheers,

Stefan
June 15, 2020
On Monday, 15 June 2020 at 15:02:04 UTC, Stefan Koch wrote:
> Hi Guys,
>
> CTFE not being in coverage reports has made 100% coverage unattainable
> for code which has if (__ctfe) branches.
>
> Well fret no more.

[snip of code demonstrating the improvement, better coverage stats]

>
>
> The way it works is quite simple.
> During CTFE we keep an array which counts the lines we hit.
> When it comes time to do codegen we simply initialize the hidden __coverge symbol.
> Which is a uint[]  representing the coverage counts for line numbers with that information rather than filling it with zeros.
>
> Therefore no modification to the runtime is necessary at all.
>
> It's open as DMD pr: https://github.com/dlang/dmd/pull/11279
>
> and hopefully passing on all platforms.
>
> Cheers,
>
> Stefan

Thanks for this Stefan.  Another nice step towards "it all just works" and a commendably simple implementation.





June 15, 2020
On Monday, 15 June 2020 at 16:49:16 UTC, Bruce Carneal wrote:
> On Monday, 15 June 2020 at 15:02:04 UTC, Stefan Koch wrote:
>> Hi Guys,
>>
>> CTFE not being in coverage reports has made 100% coverage unattainable
>> for code which has if (__ctfe) branches.
>> 
>> Fret no mre.
>>
>> Stefan
>
> Thanks for this Stefan.  Another nice step towards "it all just works" and a commendably simple implementation.

Thanks Bruce, it does help tremendously to get this kind of feedback.

Cheers,
Stefan

P.S. let's meet at  the online beerconf, if and when it happnes.
June 15, 2020
On 6/15/20 10:11 AM, Stefan Koch wrote:

> it does help tremendously to get this kind of feedback.

Sorry for being quiet but I always appreciate your work. It's inspring how you never give up and continue going forward. :)

Ali

June 15, 2020
On Monday, 15 June 2020 at 18:49:01 UTC, Ali Çehreli wrote:
> On 6/15/20 10:11 AM, Stefan Koch wrote:
>
> > it does help tremendously to get this kind of feedback.
>
> Sorry for being quiet but I always appreciate your work. It's inspring how you never give up and continue going forward. :)
>
> Ali

Same here. Stefan rox.
June 15, 2020
On Monday, 15 June 2020 at 20:00:55 UTC, Max Samukha wrote:
> On Monday, 15 June 2020 at 18:49:01 UTC, Ali Çehreli wrote:
>> On 6/15/20 10:11 AM, Stefan Koch wrote:
>>
>> > it does help tremendously to get this kind of feedback.
>>
>> Sorry for being quiet but I always appreciate your work. It's inspring how you never give up and continue going forward. :)
>>
>> Ali
>
> Same here. Stefan rox.

Thank you both Ali and Max.

June 15, 2020
On 2020-06-15 19:11, Stefan Koch wrote:
> On Monday, 15 June 2020 at 16:49:16 UTC, Bruce Carneal wrote:
>> On Monday, 15 June 2020 at 15:02:04 UTC, Stefan Koch wrote:
>>> Hi Guys,
>>>
>>> CTFE not being in coverage reports has made 100% coverage unattainable
>>> for code which has if (__ctfe) branches.
>>>
>>> Fret no mre.
>>>
>>> Stefan
>>
>> Thanks for this Stefan.  Another nice step towards "it all just works" and a commendably simple implementation.
> 
> Thanks Bruce, it does help tremendously to get this kind of feedback.
> 
> Cheers,
> Stefan
> 
> P.S. let's meet at  the online beerconf, if and when it happnes.

Stefan, let me then add that I always look up to your work.
Become one of the greats! ;)
June 15, 2020
On Monday, 15 June 2020 at 17:11:25 UTC, Stefan Koch wrote:
> On Monday, 15 June 2020 at 16:49:16 UTC, Bruce Carneal wrote:

>> Thanks for this Stefan.  Another nice step towards "it all just works" and a commendably simple implementation.
>
> Thanks Bruce, it does help tremendously to get this kind of feedback.

How to know that you did great work: nobody is saying anything, everybody's just using it ;)

Keep rocking!
June 16, 2020
On Monday, 15 June 2020 at 15:02:04 UTC, Stefan Koch wrote:
> Hi Guys,
>
> CTFE not being in coverage reports has made 100% coverage unattainable
> for code which has if (__ctfe) branches.
>
> Well fret no more.
> A few hours ago I've gotten this result.
>

D has no much potential to take on so many different domains. Moving programming challenges to compile time creates some unique opportunity.

It is nice to hear about your progress.
June 16, 2020
On Monday, 15 June 2020 at 20:51:13 UTC, Faux Amis wrote:
> On 2020-06-15 19:11, Stefan Koch wrote:
>> On Monday, 15 June 2020 at 16:49:16 UTC, Bruce Carneal wrote:
>>> On Monday, 15 June 2020 at 15:02:04 UTC, Stefan Koch wrote:
>>>> Hi Guys,
>>>>
>>>> CTFE not being in coverage reports has made 100% coverage unattainable
>>>> for code which has if (__ctfe) branches.
>>>>
>>>> Fret no mre.
>>>>
>>>> Stefan
>>>
>>> Thanks for this Stefan.  Another nice step towards "it all just works" and a commendably simple implementation.
>> 
>> Thanks Bruce, it does help tremendously to get this kind of feedback.
>> 
>> Cheers,
>> Stefan
>> 
>> P.S. let's meet at  the online beerconf, if and when it happnes.
>
> Stefan, let me then add that I always look up to your work.
> Become one of the greats! ;)

Thanks.
I am happy you think so.
« First   ‹ Prev
1 2