コード例 #1
0
ファイル: Help.php プロジェクト: molovo/phake
 public static function render(Runner $runner)
 {
     echo $runner->output->yellow->render('Usage:');
     echo $runner->output->render('  phake [options] [command|task|group]');
     echo $runner->output->render('');
     echo $runner->output->yellow->render('Options:');
     echo $runner->output->render('  -h, --help               Show help text and exit.');
     echo $runner->output->render('  -v, --version            Show version information and exit.');
     echo $runner->output->render('  -q, --quiet              Hide output from scripts run by tasks.');
     echo $runner->output->render('  -d, --dir <dir>          Specify a custom working directory.');
     echo $runner->output->render('  -f, --phakefile <file>   Specify a custom Phakefile.');
     echo $runner->output->render('  -t, --tasks              List all tasks defined in the Phakefile and exit.');
     echo $runner->output->render('  -g, --groups             List all groups defined in the Phakefile and exit.');
     if (file_exists($runner->phakefile)) {
         require_once $runner->phakefile;
         echo $runner->output->render('');
         echo $runner->output->yellow->render('Tasks:');
         $runner->tasks('  ');
         echo $runner->output->render('');
         echo $runner->output->yellow->render('Groups:');
         $runner->output->setGlobalIndent(2);
         $runner->groups();
     }
     exit;
 }
コード例 #2
0
ファイル: RunnerTest.php プロジェクト: theseer/cli
 public function testUnknownCommandExceptionsReportToStdErr()
 {
     $request = new Request(['help']);
     $locator = $this->prophesize(CommandLocator::class);
     $locator->getCommandForRequest($request)->willThrow(new CommandLocatorException('...', CommandLocatorException::UnknownCommand));
     $cli = new Runner($locator->reveal());
     StdErrCapture::init();
     $cli->run($request);
     StdErrCapture::done();
     $this->assertEquals("Unknown command 'help'\n\n", StdErrCapture::getBuffer());
 }
コード例 #3
0
ファイル: TerminusCommand.php プロジェクト: sammys/terminus
 /**
  * Instantiates object, sets cache and session
  *
  * @param array $options Elements as follow:
  *        FileCache cache
  *        Logger    Logger
  *        Outputter Outputter
  *        Session   Session
  * @return TerminusCommand
  */
 public function __construct(array $options = [])
 {
     $this->cache = new FileCache();
     $this->runner = $options['runner'];
     $this->session = Session::instance();
     $this->logger = $this->runner->getLogger();
     $this->outputter = $this->runner->getOutputter();
     $this->loadHelpers();
     if (!Utils\isTest()) {
         Utils\checkForUpdate($this->log());
     }
 }
コード例 #4
0
 public function testLogJUnitCreatesXmlFile()
 {
     $outputPath = FIXTURES . DS . 'logs' . DS . 'test-output.xml';
     $this->options['log-junit'] = $outputPath;
     $runner = new Runner($this->options);
     ob_start();
     $runner->run();
     ob_end_clean();
     $this->assertTrue(file_exists($outputPath));
     $this->assertJunitXmlIsCorrect($outputPath);
     if (file_exists($outputPath)) {
         unlink($outputPath);
     }
 }
コード例 #5
0
ファイル: classes.php プロジェクト: fuzzy76/nr-reg
 public function getUsers()
 {
     $query = "\n  select\n  p.id,\n  p.display_name as name,\n  p.user_email as email,\n  max(IF(pa.meta_key='wp-athletics_gender', pa.meta_value, null)) as gender,\n  max(IF(pa.meta_key='wp-athletics_dob', pa.meta_value, null)) as dob\n  from " . NRDatabase::USERTABLE . " p\n  left join " . NRDatabase::USERMETATABLE . " as pa on p.id = pa.user_id\n  group by p.id\n  ";
     $result = $this->query($query);
     $runners = array();
     if ($result) {
         foreach ($result as $dbrow) {
             $user = new Runner($dbrow);
             if (!$user->isComplete()) {
                 $runners[] = $user;
             }
         }
     }
     return $runners;
 }
