Added Codeception UI plugin

This commit is contained in:
Igor Timoshenko 2015-02-04 14:21:21 +00:00 committed by Tobias van Beek
parent 44c489dd22
commit 55b10948ef
13 changed files with 170 additions and 22 deletions

View file

@ -166,6 +166,7 @@ Services</a> sektionen under dit Bitbucket-repository.',
'lines_of_code' => 'Kode-linjer',
'build_log' => 'Build-log',
'quality_trend' => 'Kvalitets-trend',
'codeception_errors' => 'Codeception-fejl',
'phpmd_warnings' => 'PHPMD-advarsler',
'phpcs_warnings' => 'PHPCS-advarsler',
'phpcs_errors' => 'PHPCS-fejl',
@ -174,6 +175,7 @@ Services</a> sektionen under dit Bitbucket-repository.',
'phpdoccheck_warnings' => 'Manglende Docblocks',
'issues' => 'Sager',
'codeception' => 'Codeception',
'phpcpd' => 'PHP Copy/Paste Detector',
'phpcs' => 'PHP Code Sniffer',
'phpdoccheck' => 'Manglende Docblocks',

View file

@ -164,6 +164,7 @@ generiert. Um es zu verwenden, fügen Sie einfach den folgenden Public Key im Ab
'lines_of_code' => 'Anzahl Codezeilen',
'build_log' => 'Buildprotokoll',
'quality_trend' => 'Qualitätstrend',
'codeception_errors' => 'Codeception Errors',
'phpmd_warnings' => 'PHPMD Warnings',
'phpcs_warnings' => 'PHPCS Warnings',
'phpcs_errors' => 'PHPCS Errors',
@ -172,6 +173,7 @@ generiert. Um es zu verwenden, fügen Sie einfach den folgenden Public Key im Ab
'phpdoccheck_warnings' => 'Fehlende Docblocks',
'issues' => 'Probleme',
'codeception' => 'Codeception',
'phpcpd' => 'PHP Copy/Paste Detector',
'phpcs' => 'PHP Code Sniffer',
'phpdoccheck' => 'Fehlende Docblocks',

View file

@ -166,6 +166,7 @@ Services</a> του Bitbucket αποθετηρίου σας.',
'lines_of_code' => 'Γραμμές Κώδικα',
'build_log' => 'Αρχείο καταγραφής κατασκευών',
'quality_trend' => 'Ποιότητα τρέντ',
'codeception_errors' => 'Λάθη Codeception',
'phpmd_warnings' => 'Προειδοποιήσεις PHPMD',
'phpcs_warnings' => 'Προειδοποιήσεις PHPCS ',
'phpcs_errors' => 'Λάθη PHPCS',
@ -174,6 +175,7 @@ Services</a> του Bitbucket αποθετηρίου σας.',
'phpdoccheck_warnings' => 'Χαμένα Docblocks',
'issues' => 'Θέματα',
'codeception' => 'Codeception',
'phpcpd' => 'PHP Ανιχνευτής Αντιγραφής/Επικόλλησης',
'phpcs' => 'Sniffer Κώδικα PHP',
'phpdoccheck' => 'Χαμένα Docblocks',

View file

@ -167,6 +167,7 @@ PHPCI',
'lines_of_code' => 'Lines of Code',
'build_log' => 'Build Log',
'quality_trend' => 'Quality Trend',
'codeception_errors' => 'Codeception Errors',
'phpmd_warnings' => 'PHPMD Warnings',
'phpcs_warnings' => 'PHPCS Warnings',
'phpcs_errors' => 'PHPCS Errors',
@ -175,6 +176,7 @@ PHPCI',
'phpdoccheck_warnings' => 'Missing Docblocks',
'issues' => 'Issues',
'codeception' => 'Codeception',
'phpcpd' => 'PHP Copy/Paste Detector',
'phpcs' => 'PHP Code Sniffer',
'phpdoccheck' => 'Missing Docblocks',

View file

