Пример #1
0
 public function testStopOnFail()
 {
     $exceptionClass = false;
     $task = new ResultDummyTask();
     Result::$stopOnFail = true;
     $result = Result::success($task, "Something that worked");
     try {
         $result = Result::error($task, "Something that did not work");
         // stopOnFail will cause Result::error() to throw an exception,
         // so we will never get here. If we did, the assert below would fail.
         $this->assertTrue($result->wasSuccessful());
         $this->assertTrue(false);
     } catch (\Exception $e) {
         $exceptionClass = get_class($e);
     }
     $this->assertEquals(TaskExitException::class, $exceptionClass);
     $this->assertTrue($result->wasSuccessful());
     /*
     // This gives an error:
     //    Exception of class Robo\Exception\TaskExitException expected to
     //    be thrown, but PHPUnit_Framework_Exception caught
     // This happens whether or not the expected exception is thrown
     $this->guy->expectException(TaskExitException::class, function() {
         // $result = Result::error($task, "Something that did not work");
         $result = Result::success($task, "Something that worked");
     });
     */
     Result::$stopOnFail = false;
 }
Пример #2
0
 function execute($opts)
 {
     $answer = $this->ask("Bulding Docker container takes some time, you can use already provisioned image instead.\nDo you want to continue? (y/n)");
     if (trim(strtolower($answer)) != 'y') {
         return;
     }
     Result::$stopOnFail = true;
     $recipes = $opts['recipes'] ?: implode(',', Config::$travisRecipes);
     (new BuildRecipe('base'))->tag('roboci_base')->run();
     $res = (new DockerRun('base'))->option('-i')->option('--privileged')->exec('/usr/bin/chef-solo -j /travis.json -o ' . $recipes)->run();
     $this->taskDeleteDir(Config::$buildDir)->run();
     $data = $res->getData();
     $this->yell("Container built in successfully. Run `docker commit {$data['cid']} yourname/imagename` to save it");
 }
Пример #3
0
 protected function stopOnFail($stopOnFail = true)
 {
     Result::$stopOnFail = $stopOnFail;
 }