コード例 #6
0
ファイル: Command.php プロジェクト: slince/mechanic
 protected function makeReport(Runner $runner)
 {
     $excel = new PHPExcel();
     $sheet = $excel->setActiveSheetIndex(0)->setCellValue('A1', 'ID')->setCellValue('B1', 'Url地址')->setCellValue('C1', '请求方法')->setCellValue('E1', '测试结果')->setCellValue('F1', '备注');
     foreach ($this->extractDataFromChain($runner->getExaminationChain()) as $key => $data) {
         $key += 2;
         $sheet->setCellValue("A{$key}", $data['name'])->setCellValue("B{$key}", $data['url'])->setCellValue("C{$key}", $data['method'])->setCellValue("E{$key}", $data['status'])->setCellValue("F{$key}", $data['remark']);
     }
     $writer = \PHPExcel_IOFactory::createWriter($excel, 'Excel2007');
     $filename = getcwd() . DIRECTORY_SEPARATOR . 'report.xlsx';
     if (file_exists($filename)) {
         $filename = str_replace('.xlsx', time() . '.xlsx', $filename);
     }
     $writer->save($filename);
 }
コード例 #7
0
ファイル: CLIRunner.php プロジェクト: masterminds/fortissimo
 public function initialContext()
 {
     $cxt = parent::initialContext();
     $cxt->add('output', $this->output);
     $cxt->add('input', $this->input);
     return $cxt;
 }
コード例 #8
0
 /**
  * Run
  *
  * @access public
  */
 public function run()
 {
     $pid = pcntl_fork();
     while (true) {
         if ($pid == -1) {
             die('Could not fork');
         } elseif ($pid) {
             // Parent
             pcntl_waitpid($pid, $status);
             sleep(5);
             $pid = pcntl_fork();
         } else {
             // Child
             $trans = new Runner();
             $trans->run();
             exit;
         }
     }
 }
コード例 #9
0
 public static function run_app($task, $args)
 {
     if (isset($args[0])) {
         $config_file = $args[0];
     } else {
         $config_file = getcwd() . '/config.yaml';
     }
     pake_echo_comment('Loading configuration…');
     if (!file_exists($config_file)) {
         throw new \pakeException("Configuration file is not found: " . $config_file);
     }
     $config = \pakeYaml::loadFile($config_file);
     $runner = new Runner();
     foreach ($config['servers'] as $server) {
         if (!class_exists($server['app']['class'])) {
             require dirname($config_file) . '/' . $server['app']['file'];
             pake_echo_action('load class', $server['app']['class']);
         }
         $runner->addServer($server['app']['class'], $server['app']['middlewares'], $server['protocol'], $server['socket'], $server['min-children'], $server['max-children']);
         pake_echo_action('register', $server['app']['class'] . ' server via ' . $server['protocol'] . ' at ' . $server['socket'] . '. (' . $server['min-children'] . '-' . $server['max-children'] . ' children)');
     }
     pake_echo_comment('Starting server…');
     $runner->go();
 }
コード例 #10
0
ファイル: MeasureBasicOps.php プロジェクト: afaltz/hhvm
        echo "\nProcessor Model\t\t\t" . "{$processormodel}";
        echo "\nProcessor MHz\t\t\t" . "{$processorspeed}";
        echo "\nCache Types and Sizes";
        echo sprintf("%10s %-16s %-16s\n", "", $cachetypes[0], $cachesizes[0]);
        for ($count = 1; $count < $num_caches; $count++) {
            echo sprintf("%31s %-16s %-16s\n", "", $cachetypes[$count], $cachesizes[$count]);
        }
        echo "Memory \t\t\t\t" . "{$memsize}";
        echo "\nOperating System\t\t";
        system('cat /etc/system-release');
        echo "OS Version\t\t\t";
        system('uname -mrs');
        echo "Compile Type\t\t\t" . "JIT-compiled, repo authoritative mode, inlining turned off";
        echo "\n";
        echo "\n";
    }
}
Runner::openfile();
if ($argv[1] == 'basic') {
    Runner::runtestsBasic();
} else {
    Runner::runtestsBasic();
    Runner::runtestsInstanceof();
    Runner::runtestsIsset();
    Runner::runtestsIteration();
    Runner::runtestsRegex();
    Runner::runtestsReflection();
}
Runner::closefile();
Runner::reportresults();
コード例 #11
0
 /**
  * @param Questioner $questioner
  * @param Runner     $runner
  * @param array      $cachedAnswers Cached answers (from a previous run)
  */
 public function execute(Questioner $questioner, Runner $runner, array $cachedAnswers = [])
 {
     $answers = $questioner->interact($this->configurators, $runner->skipOptional(), $this->variables, [] !== $cachedAnswers ? $cachedAnswers : $this->defaults);
     $runner->run($this, $this->generators, $answers);
 }
