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


PHP ExecFuture::readStdout方法代码示例

本文整理汇总了PHP中ExecFuture::readStdout方法的典型用法代码示例。如果您正苦于以下问题:PHP ExecFuture::readStdout方法的具体用法?PHP ExecFuture::readStdout怎么用?PHP ExecFuture::readStdout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExecFuture的用法示例。


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

示例1: run

 public function run()
 {
     $projectRoot = $this->getWorkingCopy()->getProjectRoot();
     $cwd = getcwd();
     $buildDir = $this->findBuildDirectory($projectRoot, $cwd);
     print "Using build directory '{$buildDir}'\n";
     $makeVars = $this->getMakeVars($buildDir);
     $lit = $this->findLitExecutable($makeVars);
     print "Using lit executable '{$lit}'\n";
     // We have to modify the format string, because llvm-lit does not like a '' argument
     $cmd = '%s ' . ($this->getEnableAsyncTests() ? '' : '-j1 ') . '%s 2>&1';
     $litFuture = new ExecFuture($cmd, $lit, $buildDir . "/test");
     $out = "";
     $results = array();
     $lastTime = microtime(true);
     $ready = false;
     $dots = "";
     $numTests = 0;
     while (!$ready) {
         $ready = $litFuture->isReady();
         $newout = $litFuture->readStdout();
         if (strlen($newout) == 0) {
             usleep(100);
             continue;
         }
         $out .= $newout;
         if ($ready && strlen($out) > 0 && substr($out, -1) != "\n") {
             $out .= "\n";
         }
         while (($nlPos = strpos($out, "\n")) !== FALSE) {
             $line = substr($out, 0, $nlPos + 1);
             $out = substr($out, $nlPos + 1);
             $res = ArcanistUnitTestResult::RESULT_UNSOUND;
             if (substr($line, 0, 6) == "PASS: ") {
                 $res = ArcanistUnitTestResult::RESULT_PASS;
             } elseif (substr($line, 0, 6) == "FAIL: ") {
                 $res = ArcanistUnitTestResult::RESULT_FAIL;
             } elseif (substr($line, 0, 7) == "XPASS: ") {
                 $res = ArcanistUnitTestResult::RESULT_FAIL;
             } elseif (substr($line, 0, 7) == "XFAIL: ") {
                 $res = ArcanistUnitTestResult::RESULT_PASS;
             } elseif (substr($line, 0, 13) == "UNSUPPORTED: ") {
                 $res = ArcanistUnitTestResult::RESULT_SKIP;
             } elseif (!$numTests && preg_match('/Testing: ([0-9]+) tests/', $line, $matches)) {
                 $numTests = (int) $matches[1];
             }
             if ($res == ArcanistUnitTestResult::RESULT_FAIL) {
                 print "[1A";
             }
             if ($res != ArcanistUnitTestResult::RESULT_SKIP && $res != ArcanistUnitTestResult::RESULT_PASS) {
                 print "\r[K[1A" . $line . self::progress($results, $numTests);
             }
             if ($res == ArcanistUnitTestResult::RESULT_UNSOUND) {
                 continue;
             }
             $result = new ArcanistUnitTestResult();
             $result->setName(trim(substr($line, strpos($line, ':') + 1)));
             $result->setResult($res);
             $newTime = microtime(true);
             $result->setDuration($newTime - $lastTime);
             $lastTime = $newTime;
             $results[] = $result;
             $dots .= ".";
             print "\r[K[1A" . self::progress($results, $numTests);
         }
     }
     list($out1, $out2) = $litFuture->read();
     print $out1;
     if ($out2) {
         throw new Exception('There was error output, even though it should have been redirected to stdout.');
     }
     print "\n";
     return $results;
 }
开发者ID:mingxingtan,项目名称:polly,代码行数:74,代码来源:LitTestEngine.php

