|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / a / home / dev2.destoffenstraat.com / vendor / codeception / codeception / ext / |
Filename | /home/a/home/dev2.destoffenstraat.com/vendor/codeception/codeception/ext/RunFailed.php |
Size | 2.39 kb |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 21-Aug-2025 12:26 |
Last modified | 13-Mar-2022 18:07 |
Last accessed | 11-Aug-2025 04:27 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
namespace Codeception\Extension;
use Codeception\Event\PrintResultEvent;
use Codeception\Events;
use Codeception\Extension;
use Codeception\Test\Descriptor;
/**
* Saves failed tests into tests/_output/failed in order to rerun failed tests.
*
* To rerun failed tests just run the `failed` group:
*
* ```
* php codecept run -g failed
* ```
*
* To change failed group name add:
* ```
* --override "extensions: config: Codeception\Extension\RunFailed: fail-group: another_group1"
* ```
* Remember: if you run tests and they generated custom-named fail group, to run this group, you should add override too
*
* Starting from Codeception 2.1 **this extension is enabled by default**.
*
* ``` yaml
* extensions:
* enabled: [Codeception\Extension\RunFailed]
* ```
*
* On each execution failed tests are logged and saved into `tests/_output/failed` file.
*/
class RunFailed extends Extension
{
public static $events = [
Events::RESULT_PRINT_AFTER => 'saveFailed'
];
/** @var string filename/groupname for failed tests */
protected $group = 'failed';
public function _initialize()
{
if (array_key_exists('fail-group', $this->config) && $this->config['fail-group']) {
$this->group = $this->config['fail-group'];
}
$logPath = str_replace($this->getRootDir(), '', $this->getLogDir()); // get local path to logs
$this->_reconfigure(['groups' => [$this->group => $logPath . $this->group]]);
}
public function saveFailed(PrintResultEvent $e)
{
$file = $this->getLogDir() . $this->group;
$result = $e->getResult();
if ($result->wasSuccessful()) {
if (is_file($file)) {
unlink($file);
}
return;
}
$output = [];
foreach ($result->failures() as $fail) {
$output[] = $this->localizePath(Descriptor::getTestFullName($fail->failedTest()));
}
foreach ($result->errors() as $fail) {
$output[] = $this->localizePath(Descriptor::getTestFullName($fail->failedTest()));
}
file_put_contents($file, implode("\n", $output));
}
protected function localizePath($path)
{
$root = realpath($this->getRootDir()) . DIRECTORY_SEPARATOR;
if (substr($path, 0, strlen($root)) == $root) {
return substr($path, strlen($root));
}
return $path;
}
}
namespace Codeception\Extension;
use Codeception\Event\PrintResultEvent;
use Codeception\Events;
use Codeception\Extension;
use Codeception\Test\Descriptor;
/**
* Saves failed tests into tests/_output/failed in order to rerun failed tests.
*
* To rerun failed tests just run the `failed` group:
*
* ```
* php codecept run -g failed
* ```
*
* To change failed group name add:
* ```
* --override "extensions: config: Codeception\Extension\RunFailed: fail-group: another_group1"
* ```
* Remember: if you run tests and they generated custom-named fail group, to run this group, you should add override too
*
* Starting from Codeception 2.1 **this extension is enabled by default**.
*
* ``` yaml
* extensions:
* enabled: [Codeception\Extension\RunFailed]
* ```
*
* On each execution failed tests are logged and saved into `tests/_output/failed` file.
*/
class RunFailed extends Extension
{
public static $events = [
Events::RESULT_PRINT_AFTER => 'saveFailed'
];
/** @var string filename/groupname for failed tests */
protected $group = 'failed';
public function _initialize()
{
if (array_key_exists('fail-group', $this->config) && $this->config['fail-group']) {
$this->group = $this->config['fail-group'];
}
$logPath = str_replace($this->getRootDir(), '', $this->getLogDir()); // get local path to logs
$this->_reconfigure(['groups' => [$this->group => $logPath . $this->group]]);
}
public function saveFailed(PrintResultEvent $e)
{
$file = $this->getLogDir() . $this->group;
$result = $e->getResult();
if ($result->wasSuccessful()) {
if (is_file($file)) {
unlink($file);
}
return;
}
$output = [];
foreach ($result->failures() as $fail) {
$output[] = $this->localizePath(Descriptor::getTestFullName($fail->failedTest()));
}
foreach ($result->errors() as $fail) {
$output[] = $this->localizePath(Descriptor::getTestFullName($fail->failedTest()));
}
file_put_contents($file, implode("\n", $output));
}
protected function localizePath($path)
{
$root = realpath($this->getRootDir()) . DIRECTORY_SEPARATOR;
if (substr($path, 0, strlen($root)) == $root) {
return substr($path, strlen($root));
}
return $path;
}
}