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

Reported code coverage differs from what PHP/Xdebug reports #1589

Open
sebastianbergmann opened this issue Jan 18, 2014 · 5 comments
Open

Reported code coverage differs from what PHP/Xdebug reports #1589

sebastianbergmann opened this issue Jan 18, 2014 · 5 comments

Comments

@sebastianbergmann
Copy link
Contributor

While working on code coverage support for PHPUnit on HHVM, I discovered that the reported code coverage differs from what Xdebug reports. This will probably not be the only difference between HHVM's and Xdebug's code coverage but it's the first I found.

To reproduce, simply run PHPUnit's master on the test suite of https://github.com/sebastianbergmann/money (phpunit -c build).

PHP and Xdebug report 100% code coverage:

php

HHVM reports less than 100% code coverage:

hhvm-1

hhvm-2

hhvm-3

@scannell
Copy link
Contributor

Thanks for reporting this. I don't know if anyone has looked at the code coverage code in a long time -- that I couldn't get an answer about it easily tells me that's probably the case. It looks like the last non-cleanup commit in the code was about 22 months ago, so if anyone wants to take a look at it before we get back it, it would be appreciated.

@goldenice
Copy link

I have noticed this too. As I test over the commandline, I do not have fancy graphics, but I have prepared a pastebin file with the PHPUnit outputs of runs on both HHVM and PHP 5.6: http://pastebin.com/VZvxC6TL

@keradus
Copy link

keradus commented Dec 17, 2015

Wow! 2 years old and no fix!

@GroovyCarrot
Copy link

I find that await seems to knock code coverage out for the rest of the function, as well as the inconsistencies mentioned above

@KazuakiM
Copy link

KazuakiM commented May 5, 2017

I am maintaining the "Coveralls" PHP library. Therefore, I would like to improve the HHVM Coverage acquisition problem. Is this problem likely to be solved?

hhvm-bot pushed a commit that referenced this issue Jun 29, 2017
…format for executed line

Summary:
This pull request is related to #1589 .
(I will submit another pull request for supporting `XDEBUG_CC_UNUSED` and `XDEBUG_CC_DEAD_CODE` later)

`xdebug_get_code_coverage()` return value format is described in https://xdebug.org/docs/code_coverage :

> The returned values for each line are:
> * 1: this line was executed
> * -1: this line was not executed
> * -2: this line did not have executable code on it

According to this description, `xdebug_get_code_coverage()` should return value like:

```
[
    "/path/to/foo.php" => [
          3 => 1,  // executed line 3
          5 => 1,  // executed line 5
    ]
]
```

However, hhvm's `xdebug_get_code_coverage()` currently returns value like:

```
[
    "/path/to/foo.php" => [
          3 => 2,  // executed line 3 (2 times)
          5 => 3,  // executed line 5 (3 times)
    ]
]
```

In this pull request, hhvm's `xdebug_get_code_coverage()` return value format for executed line is changed to follow description in https://xdebug.org/docs/code_coverage .
Closes #7888

Differential Revision: D5294692

Pulled By: mofarrell

fbshipit-source-id: c394e7b7b7c352edf66b2d6fa4895413b2005a35
@lexidor lexidor mentioned this issue Sep 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants