diff --git a/src/Plugins/Tia.php b/src/Plugins/Tia.php index 8741bd38..52b7f06f 100644 --- a/src/Plugins/Tia.php +++ b/src/Plugins/Tia.php @@ -141,6 +141,12 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument '--assignee', '--issue', '--ticket', '--pr', '--pull-request', ]; + /** @var list */ + private const array LISTING_FLAGS = [ + '--list-groups', '--list-suites', '--list-tests', '--list-tests-xml', + '--list-test-files', '--list-test-ids', + ]; + private const array UNSUPPORTED_OPTIONS = [ '--covers', '--uses', '--random-order-seed', ]; @@ -494,7 +500,7 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument $hasExplicitPath = $this->hasExplicitPathArgument($arguments); $partial = ! $isWorker && ($hasExplicitPath || $this->hasPartialSelection($arguments)); - $disabled = $disabled || $partial; + $disabled = $disabled || $partial || $this->hasListingOption($arguments); $mutating = self::isMutationRun($this->originalArguments); @@ -1987,6 +1993,14 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument return false; } + /** + * @param array $arguments + */ + private function hasListingOption(array $arguments): bool + { + return array_any(self::LISTING_FLAGS, fn (string $flag): bool => $this->hasArgument($flag, $arguments)); + } + private function stoppedEarly(): bool { return TestResultFacade::shouldStop(); diff --git a/tests/Features/Tia/FilteredMode.php b/tests/Features/Tia/FilteredMode.php index 01b3f2a7..23da7e7d 100644 --- a/tests/Features/Tia/FilteredMode.php +++ b/tests/Features/Tia/FilteredMode.php @@ -36,6 +36,20 @@ test('an explicit path turns filtered mode off', function (): void { ->and($delta->isResultsOnly())->toBeTrue($delta->summary()); })->skipOnWindows(); +test('--list-tests lists the whole suite in filtered mode', function (): void { + $project = Project::make('master'); + $project->seed('master'); + $project->snapshot(); + + $result = $project->pest('--tia', '--filtered', '--list-tests'); + $delta = $project->delta(); + + expect($result->exitCode)->toBe(0, $result->describe()) + ->and(substr_count($result->output, ' - '))->toBe(Project::TOTAL_TESTS, $result->describe()) + ->and($result->output)->not->toContain('No affected tests found') + ->and($delta->writtenCount())->toBe(0, $delta->summary()); +})->skipOnWindows(); + test('filtered mode runs the whole suite when there is no baseline', function (): void { $project = Project::make('master');