Commit dd75a6b1 authored by jrfnl's avatar jrfnl
Browse files

Test bootstrap: make the builds faster

The new Xdebug version 2.6.0 will have a feature to speed up code coverage a lot.
This code snippet enables that feature when code coverage is being run and the right Xdebug version is detected.

At this moment, the only Travis image which comes with Xdebug 2.6.0(beta1) is PHP 7.2.
Initial tests show a speed up of 60% in run-time for the unit tests on those images with this snippet in place.

Refs:
* https://twitter.com/derickr/status/953268665255940103
* https://github.com/sebastianbergmann/php-code-coverage/issues/514#issuecomment-354654930
* https://gist.github.com/hollodotme/1becd28a52a75ea4a120790ca262bf44
parent fc7ee881
......@@ -5,6 +5,26 @@
* @package PHPCompatibility
*/
/*
* When possible let Xdebug (2.6.0+) handle code coverage file filtering.
*
* @internal This MUST be run BEFORE any files are included for optimal effect!
*
* @link https://bugs.xdebug.org/view.php?id=1059
* @link https://github.com/sebastianbergmann/php-code-coverage/issues/514
*/
$testingCodeCoverage = getenv('COVERALLS_VERSION');
if ($testingCodeCoverage !== false && $testingCodeCoverage !== 'notset') {
$xdebugVersion = phpversion('xdebug');
if (version_compare($xdebugVersion, '2.5.99', '>') === true) {
xdebug_set_filter(
XDEBUG_FILTER_CODE_COVERAGE,
XDEBUG_PATH_WHITELIST,
array(dirname(__DIR__) . '/Sniffs')
);
}
}
if (defined('PHP_CODESNIFFER_IN_TESTS') === false) {
define('PHP_CODESNIFFER_IN_TESTS', true);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment