mirror of
https://github.com/pestphp/pest.git
synced 2026-03-12 02:37:22 +01:00
adds a new --ci option to pest binary
This commit is contained in:
7
bin/pest
7
bin/pest
@ -31,7 +31,8 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||||||
$rootPath = dirname($autoloadPath, 2);
|
$rootPath = dirname($autoloadPath, 2);
|
||||||
$argv = new ArgvInput();
|
$argv = new ArgvInput();
|
||||||
|
|
||||||
$testSuite = TestSuite::getInstance($rootPath, $argv->getParameterOption('--test-directory', 'tests'));
|
$workingEnv = $argv->hasParameterOption('--ci') ? 'ci' : 'local';
|
||||||
|
$testSuite = TestSuite::getInstance($rootPath, $argv->getParameterOption('--test-directory', 'tests'), $workingEnv);
|
||||||
|
|
||||||
$isDecorated = $argv->getParameterOption('--colors', 'always') !== 'never';
|
$isDecorated = $argv->getParameterOption('--colors', 'always') !== 'never';
|
||||||
$output = new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, $isDecorated);
|
$output = new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, $isDecorated);
|
||||||
@ -45,9 +46,9 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||||||
$args = $_SERVER['argv'];
|
$args = $_SERVER['argv'];
|
||||||
|
|
||||||
// Let's remove any arguments that PHPUnit does not understand
|
// Let's remove any arguments that PHPUnit does not understand
|
||||||
if ($argv->hasParameterOption('--test-directory')) {
|
if ($argv->hasParameterOption(['--test-directory', '--ci'])) {
|
||||||
foreach ($args as $key => $value) {
|
foreach ($args as $key => $value) {
|
||||||
if (strpos($value, '--test-directory') !== false) {
|
if (strpos($value, '--test-directory') !== false || strpos($value, '--ci') !== false) {
|
||||||
unset($args[$key]);
|
unset($args[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -119,6 +119,10 @@ final class TestRepository
|
|||||||
*/
|
*/
|
||||||
private function testsUsingOnly(): array
|
private function testsUsingOnly(): array
|
||||||
{
|
{
|
||||||
|
if (TestSuite::getInstance()->workingEnv === 'ci') {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
return array_filter($this->state, function ($testFactory): bool {
|
return array_filter($this->state, function ($testFactory): bool {
|
||||||
return $testFactory->only;
|
return $testFactory->only;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -73,6 +73,13 @@ final class TestSuite
|
|||||||
*/
|
*/
|
||||||
public $testPath;
|
public $testPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holds the current working environment identifier.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $workingEnv;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds an instance of the test suite.
|
* Holds an instance of the test suite.
|
||||||
*
|
*
|
||||||
@ -98,10 +105,11 @@ final class TestSuite
|
|||||||
/**
|
/**
|
||||||
* Returns the current instance of the test suite.
|
* Returns the current instance of the test suite.
|
||||||
*/
|
*/
|
||||||
public static function getInstance(string $rootPath = null, string $testPath = null): TestSuite
|
public static function getInstance(string $rootPath = null, string $testPath = null, string $workingEnv = null): TestSuite
|
||||||
{
|
{
|
||||||
if (is_string($rootPath) && is_string($testPath)) {
|
if (is_string($rootPath) && is_string($testPath)) {
|
||||||
self::$instance = new TestSuite($rootPath, $testPath);
|
self::$instance = new TestSuite($rootPath, $testPath);
|
||||||
|
self::$instance->workingEnv = $workingEnv;
|
||||||
|
|
||||||
foreach (Plugin::$callables as $callable) {
|
foreach (Plugin::$callables as $callable) {
|
||||||
$callable();
|
$callable();
|
||||||
|
|||||||
Reference in New Issue
Block a user