mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 13:12:41 +00:00
Remove reliance on xdebug; fixes #113
Code coverage information is now gathered via phpdbg (a separate executable) by if available rather than xdebug, as the latter is hard to turn on and off. A "test:quick" task has also been added to Robo, which excludes 31 tests which together account for almost two thirds of the test run time. This should pave the way for testing to be added as a commit hook for Git.
This commit is contained in:
parent
183718204d
commit
73c8583744
3 changed files with 31 additions and 5 deletions
28
RoboFile.php
28
RoboFile.php
|
@ -11,18 +11,44 @@ class RoboFile extends \Robo\Tasks {
|
||||||
const BASE = __DIR__.\DIRECTORY_SEPARATOR;
|
const BASE = __DIR__.\DIRECTORY_SEPARATOR;
|
||||||
const BASE_TEST = self::BASE."tests".\DIRECTORY_SEPARATOR;
|
const BASE_TEST = self::BASE."tests".\DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
|
/** Runs the full test suite */
|
||||||
public function test(array $args): Result {
|
public function test(array $args): Result {
|
||||||
// start the built-in PHP server, which is required for some of the tests
|
// start the built-in PHP server, which is required for some of the tests
|
||||||
$this->taskServer(8000)->host("localhost")->dir(self::BASE_TEST."docroot")->rawArg("-n")->arg(self::BASE_TEST."server.php")->background()->run();
|
$this->taskServer(8000)->host("localhost")->dir(self::BASE_TEST."docroot")->rawArg("-n")->arg(self::BASE_TEST."server.php")->background()->run();
|
||||||
// run tests
|
// run tests
|
||||||
return $this->taskPHPUnit()->configFile(self::BASE_TEST."phpunit.xml")->args($args)->run();
|
$execpath = realpath(self::BASE."vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit");
|
||||||
|
$confpath = realpath(self::BASE_TEST."phpunit.xml");
|
||||||
|
return $this->taskExec("php")->arg($execpath)->option("-c", $confpath)->args($args)->run();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Runs a quick subset of the test suite */
|
||||||
|
public function testQuick(array $args): Result {
|
||||||
|
return $this->test(array_merge(["--exclude-group","slow"], $args));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function coverage(array $args): Result {
|
public function coverage(array $args): Result {
|
||||||
|
// start the built-in PHP server, which is required for some of the tests
|
||||||
|
$this->taskServer(8000)->host("localhost")->dir(self::BASE_TEST."docroot")->rawArg("-n")->arg(self::BASE_TEST."server.php")->background()->run();
|
||||||
|
// run tests with code coverage reporting enabled
|
||||||
|
$exec = $this->findCoverageEngine();
|
||||||
|
$execpath = realpath(self::BASE."vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit");
|
||||||
|
$confpath = realpath(self::BASE_TEST."phpunit.xml");
|
||||||
|
return $this->taskExec($exec)->arg($execpath)->option("-c", $confpath)->option("--coverage-html", self::BASE_TEST."coverage")->args($args)->run();
|
||||||
// run the test suite with code coverage reporting enabled
|
// run the test suite with code coverage reporting enabled
|
||||||
return $this->test(array_merge(["--coverage-html",self::BASE_TEST."coverage"], $args));
|
return $this->test(array_merge(["--coverage-html",self::BASE_TEST."coverage"], $args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function findCoverageEngine(): string {
|
||||||
|
$null = null;
|
||||||
|
$code = 0;
|
||||||
|
exec("phpdbg --version", $null, $code);
|
||||||
|
if (!$code) {
|
||||||
|
return "phpdbg -qrr";
|
||||||
|
} else {
|
||||||
|
return "php";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function package(array $args): Result {
|
public function package(array $args): Result {
|
||||||
// establish which commit to package
|
// establish which commit to package
|
||||||
$version = $args ? $args[0] : $this->askDefault("Commit to package:", "head");
|
$version = $args ? $args[0] : $this->askDefault("Commit to package:", "head");
|
||||||
|
|
|
@ -103,7 +103,7 @@ class ValueInfo {
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break; // @codeCoverageIgnore
|
||||||
case self::T_FLOAT:
|
case self::T_FLOAT:
|
||||||
if (is_float($value)) {
|
if (is_float($value)) {
|
||||||
return $value;
|
return $value;
|
||||||
|
@ -161,7 +161,7 @@ class ValueInfo {
|
||||||
} else {
|
} else {
|
||||||
return (string) $value;
|
return (string) $value;
|
||||||
}
|
}
|
||||||
break;
|
break; // @codeCoverageIgnore
|
||||||
case self::T_DATE:
|
case self::T_DATE:
|
||||||
if ($value instanceof \DateTimeImmutable) {
|
if ($value instanceof \DateTimeImmutable) {
|
||||||
return $value->setTimezone(new \DateTimeZone("UTC"));
|
return $value->setTimezone(new \DateTimeZone("UTC"));
|
||||||
|
@ -239,7 +239,7 @@ class ValueInfo {
|
||||||
return [$value];
|
return [$value];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break; // @codeCoverageIgnore
|
||||||
default:
|
default:
|
||||||
throw new ExceptionType("typeUnknown", $type); // @codeCoverageIgnore
|
throw new ExceptionType("typeUnknown", $type); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,5 +8,5 @@ namespace JKingWeb\Arsse;
|
||||||
|
|
||||||
const NS_BASE = __NAMESPACE__."\\";
|
const NS_BASE = __NAMESPACE__."\\";
|
||||||
define(NS_BASE."BASE", dirname(__DIR__).DIRECTORY_SEPARATOR);
|
define(NS_BASE."BASE", dirname(__DIR__).DIRECTORY_SEPARATOR);
|
||||||
|
ini_set("memory_limit", "-1");
|
||||||
require_once BASE."vendor".DIRECTORY_SEPARATOR."autoload.php";
|
require_once BASE."vendor".DIRECTORY_SEPARATOR."autoload.php";
|
||||||
|
|
Loading…
Reference in a new issue