当前位置: 首页>>代码示例>>PHP>>正文


PHP Futures函数代码示例

本文整理汇总了PHP中Futures函数的典型用法代码示例。如果您正苦于以下问题:PHP Futures函数的具体用法?PHP Futures怎么用?PHP Futures使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Futures函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: runTests

 public function runTests($test_paths, $source_path)
 {
     if (empty($test_paths)) {
         return array();
     }
     $futures = array();
     $tmpfiles = array();
     foreach ($test_paths as $test_path) {
         $xunit_tmp = new TempFile();
         $cover_tmp = new TempFile();
         $future = $this->buildTestFuture($test_path, $xunit_tmp, $cover_tmp);
         $futures[$test_path] = $future;
         $tmpfiles[$test_path] = array('xunit' => $xunit_tmp, 'cover' => $cover_tmp);
     }
     $results = array();
     foreach (Futures($futures)->limit(4) as $test_path => $future) {
         try {
             list($stdout, $stderr) = $future->resolvex();
         } catch (CommandException $exc) {
             if ($exc->getError() > 1) {
                 // 'nose' returns 1 when tests are failing/broken.
                 throw $exc;
             }
         }
         $xunit_tmp = $tmpfiles[$test_path]['xunit'];
         $cover_tmp = $tmpfiles[$test_path]['cover'];
         $this->parser = new ArcanistXUnitTestResultParser();
         $results[] = $this->parseTestResults($source_path, $xunit_tmp, $cover_tmp);
     }
     return array_mergev($results);
 }
开发者ID:ivoryxiong,项目名称:arcanist,代码行数:31,代码来源:NoseTestEngine.php

示例2: willLintPaths

 public function willLintPaths(array $paths)
 {
     $program = false;
     $ret_value = 0;
     $last_line = system("which checkCpp", $ret_value);
     if ($ret_value == 0) {
         $program = $last_line;
     } else {
         if (file_exists(self::PROGRAM)) {
             $program = self::PROGRAM;
         }
     }
     if ($program) {
         $futures = array();
         foreach ($paths as $p) {
             $futures[$p] = new ExecFuture("%s --lint %s 2>&1", $program, $this->getEngine()->getFilePathOnDisk($p));
         }
         foreach (Futures($futures)->limit(8) as $p => $f) {
             list($stdout, $stderr) = $f->resolvex();
             $raw = json_decode($stdout, true);
             if (!is_array($raw)) {
                 throw new Exception("checkCpp returned invalid JSON!" . "Stdout: {$stdout} Stderr: {$stderr}");
             }
             foreach ($raw as $err) {
                 $this->addLintMessage(ArcanistLintMessage::newFromDictionary(array('path' => $err['file'], 'line' => $err['line'], 'char' => 0, 'name' => $err['name'], 'description' => $err['info'], 'code' => $this->getLinterName(), 'severity' => ArcanistLintSeverity::SEVERITY_WARNING)));
             }
         }
     }
     return;
 }
开发者ID:peersafe,项目名称:rippled,代码行数:30,代码来源:PfffCppLinter.php

示例3: willLintPaths

 public function willLintPaths(array $paths)
 {
     $futures = array();
     foreach ($paths as $path) {
         if (array_key_exists($path, $this->trees)) {
             continue;
         }
         $futures[$path] = xhpast_get_parser_future($this->getData($path));
     }
     foreach (Futures($futures)->limit(8) as $path => $future) {
         $this->willLintPath($path);
         $this->trees[$path] = null;
         try {
             $this->trees[$path] = XHPASTTree::newFromDataAndResolvedExecFuture($this->getData($path), $future->resolve());
             $root = $this->trees[$path]->getRootNode();
             $root->buildSelectCache();
             $root->buildTokenCache();
         } catch (XHPASTSyntaxErrorException $ex) {
             $this->raiseLintAtLine($ex->getErrorLine(), 1, self::LINT_PHP_SYNTAX_ERROR, 'This file contains a syntax error: ' . $ex->getMessage());
             $this->stopAllLinters();
             return;
         } catch (Exception $ex) {
             $this->raiseLintAtPath(self::LINT_UNABLE_TO_PARSE, 'XHPAST could not parse this file, probably because the AST is too ' . 'deep. Some lint issues may not have been detected. You may safely ' . 'ignore this warning.');
             return;
         }
     }
 }
