Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect detection: line executed is marked as not executed #687

Closed
xthiago opened this issue Jul 25, 2019 · 6 comments

Comments

@xthiago
Copy link

commented Jul 25, 2019

Q A
php-code-coverage version 7.0.6
PHP version PHP 7.4.0alpha2 (cli) (built: Jul 12 2019 01:56:19) ( NTS )
Driver Xdebug
Xdebug version 2.8.0alpha1
Installation Method Composer
Usage Method PHPUnit
PHPUnit version 8.2.5

When I was analyzing the code coverage I saw that ->verifyNow() call below is incorrectly detected as not executed.

public static function fromString(string $latitude, string $longitude) : self
    {
        Assert::lazy()
            ->that($latitude, 'latitude')->range(self::LATITUDE_RANGE['min'], self::LATITUDE_RANGE['max'])
            ->that($longitude, 'longitude')->range(self::LONGITUDE_RANGE['min'], self::LONGITUDE_RANGE['max'])
            ->verifyNow();

        return new self($latitude, $longitude);
    }

The report:

image

It is detected correctly if I a change that the structure of statements to call everything in one line:

    public static function fromString(string $latitude, string $longitude) : self
    {
        Assert::lazy()->that($latitude, 'latitude')->range(self::LATITUDE_RANGE['min'], self::LATITUDE_RANGE['max'])->that($longitude, 'longitude')->range(self::LONGITUDE_RANGE['min'], self::LONGITUDE_RANGE['max'])->verifyNow();

        return new self($latitude, $longitude);
    }

image

Or if I split the verifyNow() call to another line:

public static function fromString(string $latitude, string $longitude) : self
    {
        $assertion = Assert::lazy()
            ->that($latitude, 'latitude')->range(self::LATITUDE_RANGE['min'], self::LATITUDE_RANGE['max'])
            ->that($longitude, 'longitude')->range(self::LONGITUDE_RANGE['min'], self::LONGITUDE_RANGE['max']);
        $assertion->verifyNow();

        return new self($latitude, $longitude);
    }

image

@sebastianbergmann

This comment has been minimized.

Copy link
Owner

commented Jul 25, 2019

There can be many reasons why a specific line is not covered. Each of them is likely a different issue. In order to be able to reproduce anything and not get bogged down with details, you need to provide the following in ONE new issue per case.

That means:

  • The exact versions of (this is what the template requires too, but more):
    • PHP
    • PHP Code Coverage
    • Xdebug
    • PHPUnit
  • php -v output
  • Either a .tar.gz archive or a GitHub repository with a reproduce case. With one file that shows the problem and one test case file (with the exception that sometimes, you might need two source files to show a problem.

This information should be filed as one specific case per issue.

CC @derickr

xthiago added a commit to xthiago/php-code-coverage-with-incorrect-line-detection that referenced this issue Jul 25, 2019
@xthiago

This comment has been minimized.

Copy link
Author

commented Jul 25, 2019

@xthiago

This comment has been minimized.

Copy link
Author

commented Jul 27, 2019

I have upgraded the Dockerfile of the repository to PHP 7.4.0beta1 and xdebug to 2.8.0beta1 and the problem still happening.

For curiosity, I created a scenario version with php 7.3 and I can confirm that in this version the line is detected correctly.

@krakjoe

This comment has been minimized.

Copy link
Contributor

commented Jul 31, 2019

@xthiago just fyi, there is nothing that @sebastianbergmann can do, this is not a bug in this package but upstream in Xdebug, opening an issue on the Xdebug tracker is the only way forward.

@derickr

This comment has been minimized.

Copy link

commented Jul 31, 2019

If you do file an issue at https://bugs.xdebug.org, please only supply the file Sample.php. I have no use for Docker images and the like.

@xthiago

This comment has been minimized.

Copy link
Author

commented Aug 1, 2019

I opened the issue on Xdebug side: https://bugs.xdebug.org/view.php?id=1691

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.