mirror of
https://github.com/pestphp/pest.git
synced 2026-04-21 14:37:29 +02:00
fix: updating snapshots in --parallel
This commit is contained in:
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||||||
namespace Pest\Plugins;
|
namespace Pest\Plugins;
|
||||||
|
|
||||||
use Pest\Contracts\Plugins\HandlesArguments;
|
use Pest\Contracts\Plugins\HandlesArguments;
|
||||||
use Pest\Exceptions\InvalidOption;
|
|
||||||
use Pest\TestSuite;
|
use Pest\TestSuite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,12 +19,12 @@ final class Snapshot implements HandlesArguments
|
|||||||
*/
|
*/
|
||||||
public function handleArguments(array $arguments): array
|
public function handleArguments(array $arguments): array
|
||||||
{
|
{
|
||||||
if (! $this->hasArgument('--update-snapshots', $arguments)) {
|
if (Parallel::isWorker()) {
|
||||||
return $arguments;
|
return $arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->hasArgument('--parallel', $arguments)) {
|
if (! $this->hasArgument('--update-snapshots', $arguments)) {
|
||||||
throw new InvalidOption('The [--update-snapshots] option is not supported when running in parallel.');
|
return $arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
TestSuite::getInstance()->snapshots->flush();
|
TestSuite::getInstance()->snapshots->flush();
|
||||||
|
|||||||
@ -59,8 +59,10 @@ final class SnapshotRepository
|
|||||||
{
|
{
|
||||||
$snapshotFilename = $this->getSnapshotFilename();
|
$snapshotFilename = $this->getSnapshotFilename();
|
||||||
|
|
||||||
if (! file_exists(dirname($snapshotFilename))) {
|
$directory = dirname($snapshotFilename);
|
||||||
mkdir(dirname($snapshotFilename), 0755, true);
|
|
||||||
|
if (! is_dir($directory)) {
|
||||||
|
@mkdir($directory, 0755, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents($snapshotFilename, $snapshot);
|
file_put_contents($snapshotFilename, $snapshot);
|
||||||
|
|||||||
Reference in New Issue
Block a user