开发者ID:apexstudios,项目名称:yamwlib,代码行数:27,代码来源:ArcanistXHPASTLinterCustom.php

示例4: renderGrepResults

 private function renderGrepResults(array $results)
 {
     $drequest = $this->getDiffusionRequest();
     require_celerity_resource('syntax-highlighting-css');
     // NOTE: This can be wrong because we may find the string inside the
     // comment. But it's correct in most cases and highlighting the whole file
     // would be too expensive.
     $futures = array();
     $engine = PhabricatorSyntaxHighlighter::newEngine();
     foreach ($results as $result) {
         list($path, $line, $string) = $result;
         $futures["{$path}:{$line}"] = $engine->getHighlightFuture($engine->getLanguageFromFilename($path), ltrim($string));
     }
     try {
         Futures($futures)->limit(8)->resolveAll();
     } catch (PhutilSyntaxHighlighterException $ex) {
     }
     $rows = array();
     foreach ($results as $result) {
         list($path, $line, $string) = $result;
         $href = $drequest->generateURI(array('action' => 'browse', 'path' => $path, 'line' => $line));
         try {
             $string = $futures["{$path}:{$line}"]->resolve();
         } catch (PhutilSyntaxHighlighterException $ex) {
         }
         $string = phutil_tag('pre', array('class' => 'PhabricatorMonospaced'), $string);
         $path = Filesystem::readablePath($path, $drequest->getPath());
         $rows[] = array(phutil_tag('a', array('href' => $href), $path), $line, $string);
     }
     $table = id(new AphrontTableView($rows))->setClassName('remarkup-code')->setHeaders(array(pht('Path'), pht('Line'), pht('String')))->setColumnClasses(array('', 'n', 'wide'))->setNoDataString(pht('The pattern you searched for was not found in the content of any ' . 'files.'));
     return $table;
 }
开发者ID:sethkontny,项目名称:phabricator,代码行数:32,代码来源:DiffusionBrowseSearchController.php

示例5: willLintPaths

 public function willLintPaths(array $paths)
 {
     $futures = array();
     $ret_value = 0;
     $last_line = system("which cpplint", $ret_value);
     $CPP_LINT = false;
     if ($ret_value == 0) {
         $CPP_LINT = $last_line;
     } else {
         if (file_exists(self::CPPLINT)) {
             $CPP_LINT = self::CPPLINT;
         }
     }
     if ($CPP_LINT) {
         foreach ($paths as $p) {
             $lpath = $this->getEngine()->getFilePathOnDisk($p);
             $lpath_file = file($lpath);
             if (preg_match('/\\.(c)$/', $lpath) || preg_match('/-\\*-.*Mode: C[; ].*-\\*-/', $lpath_file[0]) || preg_match('/vim(:.*)*:\\s*(set\\s+)?filetype=c\\s*:/', $lpath_file[0])) {
                 $futures[$p] = new ExecFuture("%s %s %s 2>&1", $CPP_LINT, self::C_FLAG, $this->getEngine()->getFilePathOnDisk($p));
             } else {
                 $futures[$p] = new ExecFuture("%s %s 2>&1", $CPP_LINT, $this->getEngine()->getFilePathOnDisk($p));
             }
         }
         foreach (Futures($futures)->limit(8) as $p => $f) {
             $this->rawLintOutput[$p] = $f->resolvex();
         }
     }
     return;
 }
