hhvm icon indicating copy to clipboard operation
hhvm copied to clipboard

[WIP] fix xdebug coverage (part2): support XDEBUG_CC_UNUSED and XDEBUG_CC_DEAD_CODE

Open xKerman opened this issue 8 years ago • 8 comments

description

related to: #1589 and #7888

This pull request adds support for XDEBUG_CC_UNUSED and XDEBUG_CC_DEAD_CODE flags to xdebug_start_code_coverage() .

example

With this pull request, code coverage report for moneyphp/money can be generated with HHVM + PHPUnit as following: https://xkerman.github.io/hhvm-coverage-sample/hhvm/

Contrast coverage report genereated with PHP5.6 + PHPUnit: https://xkerman.github.io/hhvm-coverage-sample/php56/

Note: In order to generate coverage report with HHVM + PHPUnit, I need to apply the following patch to phpunit/php-code-coverage:

diff --git a/src/Driver/HHVM.php b/src/Driver/HHVM.php
index b35ea81..85dc6a9 100644
--- a/src/Driver/HHVM.php
+++ b/src/Driver/HHVM.php
@@ -24,6 +24,6 @@ class HHVM extends Xdebug
      */
     public function start($determineUnusedAndDead = true)
     {
-        xdebug_start_code_coverage();
+        xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
     }

xKerman avatar Jul 02 '17 09:07 xKerman

2 weeks have passed since I submitted this pull request. @mofarrell could you review this?

xKerman avatar Jul 16 '17 21:07 xKerman

@mofarrell has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

hhvm-bot avatar Jul 24 '17 15:07 hhvm-bot

Thanks, but I found there is a conflict. I will rebase this pull request.

xKerman avatar Jul 24 '17 16:07 xKerman

@xKerman updated the pull request - view changes - changes since last import

hhvm-bot avatar Jul 24 '17 20:07 hhvm-bot

@mofarrell has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

facebook-github-bot avatar Jul 28 '17 16:07 facebook-github-bot

@mofarrell It has been over 2 weeks since this pull request was imported to Phabricator. I would appreciate it if you let me know whether any updates are needed.

xKerman avatar Aug 14 '17 14:08 xKerman

@xKerman Sorry this has taken so long. I kept checking back after test results had expired. This looks like it is working well, but I feel like it would be cleaner to do all the book keeping in a single map. Rather than merging them at the end.

mofarrell avatar Aug 14 '17 21:08 mofarrell

@mofarrell Thanks for your code review and comments.

it would be cleaner to do all the book keeping in a single map. Rather than merging them at the end.

I see, I will try to change to use a single map (m_hits) for reporting code coverage.

xKerman avatar Aug 14 '17 23:08 xKerman