mirror of
https://github.com/pestphp/pest.git
synced 2026-03-07 00:07:22 +01:00
only check for coverage driver if option is present
This commit is contained in:
@ -17,8 +17,8 @@ final class MapArguments
|
||||
{
|
||||
public static function toParatest(TestSuite $testSuite): void
|
||||
{
|
||||
self::coverage();
|
||||
self::registerPlugins();
|
||||
self::coverage();
|
||||
self::parallel();
|
||||
self::color();
|
||||
}
|
||||
@ -26,6 +26,7 @@ final class MapArguments
|
||||
public static function toPest(TestSuite $testSuite): void
|
||||
{
|
||||
self::inParallel($testSuite);
|
||||
// we could add coverage here too, so we stop before even running tests if there is no coverage driver
|
||||
}
|
||||
|
||||
private static function registerPlugins(): void
|
||||
@ -70,7 +71,7 @@ final class MapArguments
|
||||
|
||||
private static function coverage(): void
|
||||
{
|
||||
if (! Coverage::isAvailable()) {
|
||||
if (self::needsCoverage() && ! Coverage::isAvailable()) {
|
||||
Container::getInstance()->get(OutputInterface::class)->writeln(
|
||||
"\n <fg=white;bg=red;options=bold> ERROR </> No code coverage driver is available.</>",
|
||||
);
|
||||
@ -78,6 +79,17 @@ final class MapArguments
|
||||
}
|
||||
}
|
||||
|
||||
private static function needsCoverage(): bool
|
||||
{
|
||||
foreach ($_SERVER['argv'] as $argument) {
|
||||
if(str_starts_with($argument, '--coverage')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function unsetArgument(string $argument): bool
|
||||
{
|
||||
if (($key = array_search($argument, $_SERVER['argv'])) !== false) {
|
||||
|
||||
Reference in New Issue
Block a user