sebastianbergmann / php-code-coverage

Library that provides collection, processing, and rendering functionality for PHP code coverage information.
BSD 3-Clause "New" or "Revised" License
8.83k stars 374 forks source link

Code Coverage over HHVM Driver #302

Closed slashmili closed 9 years ago

slashmili commented 9 years ago

I'm trying to get code coverage for php/hacklang code under HHVM but I have some trouble and the executed lines don't tally.

Apparently in HHVM driver you are using fb_get_code_coverage(Just for the record in hhvm xdebug_get_code_coverage and fb_get_code_coverage are implemented the same way) which the return values are not same as xdebug_get_code_coverage. Link to prove that

I did some fix on src/CodeCoverage/Driver/HHVM.php it's not final yet but I did manage to get the proper reports in code coverage(I'll commit it in a bit)

The problem I have now is about code coverage report regarding number of methods. If you look at this gits when I run code coverage on HHVM, only one method is detected but on PHP, code coverage code detects 2 methods which is correct. So far I've found the the place that we count number of methods in PHP_CodeCoverage_Report_Node_File and I'm looking into that. However I appreciate if you can help me on that method

farzadghanei commented 9 years ago

:+1:

sebastianbergmann commented 9 years ago

Closing because of #324 and 672248f49a25fcca46aa6c73612d6731d6b83c4a. Please open a new ticket if the problem persists.

slashmili commented 9 years ago

Well the problem still exists because HHVM doesn't support xdebug 100%

hhvm --version
HipHop VM 3.7.1 (rel)
Compiler: tags/HHVM-3.7.1-0-g111c76378ac29aa8f25e6bb3c5f15b628e6bbea1
Repo schema: be14a89778f35ca7f7dd4aca7fff0793e8ae3334

hhvm -v Eval.Jit=false bin/phpunit --coverage-html ./coverage -c phpunit.xml src/Tests/ 
PHPUnit 4.6.6 by Sebastian Bergmann and contributors.

Configuration read from /home/milad/dev/my_app/phpunit.xml

Fatal error: XDEBUG_CC_UNUSED and XDEBUG_CC_DEAD_CODE constants are not currently supported. in /home/milad/dev/my_app/vendor/phpunit/php-code-coverage/src/CodeCoverage/Driver/Xdebug.php on line 47
    #0 xdebug_start_code_coverage(), called at [/home/milad/dev/my_app/vendor/phpunit/php-code-coverage/src/CodeCoverage/Driver/Xdebug.php:47]\n    #1 PHP_CodeCoverage_Driver_Xdebug->start(), called at [/home/milad/dev/my_app/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:232]\n    #2 PHP_CodeCoverage->start(), called at [/home/milad/dev/my_app/vendor/phpunit/phpunit/src/Framework/TestResult.php:580]\n    #3 PHPUnit_Framework_TestResult->run(), called at [/home/milad/dev/my_app/vendor/phpunit/phpunit/src/Framework/TestCase.php:699]\n    #4 PHPUnit_Framework_TestCase->run(), called at [/home/milad/dev/my_app/vendor/phpunit/phpunit/src/Framework/TestSuite.php:722]\n    #5 PHPUnit_Framework_TestSuite->run(), called at [/home/milad/dev/my_app/vendor/phpunit/phpunit/src/Framework/TestSuite.php:722]\n    #6 PHPUnit_Framework_TestSuite->run(), called at [/home/milad/dev/my_app/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:406]\n    #7 PHPUnit_TextUI_TestRunner->doRun(), called at [/home/milad/dev/my_app/vendor/phpunit/phpunit/src/TextUI/Command.php:153]\n    #8 PHPUnit_TextUI_Command->run(), called at [/home/milad/dev/my_app/vendor/phpunit/phpunit/src/TextUI/Command.php:105]\n    #9 PHPUnit_TextUI_Command::main(), called at [/home/milad/dev/my_app/vendor/phpunit/phpunit/phpunit:36]

I suppose it's better to not support the code coverage for hhvm until they are compatible with Xdebug