Author: Stuart Herbert (stuart.herbert@datasift.com)
Ejemplo n.º 1
0
 public function play(StoryTeller $st, Injectables $injectables)
 {
     // shorthand
     $output = $st->getOutput();
     // we're building / destroying a test environment
     $activity = 'Creating test environment';
     $testEnv = new TestEnvironment($injectables->activeTestEnvironmentName);
     // we're using this to build / destroy our test environment
     $phasesPlayer = new PhaseGroup_Player();
     // announce what we're doing
     $output->startPhaseGroup($activity, $injectables->activeTestEnvironmentName);
     // run the startup phase
     $phasesPlayer->playPhases($activity, $st, $injectables, $this->startupPhases, $testEnv);
     $creationResult = $testEnv->getResult();
     $output->endPhaseGroup($creationResult);
     // what happened?
     if (!$creationResult->getPhaseGroupSucceeded() && !$creationResult->getPhaseGroupSkipped()) {
         $output->logCliError("failed to create test environment - cannot continue");
         exit(1);
     }
     // now we need to play whatever runs against this
     // test environment
     foreach ($this->wrappedPlayers as $wrappedPlayer) {
         // play the wrapped item
         //
         // this is normally a story
         $wrappedPlayer->play($st, $injectables);
     }
     // announce what we're doing
     $activity = 'Destroying test environment';
     $output->startPhaseGroup($activity, $injectables->activeTestEnvironmentName);
     // run the shutdown phase
     $testEnv->resetResult();
     $phasesPlayer->playPhases($activity, $st, $injectables, $this->shutdownPhases, $testEnv);
     $output->endPhaseGroup($testEnv->getResult());
     // all done
 }
Ejemplo n.º 2
0
 /**
  *
  * @param  integer $signo
  * @return void
  */
 public function sigtermHandler($signo)
 {
     // tell the user what is happening
     echo PHP_EOL;
     echo "============================================================" . PHP_EOL;
     echo "USER ABORT!!" . PHP_EOL;
     // do we skip destroying the test environment?
     if ($this->st->getPersistTestEnvironment()) {
         echo PHP_EOL . "* Warning: NOT destroying test environment" . PHP_EOL . "           --reuse-target flag is set" . PHP_EOL;
     }
     // cleanup
     echo PHP_EOL . "Cleaning up: ";
     $phasesPlayer = new PhaseGroup_Player();
     $phasesPlayer->playPhases("user abort", $this->st, $this->injectables, $this->injectables->activeConfig->getData('storyplayer.phases.userAbort'), null);
     echo " done" . PHP_EOL . "============================================================" . PHP_EOL . PHP_EOL;
     // force a clean shutdown
     exit(1);
 }
Ejemplo n.º 3
0
 public function play(StoryTeller $st, Injectables $injectables)
 {
     // shorthand
     $output = $st->getOutput();
     // we're going to use this to play our setup and teardown phases
     $phasesPlayer = new PhaseGroup_Player();
     // load our story
     $story = Story_Loader::loadStory($this->storyFilename);
     $st->setStory($story);
     // does our story want to keep the test device open between
     // phases?
     if ($story->getPersistDevice()) {
         $st->setPersistDevice();
     }
     // set default callbacks up
     $story->setDefaultCallbacks();
     // make sure we start with a brand new checkpoint
     $st->setCheckpoint(new Story_Checkpoint($st));
     // tell the outside world what we're doing
     $activity = "Running story";
     $name = $story->getCategory() . ' > ' . $story->getGroupAsString() . ' > ' . $story->getName();
     $output->startPhaseGroup($activity, $name);
     // run the phases before the story truly starts
     $phasesPlayer->playPhases($activity, $st, $injectables, $this->startupPhases, $story);
     // what happened?
     $result = $story->getResult();
     if (!$result->getPhaseGroupSucceeded()) {
         // make sure the result has the story's filename in
         $result->filename = $this->storyFilename;
         // announce the results
         $output->endPhaseGroup($result);
         // all done
         return;
     }
     // run the phases in the 'story' section
     $phasesPlayer->playPhases($activity, $st, $injectables, $this->storyPhases, $story);
     // grab the result at this point
     $result = clone $story->getResult();
     // run the shutdown phase
     $phasesPlayer->playPhases($activity, $st, $injectables, $this->shutdownPhases, $story);
     // do we also need to look at any failures that happened during
     // the shutdown phase?
     if ($result->getPhaseGroupSucceeded()) {
         $result = $story->getResult();
     }
     // make sure the result has the story's filename in
     $result->filename = $this->storyFilename;
     // announce the results
     $output->endPhaseGroup($result);
     // all done
 }
Ejemplo n.º 4
0
 public function play(StoryTeller $st, Injectables $injectables)
 {
     // we are playing this script
     $script = new Script($this->scriptFilename);
     // we're going to use this to play our setup and teardown phases
     $phasesPlayer = new PhaseGroup_Player();
     // run the phases
     $phasesPlayer->playPhases("Running script", $st, $injectables, $this->scriptPhases, $script);
     // all done
 }
Ejemplo n.º 5
0
 /**
  *
  * @param  integer $signo
  * @return void
  */
 public function sigtermHandler($signo)
 {
     // tell the user what is happening
     echo "\n";
     echo "============================================================\n";
     echo "USER ABORT!!\n";
     echo "============================================================\n";
     echo "\n";
     // cleanup
     $phasesPlayer = new PhaseGroup_Player();
     $phasesPlayer->playPhases("user abort", $this->st, $this->injectables, $this->injectables->activeConfig->getData('storyplayer.phases.userAbort'), null);
     // force a clean shutdown
     exit(1);
 }