Adds initial implementation of --dirty option.

This commit is contained in:
Luke Downing
2022-12-05 08:59:42 +00:00
parent d77715b0fe
commit d29d68a2c2
5 changed files with 109 additions and 29 deletions

View File

@ -3,8 +3,10 @@
use Pest\Actions\ValidatesEnvironment;
use Pest\ConfigLoader;
use Pest\Repositories\TestRepository;
use Pest\Support\Container;
use Pest\Kernel;
use Pest\Support\DirtyTestCaseFilter;
use Pest\TestSuite;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
@ -44,9 +46,18 @@ use Symfony\Component\Console\Output\OutputInterface;
$rootPath = dirname($autoloadPath, 2);
$argv = new ArgvInput();
$filters = [];
foreach ($args as $key => $value) {
if (str_contains($value, '--dirty')) {
$filters[] = new DirtyTestCaseFilter($rootPath);
}
}
$testSuite = TestSuite::getInstance(
$rootPath,
$argv->getParameterOption('--test-directory', (new ConfigLoader($rootPath))->getTestsDirectory())
$argv->getParameterOption('--test-directory', (new ConfigLoader($rootPath))->getTestsDirectory()),
new TestRepository($filters),
);
$isDecorated = $argv->getParameterOption('--colors', 'always') !== 'never';
@ -57,16 +68,10 @@ use Symfony\Component\Console\Output\OutputInterface;
$container->add(TestSuite::class, $testSuite);
$container->add(OutputInterface::class, $output);
$argsToUnset = ['--test-directory', '--compact', '--profile', '--dirty'];
foreach ($args as $key => $value) {
if (str_contains($value, '--test-directory')) {
unset($args[$key]);
}
if (str_contains($value, '--compact')) {
unset($args[$key]);
}
if (str_contains($value, '--profile')) {
if (in_array($value, $argsToUnset)) {
unset($args[$key]);
}
}