only check for coverage driver if option is present

This commit is contained in:
Adrian Nürnberger
2021-08-06 15:48:38 +02:00
parent c86058fed1
commit 0b5321fdd7

View File

@ -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) {