diff --git a/bridge/symfony-console/src/Command/Base.php b/bridge/symfony-console/src/Command/Base.php index 55eeccaf..56025a6f 100644 --- a/bridge/symfony-console/src/Command/Base.php +++ b/bridge/symfony-console/src/Command/Base.php @@ -127,14 +127,19 @@ protected function getConfigFile(InputInterface $input): ?Path /** * Maps Symfony's console verbosity onto the framework's {@see Verbosity} level. + * + * Symfony 7.2+ adds `--silent` below `--quiet`; it is compared by value because the constant does + * not exist in the older versions this bridge supports. */ private static function resolveVerbosity(OutputInterface $output): Verbosity { - return match ($output->getVerbosity()) { - OutputInterface::VERBOSITY_QUIET => Verbosity::Quiet, - OutputInterface::VERBOSITY_VERBOSE => Verbosity::Verbose, - OutputInterface::VERBOSITY_VERY_VERBOSE => Verbosity::VeryVerbose, - OutputInterface::VERBOSITY_DEBUG => Verbosity::Debug, + $verbosity = $output->getVerbosity(); + + return match (true) { + $verbosity <= OutputInterface::VERBOSITY_QUIET => Verbosity::Quiet, + $verbosity === OutputInterface::VERBOSITY_VERBOSE => Verbosity::Verbose, + $verbosity === OutputInterface::VERBOSITY_VERY_VERBOSE => Verbosity::VeryVerbose, + $verbosity === OutputInterface::VERBOSITY_DEBUG => Verbosity::Debug, default => Verbosity::Normal, }; } diff --git a/bridge/symfony-console/src/Command/Init.php b/bridge/symfony-console/src/Command/Init.php index 1798aa1c..ebf63410 100644 --- a/bridge/symfony-console/src/Command/Init.php +++ b/bridge/symfony-console/src/Command/Init.php @@ -149,13 +149,17 @@ private static function discoverSourceDirectory( } /** - * Program status goes where the prompts are drawn, and only when they are drawn for a person: a quiet - * or undecorated run gets none. The prompts go through {@see SymfonyStyle}, which the question helper - * does not treat as a console output, so they are drawn on stdout rather than on the error output. + * Program status goes where the prompts are drawn, and only when they are drawn for a person: a quiet, + * silent or undecorated run gets none. The prompts go through {@see SymfonyStyle}, which the question + * helper does not treat as a console output, so they are drawn on stdout rather than on the error output. + * Verbosity is compared by value: `--silent` (Symfony 7.2+) sits below `--quiet`, and `isQuiet()` + * matches only the latter. */ private static function programStatus(OutputInterface $output): ProgramStatus { - return $output instanceof StreamOutput && $output->isDecorated() && !$output->isQuiet() + return $output instanceof StreamOutput + && $output->isDecorated() + && $output->getVerbosity() > OutputInterface::VERBOSITY_QUIET ? ProgramStatus::detect($output->getStream()) : ProgramStatus::disabled(); } diff --git a/core/Application/Internal/SuiteLocator.php b/core/Application/Internal/SuiteLocator.php index 56ce9298..16f38028 100644 --- a/core/Application/Internal/SuiteLocator.php +++ b/core/Application/Internal/SuiteLocator.php @@ -34,7 +34,7 @@ public function locate(ApplicationConfig $config): array /** * @see SuiteLocatorInterceptor::locateTestSuites() - * @var callable(ApplicationConfig): list $pipeline + * @var callable(ApplicationConfig): array $pipeline */ $pipeline = Pipeline::prepare( new PipeOptions(includeTypes: $this->filter->type, excludeTypes: $this->filter->notType), @@ -42,6 +42,8 @@ public function locate(ApplicationConfig $config): array ) ->with(static fn(ApplicationConfig $config): array => $config->suites, 'locateTestSuites'); - return $pipeline($config); + # An interceptor that filters with `array_filter()` hands back a keyed array; consumers count + # positions in this list, so the keys are dropped here once for all of them. + return \array_values($pipeline($config)); } } diff --git a/skills/testo-run-tests/SKILL.md b/skills/testo-run-tests/SKILL.md index 2d1ce1bd..7d6a91d1 100644 --- a/skills/testo-run-tests/SKILL.md +++ b/skills/testo-run-tests/SKILL.md @@ -117,7 +117,7 @@ over-narrow filter — widen it (a typo in `--filter`, a `--path` that matches n - `--config=path/to/testo.php` when the config is not at the project root. - In an interactive terminal the default renderer also reports the run's progress and outcome to the terminal itself (OSC 7501 program status, shown in the tab by terminals that support it). It is off - for `--json`, `--teamcity`, `--quiet`, `--no-ansi`, `NO_COLOR` and redirected output; set + for `--json`, `--teamcity`, `--quiet`, `--silent`, `--no-ansi`, `NO_COLOR` and redirected output; set `TESTO_TERMINAL_STATUS=0` to turn it off everywhere. A Composer script (`composer test`) on Windows counts as redirected output: Composer pipes it, so run `vendor/bin/testo` directly to see the status. - Full flag list: `vendor/bin/testo --help`. diff --git a/tests/Application/Feature/Runner/SuitesLocatedTest.php b/tests/Application/Feature/Runner/SuitesLocatedTest.php index b867fabb..dd249126 100644 --- a/tests/Application/Feature/Runner/SuitesLocatedTest.php +++ b/tests/Application/Feature/Runner/SuitesLocatedTest.php @@ -15,6 +15,8 @@ use Testo\Common\PluginConfigurator; use Testo\Event\TestSuite\TestSuitesLocated; use Testo\Event\TestSuite\TestSuiteStarting; +use Testo\Pipeline\InterceptorProvider; +use Testo\Pipeline\Middleware\SuiteLocatorInterceptor; use Testo\Test; /** @@ -58,4 +60,41 @@ public function configure(Container $container): void Assert::same($events, ['located: Empty, Runner', 'starting: Runner']); } + + public function suitesFilteredIntoAKeyedArrayAreAnnouncedAsAList(): void + { + $located = null; + $plugin = new class($located) implements PluginConfigurator { + public function __construct(private ?array &$located) {} + + #[\Override] + public function configure(Container $container): void + { + $container->get(InterceptorProvider::class)->addInterceptor(new class implements SuiteLocatorInterceptor { + #[\Override] + public function locateTestSuites(ApplicationConfig $config, callable $next): array + { + // Keeps the key of the surviving suite, as `array_filter()` does. + return \array_filter($next($config), static fn(SuiteConfig $suite): bool => $suite->name === 'Runner'); + } + }); + $container->get(EventListenerCollector::class)->addListener( + TestSuitesLocated::class, + function (TestSuitesLocated $event): void { + $this->located = $event->suites; + }, + ); + } + }; + + Application::createFromConfig(new ApplicationConfig( + src: [], + suites: [ + new SuiteConfig('Empty', location: new FinderConfig(include: [__DIR__ . '/../../Stub/EmptyRun'])), + new SuiteConfig('Runner', location: new FinderConfig(include: [__DIR__ . '/../../Stub/Runner'])), + ], + ))->run($plugin); + + Assert::array($located)->isList()->hasCount(1); + } }