fix: --cache-directory being used on phpunit file

This commit is contained in:
Nuno Maduro
2024-01-25 17:56:24 +00:00
parent 7a46514df8
commit a5bf6a3fcb
2 changed files with 17 additions and 2 deletions

View File

@ -6,6 +6,10 @@ namespace Pest\Plugins;
use Pest\Contracts\Plugins\HandlesArguments; use Pest\Contracts\Plugins\HandlesArguments;
use Pest\Plugins\Concerns\HandleArguments; use Pest\Plugins\Concerns\HandleArguments;
use PHPUnit\TextUI\CliArguments\Builder as CliConfigurationBuilder;
use PHPUnit\TextUI\CliArguments\XmlConfigurationFileFinder;
use PHPUnit\TextUI\XmlConfiguration\DefaultConfiguration;
use PHPUnit\TextUI\XmlConfiguration\Loader;
/** /**
* @internal * @internal
@ -31,10 +35,20 @@ final class Cache implements HandlesArguments
public function handleArguments(array $arguments): array public function handleArguments(array $arguments): array
{ {
if (! $this->hasArgument('--cache-directory', $arguments)) { if (! $this->hasArgument('--cache-directory', $arguments)) {
$arguments = $this->pushArgument('--cache-directory', $arguments);
$cliConfiguration = (new CliConfigurationBuilder)->fromParameters([]);
$configurationFile = (new XmlConfigurationFileFinder)->find($cliConfiguration);
$xmlConfiguration = DefaultConfiguration::create();
if ($configurationFile) {
$xmlConfiguration = (new Loader)->load($configurationFile);
}
if (! $xmlConfiguration->phpunit()->hasCacheDirectory()) {
$arguments = $this->pushArgument('--cache-directory', $arguments);
$arguments = $this->pushArgument((string) realpath(self::TEMPORARY_FOLDER), $arguments); $arguments = $this->pushArgument((string) realpath(self::TEMPORARY_FOLDER), $arguments);
} }
}
if (! $this->hasArgument('--parallel', $arguments)) { if (! $this->hasArgument('--parallel', $arguments)) {
return $this->pushArgument('--cache-result', $arguments); return $this->pushArgument('--cache-result', $arguments);

View File

@ -0,0 +1 @@
{"version":"pest_2.32.2","defects":[],"times":{"P\\Tests\\Playground::__pest_evaluable_basic":0.005}}