开发者ID:Jacklli,项目名称:ActionDB,代码行数:29,代码来源:FbcodeCppLinter.php

示例6: willLintPaths

 public final function willLintPaths(array $paths)
 {
     $limit = $this->getFuturesLimit();
     $this->futures = Futures(array())->limit($limit);
     foreach ($this->buildFutures($paths) as $path => $future) {
         $this->futures->addFuture($future, $path);
     }
 }
开发者ID:ivoryxiong,项目名称:arcanist,代码行数:8,代码来源:ArcanistFutureLinter.php

示例7: execute

 public function execute(HarbormasterBuild $build, HarbormasterBuildTarget $build_target)
 {
     $settings = $this->getSettings();
     $variables = $build_target->getVariables();
     $artifact = $build->loadArtifact($settings['hostartifact']);
     $lease = $artifact->loadDrydockLease();
     $this->platform = $lease->getAttribute('platform');
     $command = $this->mergeVariables(array($this, 'escapeCommand'), $settings['command'], $variables);
     $this->platform = null;
     $interface = $lease->getInterface('command');
     $future = $interface->getExecFuture('%C', $command);
     $log_stdout = $build->createLog($build_target, 'remote', 'stdout');
     $log_stderr = $build->createLog($build_target, 'remote', 'stderr');
     $start_stdout = $log_stdout->start();
     $start_stderr = $log_stderr->start();
     $build_update = 5;
     // Read the next amount of available output every second.
     $futures = Futures(array($future));
     foreach ($futures->setUpdateInterval(1) as $key => $future_iter) {
         if ($future_iter === null) {
             // Check to see if we should abort.
             if ($build_update <= 0) {
                 $build->reload();
                 if ($this->shouldAbort($build, $build_target)) {
                     $future->resolveKill();
                     throw new HarbormasterBuildAbortedException();
                 } else {
                     $build_update = 5;
                 }
             } else {
                 $build_update -= 1;
             }
             // Command is still executing.
             // Read more data as it is available.
             list($stdout, $stderr) = $future->read();
             $log_stdout->append($stdout);
             $log_stderr->append($stderr);
             $future->discardBuffers();
         } else {
             // Command execution is complete.
             // Get the return value so we can log that as well.
             list($err) = $future->resolve();
             // Retrieve the last few bits of information.
             list($stdout, $stderr) = $future->read();
             $log_stdout->append($stdout);
             $log_stderr->append($stderr);
             $future->discardBuffers();
             break;
         }
     }
     $log_stdout->finalize($start_stdout);
     $log_stderr->finalize($start_stderr);
     if ($err) {
         throw new HarbormasterBuildFailureException();
     }
 }
开发者ID:denghp,项目名称:phabricator,代码行数:56,代码来源:HarbormasterCommandBuildStepImplementation.php

示例8: run

 public function run()
 {
     $this->projectRoot = $this->getWorkingCopy()->getProjectRoot();
     $this->affectedTests = array();
     foreach ($this->getPaths() as $path) {
         $path = Filesystem::resolvePath($path, $this->projectRoot);
         // TODO: add support for directories
         // Users can call phpunit on the directory themselves
         if (is_dir($path)) {
             continue;
         }
         // Not sure if it would make sense to go further if
         // it is not a .php file
         if (substr($path, -4) != '.php') {
             continue;
         }
         if (substr($path, -8) == 'Test.php') {
             // Looks like a valid test file name.
             $this->affectedTests[$path] = $path;
             continue;
         }
         if ($test = $this->findTestFile($path)) {
             $this->affectedTests[$path] = $test;
         }
     }
     if (empty($this->affectedTests)) {
         throw new ArcanistNoEffectException('No tests to run.');
     }
     $this->prepareConfigFile();
     $futures = array();
     $tmpfiles = array();
     foreach ($this->affectedTests as $class_path => $test_path) {
         if (!Filesystem::pathExists($test_path)) {
             continue;
         }
         $json_tmp = new TempFile();
         $clover_tmp = null;
         $clover = null;
         if ($this->getEnableCoverage() !== false) {
             $clover_tmp = new TempFile();
             $clover = csprintf('--coverage-clover %s', $clover_tmp);
         }
         $config = $this->configFile ? csprintf('-c %s', $this->configFile) : null;
         $stderr = '-d display_errors=stderr';
         $futures[$test_path] = new ExecFuture('%C %C %C --log-json %s %C %s', $this->phpunitBinary, $config, $stderr, $json_tmp, $clover, $test_path);
         $tmpfiles[$test_path] = array('json' => $json_tmp, 'clover' => $clover_tmp);
     }
     $results = array();
     foreach (Futures($futures)->limit(4) as $test => $future) {
         list($err, $stdout, $stderr) = $future->resolve();
         $results[] = $this->parseTestResults($test, $tmpfiles[$test]['json'], $tmpfiles[$test]['clover'], $stderr);
     }
     return array_mergev($results);
 }