コード例 #12
0
ファイル: inscriptions.php プロジェクト: jonhy005/nobressart
$erroMsg;
if (HTTP_RESQUEST::exist('dossard_old')) {
    $dbUtils->connect();
    if (!$dbUtils->isDossardInCurrentCourse(HTTP_RESQUEST::post('dossard_old'))) {
        if ($dbUtils->isDossardValidForReSubscribe(HTTP_RESQUEST::post('dossard_old'))) {
            $dbUtils->subscribeOld(HTTP_RESQUEST::post('dossard_old'));
            $lastOldDossard = HTTP_RESQUEST::post('dossard_old');
        } else {
            $erroMsg = "LE DOSSARD " . HTTP_RESQUEST::post('dossard_old') . " N'A JAMAIS ETE PREALABLEMENT INSCRIT";
        }
    } else {
        $erroMsg = "LE DOSSARD " . HTTP_RESQUEST::post('dossard_old') . " EST DEJA INSCRIT SUR CETE COURSE";
    }
} else {
    $runner1 = new Runner(HTTP_RESQUEST::post('nom1'), HTTP_RESQUEST::post('prenom1'), HTTP_RESQUEST::post('y1') . "-" . HTTP_RESQUEST::post('m1') . "-" . HTTP_RESQUEST::post('d1'), HTTP_RESQUEST::post('sexe1'), HTTP_RESQUEST::post('club1'));
    $runner2 = new Runner(HTTP_RESQUEST::post('nom2'), HTTP_RESQUEST::post('prenom2'), HTTP_RESQUEST::post('y2') . "-" . HTTP_RESQUEST::post('m2') . "-" . HTTP_RESQUEST::post('d2'), HTTP_RESQUEST::post('sexe2'), HTTP_RESQUEST::post('club2'));
    $canSave = false;
    if (Config::team) {
        $canSave = $runner1->isValid() && $runner2->isValid();
    } else {
        $canSave = $runner1->isValid();
    }
    if ($canSave) {
        $dbUtils->connect();
        if (HTTP_RESQUEST::exist('dossard')) {
            if ($dbUtils->isDossardValid(HTTP_RESQUEST::post('dossard'))) {
                $team = new Team($runner1, $runner2, HTTP_RESQUEST::post('dossard'));
                $team->persist($dbUtils);
                $dbUtils->subscribeOld(HTTP_RESQUEST::post('dossard'), HTTP_RESQUEST::post('distance'));
                $dbUtils->close();
                $lastNewDossard = HTTP_RESQUEST::post('dossard');
コード例 #13
0
ファイル: Runner.php プロジェクト: aainc/Scruit
        } elseif (isset($this->commands[$options['n']]) || class_exists($options['n'])) {
            $command = isset($this->commands[$options['n']]) ? $this->commands[$options['n']] : new $options['n']();
            if (in_array('Scruit\\Runnable', class_implements($command))) {
                if (isset($args['man'])) {
                    $command->doc();
                } else {
                    $result = $command->run($args);
                }
            } else {
                $result = $options['n'] . ' is not runner.';
            }
        } else {
            $result = $options['n'] . ' is not exists.';
        }
        return $result;
    }
}
if (php_sapi_name() === 'cli' && basename($_SERVER['SCRIPT_NAME']) === 'Runner.php' && isset($argv) && count($argv)) {
    require __DIR__ . '/bootstrap.php';
    $options = getopt('n::', array('optional::', 'bootstrap::'));
    $result = 0;
    try {
        echo Runner::getInstance()->run($options) . "\n";
    } catch (\Exception $e) {
        error_log("<< " . get_class($e) . " >>\n");
        error_log($e->getMessage());
        error_log($e->getTraceAsString());
        $result = 1;
    }
    exit($result);
}
コード例 #14
0
            }
        }
        if ($input != NULL) {
            unlink($pipe_filename);
        }
        pcntl_waitpid($pid, $status);
        if (pcntl_wifexited($status)) {
            return pcntl_wexitstatus($status);
        }
        if (pcntl_wifsignaled($status) || pcntl_wifstopped($status)) {
            return -1;
        }
    }
    function compareResult($dir_result, $dir_output)
    {
        $bufferoutput = file($dir_output);
        $bufferesult = file($dir_result);
        #$bufferesult = preg_replace('/\s(?=\s)/', '',$bufferesult);
        $diff = array_diff($bufferesult, $bufferesult);
        if (count($diff) == 0) {
            return true;
        }
        return false;
    }
}
$test = new Runner();
$result = $test->execute('./teste', NULL, NULL, './teste.txt', './output.txt');
exit($result);
?>

コード例 #15
0
ファイル: helpers.php プロジェクト: CarbinCreative/Cider
/**
 *  afterEach
 *
 *  Adds a after each callback.
 *
 *  @param callable $afterEachCallback
 *
 *  @return void
 */
