-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from ElvenSpellmaker/feature/run-x-times
Implements the ability to run `x` times.
- Loading branch information
Showing
8 changed files
with
94 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
/** | ||
* @title Basic example to show grepping. | ||
|
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
/** | ||
* @title Example to show large head into smaller head. | ||
|
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
/** | ||
* @title Example to show small head into larger head. | ||
|
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
/** | ||
* @title Basic example to show that `head` terminates `yes`. | ||
|
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,56 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
/** | ||
* @title Tests two infintie commands sandwiched by a terminating command. | ||
* @command yes | head | yes | ||
* @expected y\ny\ny\ny\ny\ny\ny\ny\ny\ny\n | ||
*/ | ||
|
||
error_reporting(E_ALL); | ||
|
||
include __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use ElvenSpellmaker\PipeSys as PS; | ||
use ElvenSpellmaker\PipeSys\Command as Command; | ||
|
||
$c = new PS\Scheduler(new Command\StandardConnector); | ||
$c->addCommand(new Command\Yes); | ||
$c->addCommand(new Command\Head(1)); | ||
$c->addCommand(new Command\Yes); | ||
|
||
$output = ''; | ||
|
||
if ($count = count($c->run(3)) !== 3) | ||
{ | ||
$output .= "Expecting 3 elements, received $count\n"; | ||
} | ||
|
||
$expected = [ | ||
0 => 'ElvenSpellmaker\PipeSys\Command\Yes', | ||
2 => 'ElvenSpellmaker\PipeSys\Command\Yes', | ||
]; | ||
$received = array_map('get_class', $c->run(1)); | ||
|
||
if ($received !== $expected) | ||
{ | ||
echo '<pre>'; | ||
var_dump($expected, $received); | ||
exit; | ||
|
||
$output .= "Expecting the head to be missing!\n"; | ||
} | ||
|
||
$expected = [2 => 'ElvenSpellmaker\PipeSys\Command\Yes']; | ||
$received = array_map('get_class', $c->run(1)); | ||
|
||
if ($received !== $expected) | ||
{ | ||
$output .= "Expecting the last yes to be present only!\n"; | ||
} | ||
|
||
if (! count($c->run(5))) | ||
{ | ||
$output .= "Command has terminated sometime before 10 runs!\n"; | ||
} | ||
|
||
echo $output; |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
/** | ||
* @title Tests two infinite commands and a terminating command. | ||
|
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
Empty file.