开发者ID:ivoryxiong,项目名称:arcanist,代码行数:54,代码来源:PhpunitTestEngine.php

示例9: testMultipleTimeoutsTestShouldRunLessThan1Sec

 public function testMultipleTimeoutsTestShouldRunLessThan1Sec()
 {
     $futures = array();
     for ($ii = 0; $ii < 4; $ii++) {
         $futures[] = id(new ExecFuture('sleep 32000'))->setTimeout(0.01);
     }
     foreach (Futures($futures) as $future) {
         list($err) = $future->resolve();
         $this->assertEqual(true, $err > 0);
         $this->assertEqual(true, $future->getWasKilledByTimeout());
     }
 }
开发者ID:rwray,项目名称:libphutil,代码行数:12,代码来源:ExecFutureTestCase.php

示例10: run

 public function run()
 {
     $paths = $this->getPaths();
     $affected_tests = array();
     foreach ($paths as $path) {
         $absolute_path = Filesystem::resolvePath($path);
         if (is_dir($absolute_path)) {
             $absolute_test_path = Filesystem::resolvePath("tests/" . $path);
             if (is_readable($absolute_test_path)) {
                 $affected_tests[] = $absolute_test_path;
             }
         }
         if (is_readable($absolute_path)) {
             $filename = basename($path);
             $directory = dirname($path);
             // assumes directory layout: tests/<package>/test_<module>.py
             $relative_test_path = "tests/" . $directory . "/test_" . $filename;
             $absolute_test_path = Filesystem::resolvePath($relative_test_path);
             if (is_readable($absolute_test_path)) {
                 $affected_tests[] = $absolute_test_path;
             }
         }
     }
     if (empty($affected_tests)) {
         return array();
     }
     $futures = array();
     $tmpfiles = array();
     foreach ($affected_tests as $test_path) {
         $xunit_tmp = new TempFile();
         $cover_tmp = new TempFile();
         $future = $this->buildTestFuture($test_path, $xunit_tmp, $cover_tmp);
         $futures[$test_path] = $future;
         $tmpfiles[$test_path] = array('xunit' => $xunit_tmp, 'cover' => $cover_tmp);
     }
     $results = array();
     foreach (Futures($futures)->limit(4) as $test_path => $future) {
         try {
             list($stdout, $stderr) = $future->resolvex();
         } catch (CommandException $exc) {
             if ($exc->getError() > 1) {
                 // 'nose' returns 1 when tests are failing/broken.
                 throw $exc;
             }
         }
         $xunit_tmp = $tmpfiles[$test_path]['xunit'];
         $cover_tmp = $tmpfiles[$test_path]['cover'];
         $results[] = $this->parseTestResults($test_path, $xunit_tmp, $cover_tmp);
     }
     return array_mergev($results);
 }
开发者ID:rafikk,项目名称:arcanist,代码行数:51,代码来源:NoseTestEngine.php

