1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-23 06:14:55 +00:00

Merge branch 'master' into php7.1

This commit is contained in:
J. King 2020-02-02 15:45:58 -05:00
commit cb41912f36
2 changed files with 27 additions and 14 deletions

View file

@ -88,7 +88,7 @@ There is also a `test:quick` Robo task which excludes slower tests, and a `test:
### Test coverage ### Test coverage
Computing the coverage of tests can be done by running `./robo coverage`, after which an HTML-format coverage report will be written to `/tests/coverage/`. Either [Xdebug](https://xdebug.org) or [phpdbg](https://php.net/manual/en/book.phpdbg.php) is required for this. Xdebug is generally recommended as it is better maintained, though phpdbg is significantly faster. If using Xdebug, the extension need not be enabled globally; PHPUnit will enable it when needed. Computing the coverage of tests can be done by running `./robo coverage`, after which an HTML-format coverage report will be written to `/tests/coverage/`. Either [PCOV](https://github.com/krakjoe/pcov), [Xdebug](https://xdebug.org), or [phpdbg](https://php.net/manual/en/book.phpdbg.php) is required for this. PCOV is generally recommended as it is faster than Xdebug; phpdbg is faster still, but less accurate. If using either PCOV or Xdebug, the extension need not be enabled globally; PHPUnit will enable it when needed.
## Enforcing coding style ## Enforcing coding style

View file

@ -53,9 +53,9 @@ class RoboFile extends \Robo\Tasks {
* tests/coverage/. Additional reports may be produced by passing * tests/coverage/. Additional reports may be produced by passing
* arguments to this task as one would to PHPUnit. * arguments to this task as one would to PHPUnit.
* *
* Robo first tries to use phpdbg and will fall back to Xdebug if available. * Robo first tries to use pcov and will fall back first to xdebug then
* Because Xdebug slows down non-coverage tasks, however, phpdbg is highly * phpdbg. Neither pcov nor xdebug need to be enabled to be used; they
* recommended if debugging facilities are not otherwise needed. * only need to be present in the extension load path to be used.
*/ */
public function coverage(array $args): Result { public function coverage(array $args): Result {
// run tests with code coverage reporting enabled // run tests with code coverage reporting enabled
@ -89,6 +89,19 @@ class RoboFile extends \Robo\Tasks {
} }
protected function findCoverageEngine(): string { protected function findCoverageEngine(): string {
$dir = rtrim(ini_get("extension_dir"), "/").\DIRECTORY_SEPARATOR;
$ext = IS_WIN ? "dll" : (IS_MAC ? "dylib" : "so");
$php = escapeshellarg(\PHP_BINARY);
$code = escapeshellarg(BASE."lib");
if (extension_loaded("pcov")) {
return "$php -d pcov.enabled=1 -d pcov.directory=$code";
} elseif (extension_loaded("xdebug")) {
return $php;
} elseif (file_exists($dir."pcov.$ext")) {
return "$php -d extension=pcov.$ext -d pcov.enabled=1 -d pcov.directory=$code";
} elseif (file_exists($dir."pcov.$ext")) {
return "$php -d zend_extension=xdebug.$ext";
} else {
if (IS_WIN) { if (IS_WIN) {
$dbg = dirname(\PHP_BINARY)."\\phpdbg.exe"; $dbg = dirname(\PHP_BINARY)."\\phpdbg.exe";
$dbg = file_exists($dbg) ? $dbg : ""; $dbg = file_exists($dbg) ? $dbg : "";
@ -98,8 +111,8 @@ class RoboFile extends \Robo\Tasks {
if ($dbg) { if ($dbg) {
return escapeshellarg($dbg)." -qrr"; return escapeshellarg($dbg)." -qrr";
} else { } else {
$ext = IS_WIN ? "dll" : (IS_MAC ? "dylib" : "so"); return $php;
return escapeshellarg(\PHP_BINARY)." -d zend_extension=xdebug.$ext"; }
} }
} }