Anatomy of a bad test

Joakim via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 7 11:22:11 PDT 2016


On Thursday, 7 July 2016 at 13:48:56 UTC, Andrei Alexandrescu 
wrote:
> On 07/07/2016 04:27 AM, Joakim wrote:
>> Dan recently found an off-by-one bug in std.conv.toChars from 
>> Phobos,
>> that somehow wasn't surfaced by our tests:
>
> Nice! Worth a blog entry? -- Andrei

Maybe once we do something different about our process, whether 
adding sanitizers or adding coverage checks to github PRs, seems 
too short right now.

On Thursday, 7 July 2016 at 14:04:30 UTC, Seb wrote:
> On Thursday, 7 July 2016 at 08:27:58 UTC, Joakim wrote:
>> Moral of the story: always check the happy path with your 
>> tests.  It's easy to get caught up in all the corner cases, 
>> just don't forget the happy path.
>
> Isn't the moral that we should start to check  code coverage 
> for PRs and alert reviewers if the code coverage decreased or 
> new, untested lines are added?

While that's a good idea, it wouldn't have caught this bug, as 
the corner case test did exercise all of the opSlice function 
that had the off-by-one bug.  It just did so with test input that 
happened to pass anyway.


More information about the Digitalmars-d mailing list