Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions bridge/symfony-console/src/Command/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,19 @@

/**
* 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();

Check warning on line 136 in bridge/symfony-console/src/Command/Base.php

View check run for this annotation

Codecov / codecov/patch

bridge/symfony-console/src/Command/Base.php#L136

Added line #L136 was not covered by tests

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,

Check warning on line 142 in bridge/symfony-console/src/Command/Base.php

View check run for this annotation

Codecov / codecov/patch

bridge/symfony-console/src/Command/Base.php#L138-L142

Added lines #L138 - L142 were not covered by tests
default => Verbosity::Normal,
};
}
Expand Down
12 changes: 8 additions & 4 deletions bridge/symfony-console/src/Command/Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
6 changes: 4 additions & 2 deletions core/Application/Internal/SuiteLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ public function locate(ApplicationConfig $config): array

/**
* @see SuiteLocatorInterceptor::locateTestSuites()
* @var callable(ApplicationConfig): list<SuiteConfig> $pipeline
* @var callable(ApplicationConfig): array<array-key, SuiteConfig> $pipeline
*/
$pipeline = Pipeline::prepare(
new PipeOptions(includeTypes: $this->filter->type, excludeTypes: $this->filter->notType),
...$interceptors,
)
->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));
}
}
2 changes: 1 addition & 1 deletion skills/testo-run-tests/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
39 changes: 39 additions & 0 deletions tests/Application/Feature/Runner/SuitesLocatedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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);
}
}
Loading