function afterEach(callable $afterEachCallback)
{
    Runner::afterEach($afterEachCallback);
}
コード例 #16
0
 /**
  * Executes a Request and (if applicable) automatically retries
  * when errors occur.
  *
  * @param Client $client
  * @param Request $req
  * @return array decoded result
  * @throws Exception on server side error (ie: not authenticated,
  *  invalid or malformed post body, invalid url)
  */
 public static function execute(Client $client, Request $req)
 {
     $runner = new Runner($client, sprintf('%s %s', $req->getRequestMethod(), $req->getUrl()), array(get_class(), 'doExecute'), array($client, $req));
     return $runner->run();
 }
コード例 #17
0
 function testShouldThrowIfParamCountInvalidWithOptionalParamSet()
 {
     $runner = new Runner(array(array('Middleware\\MiddlewareWithOptionalParam', array('A', 'optional'))));
     $env = new DummyEnv();
     $this->assertNull($runner->call($env));
     $this->assertEquals(array('A-optional ->'), $env->before);
     $this->assertEquals(array('A-optional <-'), $env->after);
 }
コード例 #18
0
ファイル: SlimRestful.php プロジェクト: m4nolo/slim-restful
 public function run()
 {
     $runner = new Runner();
     $runner->run($this);
 }
コード例 #19
0
ファイル: index.php プロジェクト: Overfinch/oop
{
}
class Runner
{
    static function init()
    {
        try {
            $config = new Conf("file.xml");
            $config->set('sex', 'male');
            // назначает значение
            $config->write();
            // записывает в файл
            echo "sex: " . $config->get('sex');
            // выводит значение
        } catch (FileException $e) {
            die($e->__toString());
            //файл не существует либо не доступен для записи
        } catch (XmlException $e) {
            die($e->__toString());
            //Повреждённый XML-файл
        } catch (ConfException $e) {
            die($e->__toString());
            //не корректный формат XML-файла
        } catch (Exception $e) {
            die($e->__toString());
            // Этот код не долже никогда вызываться
        }
    }
}
Runner::init();
コード例 #20
0
ファイル: job-runner.php プロジェクト: vbuilder/scheduler
    }
    protected function jobFinished($jobScript, $stdoutHandle, $stderrHandle)
    {
        $output = stream_get_contents($stdoutHandle);
        if ($output != "") {
            echo "\n\n{$output}\nJob finished\n";
        } else {
            echo " Finished\n";
        }
        // Call parent
        return call_user_func_array(array('parent', __FUNCTION__), func_get_args());
    }
    protected function jobFailed($jobScript, $stdoutHandle, $stderrHandle)
    {
        $output = stream_get_contents($stdoutHandle);
        if ($output != "") {
            echo "\n\n{$output}\n!!! Job FAILED\n";
        } else {
            echo " Failed\n";
        }
        // Log error (and notify by e-mail if set)
        Nette\Diagnostics\Debugger::log('Job ' . $jobScript . ' failed', 'error');
        // Call parent
        return call_user_func_array(array('parent', __FUNCTION__), func_get_args());
    }
}
// -----------------------------------------------------------------------------
$runner = new Runner($container->getService('scheduler.jobStorage'));
echo "\n";
$runner->runAll();
echo "\n";
コード例 #21
0
ファイル: chat.php プロジェクト: brenodouglas/react-restify
<?php

require_once __DIR__ . '/../vendor/autoload.php';
use CapMousse\ReactRestify\{Server, Runner};
use CapMousse\ReactRestify\Async\Timeout;
use CapMousse\ReactRestify\Promise\AsyncPromise;
$server = new Server("ReactAPI", "0.0.0.1");
$server->post('/', function ($req, $res, $next) {
    $image = (object) $req->httpRequest->getFiles()['filename'];
    AsyncPromise::run(function ($image) {
        file_put_contents(__DIR__ . "/" . rand() . ".jpg", $image->stream);
    }, $image)->then(function () use($res, $next) {
        $res->addHeader("Content-Type", "text/html");
        $res->write("result");
        $next();
    });
});
$server->on('NotFound', function ($request, $response, $next) {
    $response->write('You fail, 404');
    $response->setStatus(404);
    $next();
});
$runner = new Runner($server);
$runner->listen(8080);
コード例 #22
0
ファイル: Request.php プロジェクト: oksuz/curl
 /**
  * @return Response
  */
 public function result()
 {
     $runner = new Runner();
     return $runner->runSingle($this);
 }