@ -167,6 +167,7 @@ PHPCI',
'lines_of_code' => 'Lignes de code',
'build_log' => 'Log du build',
'quality_trend' => 'Tendance de la qualité',
'codeception_errors' => 'Erreurs Codeception',
'phpmd_warnings' => 'Alertes PHPMD',
'phpcs_warnings' => 'Alertes PHPCS',
'phpcs_errors' => 'Erreurs PHPCS',
@ -175,6 +176,7 @@ PHPCI',
'phpdoccheck_warnings' => 'Blocs de documentation manquants',
'issues' => 'Tickets',
'codeception' => 'Codeception',
'phpcpd' => 'PHP Copy/Paste Detector',
'phpcs' => 'PHP Code Sniffer',
'phpdoccheck' => 'Missing Docblocks',

View file

@ -11,7 +11,7 @@ $strings = array(
'language_name' => 'Italiano',
'language' => 'Lingua',
// Log in:
'log_in_to_phpci' => 'Accedi a PHPCI',
'login_error' => 'Indirizzo email o password errati',
@ -169,6 +169,7 @@ PHPCI',
'lines_of_code' => 'Linee di codice',
'build_log' => 'Log della build',
'quality_trend' => 'Trend della qualità',
'codeception_errors' => 'Errori di Codeception',
'phpmd_warnings' => 'Avvisi di PHPMD',
'phpcs_warnings' => 'Avvisi di PHPCS',
'phpcs_errors' => 'Errori di PHPCS',
@ -177,6 +178,7 @@ PHPCI',
'phpdoccheck_warnings' => 'Docblocks mancanti',
'issues' => 'Segnalazioni',
'codeception' => 'Codeception',
'phpcpd' => 'PHP Copy/Paste Detector',
'phpcs' => 'PHP Code Sniffer',
'phpdoccheck' => 'Docblocks mancanti',

View file

@ -167,6 +167,7 @@ Services</a> sectie van je Bitbucket repository toegevoegd worden.',
'lines_of_code' => 'Lijnen code',
'build_log' => 'Build Log',
'quality_trend' => 'Kwaliteitstrend',
'codeception_errors' => 'Codeception Fouten',
'phpmd_warnings' => 'PHPMD Waarschuwingen',
'phpcs_warnings' => 'PHPCS Waarschuwingen',
'phpcs_errors' => 'PHPCS Fouten',
@ -175,6 +176,7 @@ Services</a> sectie van je Bitbucket repository toegevoegd worden.',
'phpdoccheck_warnings' => 'Ontbrekende Docblocks',
'issues' => 'Problemen',
'codeception' => 'Codeception',
'phpcpd' => 'PHP Copy/Paste Detector',
'phpcs' => 'PHP Code Sniffer',
'phpdoccheck' => 'Ontbrekende Docblocks',

View file

@ -167,6 +167,7 @@ Services</a> repozytoria Bitbucket.',
'lines_of_code' => 'Linie Kodu',
'build_log' => 'Log Budowania',
'quality_trend' => 'Trend Jakości',
'codeception_errors' => 'Błędy Codeception',
'phpmd_warnings' => 'Alerty PHPMD',
'phpcs_warnings' => 'Alerty PHPCS',
'phpcs_errors' => 'Błędy PHPCS',
@ -175,6 +176,7 @@ Services</a> repozytoria Bitbucket.',
'phpdoccheck_warnings' => 'Brakuje sekcji DocBlock',
'issues' => 'Problemy',
'codeception' => 'Codeception',
'phpcpd' => 'PHP Copy/Paste Detector',
'phpcs' => 'PHP Code Sniffer',
'phpdoccheck' => 'Brakuje sekcji DocBlock',

View file

@ -162,6 +162,7 @@ PHPCI',
'lines_of_code' => 'Строк кода',
'build_log' => 'Лог сборки',
'quality_trend' => 'Тенденция качества',
'codeception_errors' => 'Ошибки Codeception',
'phpmd_warnings' => 'Предупреждения PHPMD',
'phpcs_warnings' => 'Предупреждения PHPCS',
'phpcs_errors' => 'Ошибки PHPCS',
@ -170,6 +171,7 @@ PHPCI',
'phpdoccheck_warnings' => 'Пропущенные Docblocks',
'issues' => 'Проблемы',
'codeception' => 'Codeception',
'phpcpd' => 'PHP Copy/Paste Detector',
'phpcs' => 'PHP Code Sniffer',
'phpdoccheck' => 'Missing Docblocks',

View file

@ -167,14 +167,16 @@ PHPCI',
'lines_of_code' => 'Рядки коду',
'build_log' => 'Лог збірки',
'quality_trend' => 'Тенденція якості',
'codeception_errors' => 'Помилки Codeception',
'phpmd_warnings' => 'Попередження PHPMD',
'phpcs_warnings' => 'Попередження PHPCS',
'phpcs_errors' => 'Помилки PHPCS',
'phplint_errors' => 'Помилки Lint',
'phpunit_errors' => 'Помилки PHPCS',
'phpunit_errors' => 'Помилки PHPUnit',
'phpdoccheck_warnings' => 'Відсутні Docblocks',
'issues' => 'Проблеми',
'codeception' => 'Codeception',
'phpcpd' => 'PHP Copy/Paste Detector',
'phpcs' => 'PHP Code Sniffer',
'phpdoccheck' => 'Відсутні Docblocks',

View file

@ -9,37 +9,50 @@
namespace PHPCI\Plugin;
use PHPCI;
use PHPCI\Builder;
use PHPCI\Helper\Lang;
use PHPCI\Model\Build;
use PHPCI\Plugin\Util\TapParser;
/**
* Codeception Plugin - Enables full acceptance, unit, and functional testing.
* Codeception Plugin - Enables full acceptance, unit, and functional testing
*
* @author Don Gilbert <don@dongilbert.net>
* @author Igor Timoshenko <contact@igortimoshenko.com>
* @package PHPCI
* @subpackage Plugins
*/
class Codeception implements \PHPCI\Plugin
class Codeception implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
{
/**
* @var string
*/
protected $args = '';
/**
* @var Build
*/
protected $build;
/**
* @var Builder
*/
protected $phpci;
protected $build;
/**
* @var string|string[] The path (or array of paths) of an yml config for Codeception
*/
protected $configFile;
/**
* @var string|string[] $xmlConfigFile The path (or array of paths) of an xml config for PHPUnit
* @var string The path where the reports and logs are stored
*/
protected $xmlConfigFile;
protected $logPath = 'tests/_output';
/**
* Set up the plugin, configure options, etc.
*
* @param Builder $phpci
* @param Build $build
* @param array $options
@ -50,49 +63,86 @@ class Codeception implements \PHPCI\Plugin
$this->build = $build;
if (isset($options['config'])) {
$this->xmlConfigFile = $options['config'];
$this->configFile = $options['config'];
}
if (isset($options['args'])) {
$this->args = (string) $options['args'];
}
if (isset($options['log_path'])) {
$this->logPath = $options['log_path'];
}
}
/**
* Runs Codeception tests, optionally using specified config file(s).
* {@inheritDoc}
*/
public function execute()
{
$success = true;
// Run any config files first. This can be either a single value or an array.
if ($this->xmlConfigFile !== null) {
$success &= $this->runConfigFile($this->xmlConfigFile);
$this->phpci->logExecOutput(false);
// Run any config files first. This can be either a single value or an array
if ($this->configFile !== null) {
$success &= $this->runConfigFile($this->configFile);
}
$tapString = file_get_contents(
$this->phpci->buildPath . $this->logPath . DIRECTORY_SEPARATOR . 'report.tap.log'
);
try {
$tapParser = new TapParser($tapString);
$output = $tapParser->parse();
} catch (\Exception $ex) {
$this->phpci->logFailure($tapString);
throw $ex;
}
$failures = $tapParser->getTotalFailures();
$this->build->storeMeta('codeception-errors', $failures);
$this->build->storeMeta('codeception-data', $output);
$this->phpci->logExecOutput(true);
return $success;
}
/**
* Run tests from a Codeception config file.
* @param $configPath
* {@inheritDoc}
*/
public static function canExecute($stage, Builder $builder, Build $build)
{
return $stage === 'test';
}
/**
* Run tests from a Codeception config file
*
* @param string $configPath
* @return bool|mixed
*/
protected function runConfigFile($configPath)
{
if (is_array($configPath)) {
return $this->recurseArg($configPath, array($this, "runConfigFile"));
return $this->recurseArg($configPath, array($this, 'runConfigFile'));
} else {
$codecept = $this->phpci->findBinary('codecept');
if (!$codecept) {
$this->phpci->logFailure(Lang::get('could_not_find', 'codecept'));
return false;
}
$cmd = 'cd "%s" && ' . $codecept . ' run -c "%s" '. $this->args;
$cmd = 'cd "%s" && ' . $codecept . ' run -c "%s" --tap ' . $this->args;
if (IS_WIN) {
$cmd = 'cd /d "%s" && ' . $codecept . ' run -c "%s" '. $this->args;
$cmd = 'cd /d "%s" && ' . $codecept . ' run -c "%s" --tap ' . $this->args;
}
$configPath = $this->phpci->buildPath . $configPath;
@ -103,16 +153,18 @@ class Codeception implements \PHPCI\Plugin
}
/**
* @param $array
* @param $callable
* @param array $array
* @param \Callback $callable
* @return bool|mixed
*/
protected function recurseArg($array, $callable)
protected function recurseArg(array $array, $callable)
{
$success = true;
foreach ($array as $subItem) {
$success &= call_user_func($callable, $subItem);
}
return $success;
}
}

View file

@ -0,0 +1,75 @@
var codeceptionPlugin = ActiveBuild.UiPlugin.extend({
id: 'build-codeception-errors',
css: 'col-lg-6 col-md-12 col-sm-12 col-xs-12',
title: Lang.get('codeception'),
lastData: null,
displayOnUpdate: false,
box: true,
rendered: false,
register: function() {
var self = this;
var query = ActiveBuild.registerQuery('codeception-data', -1, {key: 'codeception-data'})
$(window).on('codeception-data', function(data) {
self.onUpdate(data);
});
$(window).on('build-updated', function() {
if (!self.rendered) {
self.displayOnUpdate = true;
query();
}
});
},
render: function() {
return $('<table class="table" id="codeception-data">' +
'<thead>' +
'<tr>' +
' <th>'+Lang.get('test')+'</th>' +
'</tr>' +
'</thead><tbody></tbody></table>');
},
onUpdate: function(e) {
if (!e.queryData) {
$('#build-codeception-errors').hide();
return;
}
this.rendered = true;
this.lastData = e.queryData;
var tests = this.lastData[0].meta_value;
var tbody = $('#codeception-data tbody');
tbody.empty();
if (tests.length == 0) {
$('#build-codeception-errors').hide();
return;
}
for (var i in tests) {
var row = $('<tr>' +
'<td><strong>'+tests[i].suite+'' +
'::'+tests[i].test+'</strong><br>' +
''+(tests[i].message || '')+'</td>' +
'</tr>');
if (!tests[i].pass) {
row.addClass('danger');
} else {
row.addClass('success');
}
tbody.append(row);
}
$('#build-codeception-errors').show();
}
});
ActiveBuild.registerPlugin(new codeceptionPlugin());

View file

@ -3,6 +3,7 @@ var warningsPlugin = ActiveBuild.UiPlugin.extend({
css: 'col-lg-6 col-md-6 col-sm-12 col-xs-12',
title: Lang.get('quality_trend'),
keys: {
'codeception-errors': Lang.get('codeception_errors'),
'phpmd-warnings': Lang.get('phpmd_warnings'),
'phpcs-warnings': Lang.get('phpcs_warnings'),
'phpcs-errors': Lang.get('phpcs_errors'),
@ -24,7 +25,7 @@ var warningsPlugin = ActiveBuild.UiPlugin.extend({
queries.push(ActiveBuild.registerQuery(key, -1, {num_builds: 10, key: key}));
}
$(window).on('phpmd-warnings phpcs-warnings phptallint-warnings phptallint-errors phpcs-errors phplint-errors phpunit-errors phpdoccheck-warnings', function(data) {
$(window).on('codeception-errors phpmd-warnings phpcs-warnings phptallint-warnings phptallint-errors phpcs-errors phplint-errors phpunit-errors phpdoccheck-warnings', function(data) {
self.onUpdate(data);
});