Browse Source

Merge branch 'master' into php7.1

rpm
J. King 4 years ago
parent
commit
cb41912f36
  1. 2
      README.md
  2. 39
      RoboFile.php

2
README.md

@ -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

39
RoboFile.php

@ -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,17 +89,30 @@ class RoboFile extends \Robo\Tasks {
} }
protected function findCoverageEngine(): string { protected function findCoverageEngine(): string {
if (IS_WIN) { $dir = rtrim(ini_get("extension_dir"), "/").\DIRECTORY_SEPARATOR;
$dbg = dirname(\PHP_BINARY)."\\phpdbg.exe"; $ext = IS_WIN ? "dll" : (IS_MAC ? "dylib" : "so");
$dbg = file_exists($dbg) ? $dbg : ""; $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 { } else {
$dbg = trim(`which phpdbg 2>/dev/null`); if (IS_WIN) {
} $dbg = dirname(\PHP_BINARY)."\\phpdbg.exe";
if ($dbg) { $dbg = file_exists($dbg) ? $dbg : "";
return escapeshellarg($dbg)." -qrr"; } else {
} else { $dbg = trim(`which phpdbg 2>/dev/null`);
$ext = IS_WIN ? "dll" : (IS_MAC ? "dylib" : "so"); }
return escapeshellarg(\PHP_BINARY)." -d zend_extension=xdebug.$ext"; if ($dbg) {
return escapeshellarg($dbg)." -qrr";
} else {
return $php;
}
} }
} }

Loading…
Cancel
Save