コード例 #23
0
ファイル: bug48409.php プロジェクト: badlamer/hhvm
{
    public function func()
    {
        $b = new BBB();
        $c = new CCC();
        $i = 34;
        $item = array('foo' => 'bar');
        try {
            $c->process($b->xyz($item['foo'], $i));
        } catch (ABCException $e) {
            $b->xyz($item['foo'], $i);
        }
    }
}
class Runner
{
    public function run($x)
    {
        try {
            $x->func();
        } catch (ABCException $e) {
            throw new Exception();
        }
    }
}
try {
    $runner = new Runner();
    $runner->run(new AAA());
} catch (Exception $e) {
    die('Exception thrown');
}
コード例 #24
0
ファイル: Config.php プロジェクト: spasquier/sv-egg-giver
 /**
  * Config constructor.
  */
 private function __construct()
 {
     $this->settings = (require Runner::getConfigDir() . "/settings.php");
 }
コード例 #25
0
ファイル: example.php プロジェクト: nike-17/SiteRunner
<?php

include_once './library/Runner.php';
include_once './Cli.php';
$cli = new Cli();
$options = array('siteUrl' => 'http://www.zalora.sg', 'crawlerAdapterName' => 'Fgc', 'parserAdapterName' => 'Xpath', 'processorName' => 'Zalora_Price');
try {
    $runner = new Runner($options);
    $notInIntervalUrls = array();
    while ($runner->getPlanner()->plannerQueueHasMore()) {
        $currenUrl = $runner->getPlanner()->getNext();
        $data = $runner->getCrawler()->getAdapter()->getHtmlData($currenUrl);
        $urls = $runner->getParser()->getAdapter()->getUrls($data);
        $runner->getPlanner()->addUrls($urls);
        if (!$runner->getProcessor()->is_price_interval($data, 20, 2000)) {
            $notInIntervalUrls[] = $currenUrl;
            $cli->info("Price of this item not in providing interval: {$currenUrl}");
        }
        if ($runner->getPlanner()->processedListSize() % 10 == 0) {
            $cli->info("Processed List Size {$runner->getPlanner()->processedListSize()}");
            $cli->info("Planner Queue Size {$runner->getPlanner()->plannerQueueSize()}");
            $notInIntervalUrlsCount = count($notInIntervalUrls);
            $cli->info("Not in interval url count  {$notInIntervalUrlsCount}");
        }
        $runner->getPlanner()->moveToProcessed($currenUrl);
    }
    $cli->info('Results:');
    foreach ($notInIntervalUrls as $url) {
        $cli->info($url);
    }
} catch (Exception $e) {
コード例 #26
0
ファイル: Runner.php プロジェクト: alewitt/openstack
            }
            $services = [$service => $versions];
        }
        return $services;
    }
    private function toCamelCase($word, $separator = '_')
    {
        return str_replace($separator, '', ucwords($word, $separator));
    }
    public function runServices()
    {
        list($serviceOpt, $versionOpt, $testMethodOpt, $debugOpt) = $this->getOpts();
        $services = $this->getRunnableServices($serviceOpt, $versionOpt, $testMethodOpt);
        foreach ($services as $serviceName => $versions) {
            foreach ($versions as $version) {
                $class = sprintf("%s\\%s\\%sTest", __NAMESPACE__, $this->toCamelCase($serviceName), ucfirst($version));
                $testRunner = new $class($this->logger, $debugOpt);
                if ($testMethodOpt && method_exists($testRunner, $testMethodOpt)) {
                    $testRunner->startTimer();
                    $testRunner->{$testMethodOpt}();
                } else {
                    $testRunner->runTests();
                }
                $testRunner->deletePaths();
            }
        }
    }
}
require_once dirname(dirname(__DIR__)) . '/vendor/autoload.php';
$runner = new Runner();
$runner->runServices();
コード例 #27
-2
ファイル: Planner.php プロジェクト: nike-17/SiteRunner
 /**
  * Normalize url
  * @todo Refactor
  * @param string $url
  * @return string
  */
 protected function _normalizeUrl($url)
 {
     if (!parse_url($url, PHP_URL_HOST)) {
         $siteUrl = $this->_runner->getOption('siteUrl');
         $prefix = parse_url(rtrim($siteUrl, "/"), PHP_URL_HOST);
         if (strpos($prefix, $url) === false) {
             $url = $prefix . $url;
         }
         if (!strpos('http', $url)) {
             $url = 'http://' . $url;
         }
     }
     $url = rtrim($url, "/");
     return $url;
 }