mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
fix: wrong status code being used
This commit is contained in:
@ -4,9 +4,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Pest;
|
namespace Pest;
|
||||||
|
|
||||||
use NunoMaduro\Collision\Adapters\Phpunit\Support\ResultReflection;
|
|
||||||
use PHPUnit\TestRunner\TestResult\TestResult;
|
use PHPUnit\TestRunner\TestResult\TestResult;
|
||||||
use PHPUnit\TextUI\Configuration\Configuration;
|
use PHPUnit\TextUI\Configuration\Configuration;
|
||||||
|
use PHPUnit\TextUI\ShellExitCodeCalculator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@ -15,10 +15,6 @@ final class Result
|
|||||||
{
|
{
|
||||||
private const int SUCCESS_EXIT = 0;
|
private const int SUCCESS_EXIT = 0;
|
||||||
|
|
||||||
private const int FAILURE_EXIT = 1;
|
|
||||||
|
|
||||||
private const int EXCEPTION_EXIT = 2;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the exit code is different from 0.
|
* If the exit code is different from 0.
|
||||||
*/
|
*/
|
||||||
@ -40,44 +36,8 @@ final class Result
|
|||||||
*/
|
*/
|
||||||
public static function exitCode(Configuration $configuration, TestResult $result): int
|
public static function exitCode(Configuration $configuration, TestResult $result): int
|
||||||
{
|
{
|
||||||
if ($result->wasSuccessful()) {
|
$shell = new ShellExitCodeCalculator;
|
||||||
if ($configuration->failOnWarning()) {
|
|
||||||
$warnings = $result->numberOfTestsWithTestTriggeredPhpunitWarningEvents()
|
|
||||||
+ count($result->warnings())
|
|
||||||
+ count($result->phpWarnings());
|
|
||||||
|
|
||||||
if ($warnings > 0) {
|
return $shell->calculate($configuration, $result);
|
||||||
return self::FAILURE_EXIT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $result->hasTestTriggeredPhpunitWarningEvents()) {
|
|
||||||
return self::SUCCESS_EXIT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($configuration->failOnEmptyTestSuite() && ResultReflection::numberOfTests($result) === 0) {
|
|
||||||
return self::FAILURE_EXIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($result->wasSuccessful()) {
|
|
||||||
if ($configuration->failOnRisky() && $result->hasTestConsideredRiskyEvents()) {
|
|
||||||
$returnCode = self::FAILURE_EXIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($configuration->failOnIncomplete() && $result->hasTestMarkedIncompleteEvents()) {
|
|
||||||
$returnCode = self::FAILURE_EXIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($configuration->failOnSkipped() && $result->hasTestSkippedEvents()) {
|
|
||||||
$returnCode = self::FAILURE_EXIT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($result->hasTestErroredEvents()) {
|
|
||||||
return self::EXCEPTION_EXIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::FAILURE_EXIT;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,7 +35,7 @@ final class EnsureIgnorableTestCasesAreIgnored implements StartedSubscriber
|
|||||||
/** @var array<int, WarningTriggered> $testRunnerTriggeredWarningEvents */
|
/** @var array<int, WarningTriggered> $testRunnerTriggeredWarningEvents */
|
||||||
$testRunnerTriggeredWarningEvents = $property->getValue($collector);
|
$testRunnerTriggeredWarningEvents = $property->getValue($collector);
|
||||||
|
|
||||||
$testRunnerTriggeredWarningEvents = array_values(array_filter($testRunnerTriggeredWarningEvents, fn (WarningTriggered $event): bool => $event->message() !== 'No tests found in class "Pest\TestCases\IgnorableTestCase".'));
|
$testRunnerTriggeredWarningEvents = array_values(array_filter($testRunnerTriggeredWarningEvents, fn (WarningTriggered $event): bool => str_contains($event->message(), 'No tests found in class') === false));
|
||||||
|
|
||||||
$property->setValue($collector, $testRunnerTriggeredWarningEvents);
|
$property->setValue($collector, $testRunnerTriggeredWarningEvents);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user