示例11: testManyWriters

 public function testManyWriters()
 {
     $root = phutil_get_library_root('phutil') . '/../';
     $bin = $root . 'scripts/test/deferred_log.php';
     $n_writers = 3;
     $n_lines = 8;
     $tmp = new TempFile();
     $futures = array();
     for ($ii = 0; $ii < $n_writers; $ii++) {
         $futures[] = new ExecFuture('%s %d %s', $bin, $n_lines, (string) $tmp);
     }
     Futures($futures)->resolveAll();
     $this->assertEqual(str_repeat("abcdefghijklmnopqrstuvwxyz\n", $n_writers * $n_lines), Filesystem::readFile($tmp));
 }
开发者ID:lsubra,项目名称:libphutil,代码行数:14,代码来源:PhutilDeferredLogTestCase.php

示例12: willLintPaths

 public function willLintPaths(array $paths)
 {
     $script = $this->getConfiguredScript();
     $root = $this->getEngine()->getWorkingCopy()->getProjectRoot();
     $futures = array();
     foreach ($paths as $path) {
         $future = new ExecFuture('%C %s', $script, $path);
         $future->setCWD($root);
         $futures[$path] = $future;
     }
     foreach (Futures($futures)->limit(4) as $path => $future) {
         list($stdout) = $future->resolvex();
         $this->output[$path] = $stdout;
     }
 }
开发者ID:prajwalabove,项目名称:inbox-ios,代码行数:15,代码来源:InboxUncrustifyLinter.php

示例13: willLintPaths

 public function willLintPaths(array $paths)
 {
     $phpcs_bin = $this->getPhpcsPath();
     $phpcs_options = $this->getPhpcsOptions();
     $futures = array();
     foreach ($paths as $path) {
         $filepath = $this->getEngine()->getFilePathOnDisk($path);
         $this->reports[$path] = new TempFile();
         $futures[$path] = new ExecFuture('%C %C --report=xml --report-file=%s %s', $phpcs_bin, $phpcs_options, $this->reports[$path], $filepath);
     }
     foreach (Futures($futures)->limit(8) as $path => $future) {
         $this->results[$path] = $future->resolve();
     }
     libxml_use_internal_errors(true);
 }
开发者ID:rafikk,项目名称:arcanist,代码行数:15,代码来源:ArcanistPhpcsLinter.php

示例14: willParseFiles

 public function willParseFiles(array $file_map)
 {
     $root = dirname(phutil_get_library_root('javelin-diviner'));
     $bin = $root . '/jsast/jsast';
     if (!Filesystem::pathExists($bin)) {
         throw new Exception("You must build the 'jsast' binary before you can generate " . "Javelin documentation.");
     }
     $futures = array();
     foreach ($file_map as $file => $data) {
         $future = new ExecFuture($bin);
         $future->write($data);
         $futures[$file] = $future;
     }
     foreach (Futures($futures)->limit(8) as $file => $future) {
         $this->trees[$file] = $future->resolveJSON();
     }
 }
开发者ID:WilkGardariki,项目名称:javelin,代码行数:17,代码来源:JavelinDivinerEngine.php

示例15: willLintPaths

 public final function willLintPaths(array $paths)
 {
     $futures = array();
     foreach ($paths as $path) {
         if (!$this->shouldLintPath($path)) {
             continue;
         }
         $changed = $this->changedLines[$path];
         if (!isset($changed)) {
             // do not run linter if there are no changes
             continue;
         }
         $futures[$path] = $this->getFormatFuture($path, $changed);
     }
     foreach (Futures($futures)->limit(8) as $p => $f) {
         $this->rawLintOutput[$p] = $f->resolvex();
     }
 }
开发者ID:michaelsuo,项目名称:rocksdb,代码行数:18,代码来源:BaseDirectoryScopedFormatLinter.php


注:本文中的Futures函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。