|
@ -2,17 +2,12 @@ |
|
|
|
|
|
|
|
|
use Robo\Result; |
|
|
use Robo\Result; |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* This is project's console commands configuration for Robo task runner. |
|
|
|
|
|
* |
|
|
|
|
|
* @see http://robo.li/ |
|
|
|
|
|
*/ |
|
|
|
|
|
class RoboFile extends \Robo\Tasks { |
|
|
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 |
|
|
* Runs the typical test suite |
|
|
* |
|
|
* |
|
|
* Arguments passed to the task are passed on to PHPUnit. Thus one may, for |
|
|
* Arguments passed to the task are passed on to PHPUnit. Thus one may, for |
|
|
* example, run the following command and get the expected results: |
|
|
* example, run the following command and get the expected results: |
|
@ -22,21 +17,17 @@ class RoboFile extends \Robo\Tasks { |
|
|
* Please see the PHPUnit documentation for available options. |
|
|
* Please see the PHPUnit documentation for available options. |
|
|
*/ |
|
|
*/ |
|
|
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 |
|
|
return $this->runTests("php", "typical", $args); |
|
|
$this->taskServer(8000)->host("localhost")->dir(self::BASE_TEST."docroot")->rawArg("-n")->arg(self::BASE_TEST."server.php")->background()->run(); |
|
|
|
|
|
// run tests |
|
|
|
|
|
$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 the full test suite |
|
|
* Runs the full test suite |
|
|
* |
|
|
* |
|
|
* This is an alias of the "test" task. |
|
|
* This includes pedantic tests which may help to identify problems. |
|
|
|
|
|
* See help for the "test" task for more details. |
|
|
*/ |
|
|
*/ |
|
|
public function testFull(array $args): Result { |
|
|
public function testFull(array $args): Result { |
|
|
return $this->test($args); |
|
|
return $this->runTests("php", "full", $args); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -45,27 +36,33 @@ class RoboFile extends \Robo\Tasks { |
|
|
* See help for the "test" task for more details. |
|
|
* See help for the "test" task for more details. |
|
|
*/ |
|
|
*/ |
|
|
public function testQuick(array $args): Result { |
|
|
public function testQuick(array $args): Result { |
|
|
return $this->test(array_merge(["--exclude-group", "slow,optional"], $args)); |
|
|
return $this->runTests("php", "quick", $args); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** Produces a code coverage report |
|
|
/** Produces a code coverage report |
|
|
* |
|
|
* |
|
|
* By default this task produces an HTML-format coverage report in |
|
|
* By default this task produces an HTML-format coverage report in |
|
|
* arsse/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 phpdbg and will fall back to Xdebug if available. |
|
|
* Because Xdebug slows down non-coverage tasks, however, phpdbg is highly |
|
|
* Because Xdebug slows down non-coverage tasks, however, phpdbg is highly |
|
|
* recommanded is debugging facilities are not otherwise needed. |
|
|
* recommended if debugging facilities are not otherwise needed. |
|
|
*/ |
|
|
*/ |
|
|
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 |
|
|
// run tests with code coverage reporting enabled |
|
|
$exec = $this->findCoverageEngine(); |
|
|
$exec = $this->findCoverageEngine(); |
|
|
$execpath = realpath(self::BASE."vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit"); |
|
|
return $this->runTests($exec, "typical", array_merge(["--coverage-html", self::BASE_TEST."coverage"], $args)); |
|
|
$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(); |
|
|
|
|
|
|
|
|
/** Runs the coding standards fixer */ |
|
|
|
|
|
public function clean($opts = ['demo|d' => false]): Result { |
|
|
|
|
|
$t = $this->taskExec(realpath(self::BASE."vendor/bin/php-cs-fixer")); |
|
|
|
|
|
$t->arg("fix"); |
|
|
|
|
|
if ($opts['demo']) { |
|
|
|
|
|
$t->args("--dry-run", "--diff")->option("--diff-format", "udiff"); |
|
|
|
|
|
} |
|
|
|
|
|
return $t->run(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected function findCoverageEngine(): string { |
|
|
protected function findCoverageEngine(): string { |
|
@ -79,6 +76,26 @@ class RoboFile extends \Robo\Tasks { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected function runTests(string $executor, string $set, array $args) : Result { |
|
|
|
|
|
switch ($set) { |
|
|
|
|
|
case "typical": |
|
|
|
|
|
$set = ["--exclude-group", "optional"]; |
|
|
|
|
|
break; |
|
|
|
|
|
case "quick": |
|
|
|
|
|
$set = ["--exclude-group", "optional,slow"]; |
|
|
|
|
|
break; |
|
|
|
|
|
case "full": |
|
|
|
|
|
$set = []; |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
throw new \Exception; |
|
|
|
|
|
} |
|
|
|
|
|
$execpath = realpath(self::BASE."vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit"); |
|
|
|
|
|
$confpath = realpath(self::BASE_TEST."phpunit.xml"); |
|
|
|
|
|
$this->taskServer(8000)->host("localhost")->dir(self::BASE_TEST."docroot")->rawArg("-n")->arg(self::BASE_TEST."server.php")->background()->run(); |
|
|
|
|
|
return $this->taskExec($executor)->arg($execpath)->option("-c", $confpath)->args(array_merge($set, $args))->run(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** Packages a given commit of the software into a release tarball |
|
|
/** Packages a given commit of the software into a release tarball |
|
|
* |
|
|
* |
|
|
* The version to package may be any Git tree-ish identifier: a tag, a branch, |
|
|
* The version to package may be any Git tree-ish identifier: a tag, a branch, |
|
@ -128,13 +145,4 @@ class RoboFile extends \Robo\Tasks { |
|
|
$this->_exec("git worktree prune"); |
|
|
$this->_exec("git worktree prune"); |
|
|
return $out; |
|
|
return $out; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function clean($opts = ['demo|d' => false]): Result { |
|
|
|
|
|
$t = $this->taskExec(realpath(self::BASE."vendor/bin/php-cs-fixer")); |
|
|
|
|
|
$t->arg("fix"); |
|
|
|
|
|
if ($opts['demo']) { |
|
|
|
|
|
$t->args("--dry-run", "--diff")->option("--diff-format", "udiff"); |
|
|
|
|
|
} |
|
|
|
|
|
return $t->run(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|