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

Allow working with XDebug Code Coverage data with XDebug disabled #987

Open
Csardelacal opened this issue Mar 16, 2023 · 0 comments
Open

Comments

@Csardelacal
Copy link

Q A
php-code-coverage version 9.2.24
PHP version 8.2
Driver Xdebug
Xdebug version (if used) 3
Installation Method Composer
Usage Method other

Hi,

I collect Xdebug Coverage data while running integration tests with PHPUnit + Selenium Hub inside a Docker machine. I then collect the code coverage data, merge the ones that belong to the same test and use PHP_Code_coverage to generate a report in clover and HTML.

This works great, with one caveat. The exported coverage files are sometimes several megabytes and merging them is very CPU and memory intensive.

Without XDebug, merging these takes a few seconds, with XDebug in Coverage mode this balloons to several minutes. In order to run it without xdebug I added this rather horrible shim:

defined('XDEBUG_FILTER_CODE_COVERAGE') || define('XDEBUG_FILTER_CODE_COVERAGE', 1);
defined('XDEBUG_PATH_INCLUDE') || define('XDEBUG_PATH_INCLUDE', 1);
if (!function_exists('xdebug_set_filter')) {
	function xdebug_set_filter() {};
}

putenv('XDEBUG_MODE=coverage');

$coverage = new CodeCoverage(
	(new Selector)->forLineCoverage($filter),
	$filter
);

putenv('XDEBUG_MODE=');

It does the job, but I wish I could just process the code-coverage data without the need to either move the merging of the data to an external process or having to resort to a hack like this. It should be rather simple to pass an argument to the selector or provide an environment flag that disables checking when it's not needed.

Thank you again for the amazing work <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant