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
20 changes: 20 additions & 0 deletions src/Illuminate/Process/ProcessPoolResults.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ public function __construct(array $results)
$this->results = $results;
}

/**
* Determine if all of the processes in the pool were successful.
*
* @return bool
*/
public function successful()
{
return $this->collect()->every(fn ($p) => $p->successful());
}

/**
* Determine if any of the processes in the pool failed.
*
* @return bool
*/
public function failed()
{
return ! $this->successful();
}

/**
* Get the results as a collection.
*
Expand Down
25 changes: 25 additions & 0 deletions tests/Process/ProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,31 @@ public function testProcessPool()

$this->assertTrue(str_contains($results[0]->output(), 'ProcessTest.php'));
$this->assertTrue(str_contains($results[1]->output(), 'ProcessTest.php'));

$this->assertTrue($results->successful());
}

public function testProcessPoolFailed()
{
$factory = new Factory;

$factory->fake([
'cat *' => $factory->result(exitCode: 1),
]);

$pool = $factory->pool(function ($pool) {
return [
$pool->path(__DIR__)->command($this->ls()),
$pool->path(__DIR__)->command('cat test'),
];
});

$results = $pool->start()->wait();

$this->assertTrue($results[0]->successful());
$this->assertTrue($results[1]->failed());

$this->assertTrue($results->failed());
}

public function testInvokedProcessPoolCount()
Expand Down