示例2: run

 public function run()
 {
     $projectRoot = $this->getWorkingCopy()->getProjectRoot();
     $cwd = getcwd();
     $buildDir = $this->findBuildDirectory($projectRoot, $cwd);
     $polliObjDir = $buildDir;
     if (is_dir($buildDir . DIRECTORY_SEPARATOR . "tools" . DIRECTORY_SEPARATOR . "polly" . DIRECTORY_SEPARATOR . "tools" . DIRECTORY_SEPARATOR . "polli")) {
         $polliObjDir = $buildDir . DIRECTORY_SEPARATOR . "tools" . DIRECTORY_SEPARATOR . "polly" . DIRECTORY_SEPARATOR . "tools" . DIRECTORY_SEPARATOR . "polli";
     }
     $polliTestDir = $polliObjDir . DIRECTORY_SEPARATOR . "test";
     if (is_dir($buildDir . DIRECTORY_SEPARATOR . "bin") && file_exists($buildDir . DIRECTORY_SEPARATOR . "bin" . DIRECTORY_SEPARATOR . "llvm-lit")) {
         $lit = $buildDir . DIRECTORY_SEPARATOR . "bin" . DIRECTORY_SEPARATOR . "llvm-lit";
         $cmd = "ninja -C " . $buildDir;
         print "Running ninja (" . $cmd . ")\n";
         exec($cmd);
     } else {
         $makeVars = $this->getMakeVars($buildDir);
         $lit = $this->findLitExecutable($makeVars);
     }
     print "Using lit executable '{$lit}'\n";
     // We have to modify the format string, because llvm-lit does not like a '' argument
     $cmd = '%s %s 2>&1';
     $litFuture = new ExecFuture($cmd, $lit, $polliTestDir);
     $out = "";
     $results = array();
     $lastTime = microtime(true);
     $ready = false;
     $dots = "";
     $numTests = 0;
     while (!$ready) {
         $ready = $litFuture->isReady();
         $newout = $litFuture->readStdout();
         if (strlen($newout) == 0) {
             usleep(100);
             continue;
         }
         $out .= $newout;
         if ($ready && strlen($out) > 0 && substr($out, -1) != "\n") {
             $out .= "\n";
         }
         while (($nlPos = strpos($out, "\n")) !== FALSE) {
             $line = substr($out, 0, $nlPos + 1);
             $out = substr($out, $nlPos + 1);
             $res = ArcanistUnitTestResult::RESULT_UNSOUND;
             if (substr($line, 0, 6) == "PASS: ") {
                 $res = ArcanistUnitTestResult::RESULT_PASS;
             } elseif (substr($line, 0, 6) == "FAIL: ") {
                 $res = ArcanistUnitTestResult::RESULT_FAIL;
             } elseif (substr($line, 0, 7) == "XPASS: ") {
                 $res = ArcanistUnitTestResult::RESULT_FAIL;
             } elseif (substr($line, 0, 7) == "XFAIL: ") {
                 $res = ArcanistUnitTestResult::RESULT_PASS;
             } elseif (substr($line, 0, 13) == "UNSUPPORTED: ") {
                 $res = ArcanistUnitTestResult::RESULT_SKIP;
             } elseif (!$numTests && preg_match('/Testing: ([0-9]+) tests/', $line, $matches)) {
                 $numTests = (int) $matches[1];
             }
             if ($res == ArcanistUnitTestResult::RESULT_FAIL) {
                 print "[0A";
             }
             if ($res != ArcanistUnitTestResult::RESULT_SKIP && $res != ArcanistUnitTestResult::RESULT_PASS) {
                 print "[K[0A" . $line . self::progress($results, $numTests);
             }
             if ($res == ArcanistUnitTestResult::RESULT_UNSOUND) {
                 continue;
             }
             $result = new ArcanistUnitTestResult();
             $result->setName(trim(substr($line, strpos($line, ':') + 1)));
             $result->setResult($res);
             $newTime = microtime(true);
             $result->setDuration($newTime - $lastTime);
             $lastTime = $newTime;
             $results[] = $result;
             $dots .= ".";
             print "\r[K[0A" . self::progress($results, $numTests);
         }
     }
     list($out1, $out2) = $litFuture->read();
     print $out1;
     if ($out2) {
         throw new Exception('There was error output, even though it should have been redirected to stdout.');
     }
     print "\n";
     $timeThreshold = 0.05;
     $interestingTests = array();
     foreach ($results as $result) {
         if ($result->getResult() != "pass") {
             $interestingTests[] = $result;
         }
         if ($result->getDuration() > $timeThreshold) {
             $interestingTests[] = $result;
         }
     }
     return $interestingTests;
 }
开发者ID:CIB,项目名称:polli,代码行数:95,代码来源:LitTestEngine.php


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