2bfd226663
- allow atoum bin to be called directly into PHPCI and not only in the current project tested (changed -d option), - added plugin in the phpci's composer.json, - modify execute method of the plugin because atoum always return 0 even if errors are catched,
62 lines
1.4 KiB
PHP
62 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace PHPCI\Plugin;
|
|
|
|
class Atoum implements \PHPCI\Plugin
|
|
{
|
|
private $args;
|
|
private $config;
|
|
private $directory;
|
|
|
|
public function __construct(\PHPCI\Builder $phpci, array $options = array())
|
|
{
|
|
$this->phpci = $phpci;
|
|
|
|
if (isset($options['executable'])) {
|
|
$this->executable = $options['executable'];
|
|
}
|
|
else {
|
|
$this->executable = PHPCI_BIN_DIR.'atoum';
|
|
}
|
|
|
|
if (isset($options['args'])) {
|
|
$this->args = $options['args'];
|
|
}
|
|
|
|
if (isset($options['config'])) {
|
|
$this->config = $options['config'];
|
|
}
|
|
|
|
if (isset($options['directory'])) {
|
|
$this->directory = $options['directory'];
|
|
}
|
|
}
|
|
|
|
public function execute()
|
|
{
|
|
$cmd = $this->executable;
|
|
|
|
if ($this->args !== null) {
|
|
$cmd .= " {$this->args}";
|
|
}
|
|
if ($this->config !== null) {
|
|
$cmd .= " -c '{$this->config}'";
|
|
}
|
|
if ($this->directory !== null) {
|
|
$dirPath = $this->phpci->buildPath . DIRECTORY_SEPARATOR . $this->directory;
|
|
$cmd .= " -d '{$dirPath}'";
|
|
}
|
|
|
|
$output = '';
|
|
$status = true;
|
|
exec($cmd, $output);
|
|
|
|
if (!empty($output) && count(preg_grep("/error/i",$output)) > 0) {
|
|
$status = false;
|
|
$this->phpci->log($output, ' ');
|
|
}
|
|
|
|
return $status;
|
|
}
|
|
}
|