1

I'm honestly not sure if this is a bug or me missing something.

Devel::Cover ignores my # uncoverable branch true based on a previous condition somehow.

I have 2 files - Test and Test2 - the uncoverable is in Test.

Now when the trigger condition (see below) is not commented out I get 50% branch coverage that looks like this:

messed up coverage

Now comment out the trigger condition and run everything again and I get:

expected coverage

The branch is now properly ignored as uncoverable. The only thing that was changed was commenting out the trigger condition.

I really don't understand this behavior - if anybody would be willing to try this out to see if this is me not understanding something or a bug.

Disclaimer: I'm no perl guru :) I tried to simplify this more but I could not reproduce it otherwise - even simplification of this is appreciated - maybe it will help trace to the root cause of it.

EDIT: I made this repo to make this easier to reproduce: https://github.com/lukaskuzmiak/Devel--Cover_coverage_issue_PoC

package My::Test;

use 5.026;
use strict;
use warnings;

use My::Test2;


sub test {

    my $test2 = My::Test2->new({});

    if ($test2 > 1) { say 'something'; } # let's call this "trigger condition"

    # uncoverable branch true
    $test2->asdf(
        {
            variable => 'asdf'
        }
    ) or say 'something else';

    return 1;
}

1;

And a second Test2

package My::Test2;

use 5.026;
use strict;
use warnings;

sub new {
    my ($class, $args) = @_;
    my $self = {};
    return bless $self, $class;
}

sub asdf {
    my ($class, $args) = @_;
    return 1;
}

1;
lukash
  • 725
  • 6
  • 19
  • I have verified this and it is 1.31, good point though, thanks. I'm going over open issues on Github, there are a few that possibly could have the same root cause but don't look similar on the first look. I'll try to narrow it down and update this based on the results. – lukash Dec 09 '18 at 22:55
  • 1
    Your code does not match your example output. It's also unnecessarily complicated. If you can strip it down to a *complete* runnable example that illustrates the problem, we can possibly help. – showaltb Dec 10 '18 at 17:40
  • I tried to simplify it further, but I could no longer reproduce the issue. The screenshots are taken on this exact code - perl perhaps translates stuff internally? If you're referring to the "unless" that is not in my code. Anyway, I made a GitHub repo with all the sources to hopefully make it easier to reproduce. – lukash Dec 11 '18 at 04:45

0 Answers0