mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 13:12:41 +00:00
Prefer PCOV for code coverage
This commit is contained in:
parent
14ef33879b
commit
d7e10e40ee
2 changed files with 27 additions and 14 deletions
|
@ -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
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…
Reference in a new issue