mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Fixes ignorable tests
This commit is contained in:
@ -4,13 +4,24 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Pest;
|
namespace Pest;
|
||||||
|
|
||||||
|
use PHPUnit\TestRunner\TestResult\Facade;
|
||||||
|
use PHPUnit\TestRunner\TestResult\TestResult;
|
||||||
use PHPUnit\TextUI\Application;
|
use PHPUnit\TextUI\Application;
|
||||||
|
use PHPUnit\TextUI\Configuration\Registry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class Kernel
|
final class Kernel
|
||||||
{
|
{
|
||||||
|
private const SUCCESS_EXIT = 0;
|
||||||
|
|
||||||
|
private const FAILURE_EXIT = 1;
|
||||||
|
|
||||||
|
private const EXCEPTION_EXIT = 2;
|
||||||
|
|
||||||
|
private const CRASH_EXIT = 255;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Kernel bootstrappers.
|
* The Kernel bootstrappers.
|
||||||
*
|
*
|
||||||
@ -53,11 +64,15 @@ final class Kernel
|
|||||||
{
|
{
|
||||||
$argv = (new Plugins\Actions\HandleArguments())->__invoke($argv);
|
$argv = (new Plugins\Actions\HandleArguments())->__invoke($argv);
|
||||||
|
|
||||||
$result = $this->application->run(
|
$this->application->run(
|
||||||
$argv, false,
|
$argv, false,
|
||||||
);
|
);
|
||||||
|
|
||||||
return (new Plugins\Actions\AddsOutput())->__invoke($result);
|
$returnCode = $this->returnCode();
|
||||||
|
|
||||||
|
return (new Plugins\Actions\AddsOutput())->__invoke(
|
||||||
|
$returnCode,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,4 +82,55 @@ final class Kernel
|
|||||||
{
|
{
|
||||||
// ..
|
// ..
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the exit code, based on the facade's result.
|
||||||
|
*/
|
||||||
|
private function returnCode(): int
|
||||||
|
{
|
||||||
|
$result = Facade::result();
|
||||||
|
|
||||||
|
$returnCode = self::FAILURE_EXIT;
|
||||||
|
|
||||||
|
if ($result->wasSuccessfulIgnoringPhpunitWarnings()
|
||||||
|
&& ! $result->hasTestTriggeredPhpunitWarningEvents()) {
|
||||||
|
$returnCode = self::SUCCESS_EXIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
$configuration = Registry::get();
|
||||||
|
|
||||||
|
if ($configuration->failOnEmptyTestSuite() && $result->numberOfTests() === 0) {
|
||||||
|
$returnCode = self::FAILURE_EXIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($result->wasSuccessfulIgnoringPhpunitWarnings()) {
|
||||||
|
if ($configuration->failOnRisky() && $result->hasTestConsideredRiskyEvents()) {
|
||||||
|
$returnCode = self::FAILURE_EXIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
$warnings = $result->numberOfTestsWithTestTriggeredPhpunitWarningEvents()
|
||||||
|
+ $result->numberOfTestsWithTestTriggeredWarningEvents()
|
||||||
|
+ $result->numberOfTestsWithTestTriggeredPhpWarningEvents();
|
||||||
|
|
||||||
|
if ($configuration->failOnWarning() && ! empty($warnings)) {
|
||||||
|
$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()) {
|
||||||
|
$returnCode = self::EXCEPTION_EXIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $returnCode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,13 +9,7 @@ use PHPUnit\Framework\TestCase;
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class IgnorableTest extends TestCase
|
class IgnorableTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Creates a dummy assertion.
|
|
||||||
*/
|
|
||||||
public function testIgnorable(): void
|
|
||||||
{
|
|
||||||
self::assertTrue(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -692,9 +692,6 @@
|
|||||||
✓ custom traits can be used
|
✓ custom traits can be used
|
||||||
✓ trait applied in this file
|
✓ trait applied in this file
|
||||||
|
|
||||||
WARN Tests\Playground
|
|
||||||
! basic → This test did not perform any assertions
|
|
||||||
|
|
||||||
PASS Tests\Plugins\Traits
|
PASS Tests\Plugins\Traits
|
||||||
✓ it allows global uses
|
✓ it allows global uses
|
||||||
✓ it allows multiple global uses registered in the same path
|
✓ it allows multiple global uses registered in the same path
|
||||||
@ -770,5 +767,5 @@
|
|||||||
WARN Tests\Visual\TeamCity
|
WARN Tests\Visual\TeamCity
|
||||||
- it is can successfully call all public methods → Not supported yet.
|
- it is can successfully call all public methods → Not supported yet.
|
||||||
|
|
||||||
Tests: 1 risky, 4 incompleted, 18 skipped, 514 passed
|
Tests: 4 incompleted, 18 skipped, 514 passed
|
||||||
|
|
||||||
2
tests/PHPUnit/IgnorableTest.php
Normal file
2
tests/PHPUnit/IgnorableTest.php
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
Reference in New Issue
Block a user