-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add $stopAllOnAnyFailure flag to \Robo\Task\Base\ParallelExec
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
namespace Robo; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Robo\Task\Base\Exec; | ||
use Robo\Task\Base\ParallelExec; | ||
use Robo\Traits\TestTasksTrait; | ||
|
||
class StopAllOnAnyFailureTest extends TestCase | ||
{ | ||
use TestTasksTrait; | ||
use Task\File\loadTasks; | ||
|
||
protected $fixtures; | ||
|
||
public function setUp() | ||
{ | ||
$this->fixtures = new Fixtures(); | ||
$this->initTestTasksTrait(); | ||
} | ||
|
||
public function tearDown() | ||
{ | ||
$this->fixtures->cleanup(); | ||
} | ||
|
||
public function testParallelProcessesGetStoppedIfStopAllOnAnyFailureIsSet() | ||
{ | ||
// Some tests may left this to true | ||
Result::$stopOnFail = false; | ||
$this->fixtures->createAndCdToSandbox(); | ||
|
||
$filenameOk = uniqid('ok_'); | ||
$filenameKo = uniqid('ko_'); | ||
|
||
/** @var ParallelExec $parallel */ | ||
$parallel = $this->task(ParallelExec::class); | ||
$parallel->stopAllOnAnyFailure(true); | ||
$parallel->process($this->task(Exec::class, sprintf('touch %s && false', escapeshellarg($filenameOk)))); | ||
$parallel->process($this->task(Exec::class, sprintf('sleep 3 && touch %s', escapeshellarg($filenameKo)))); | ||
$parallel->run(); | ||
|
||
$this->assertFileExists($filenameOk); | ||
$this->assertFileNotExists($filenameKo); | ||
} | ||
} |