本文整理汇总了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;
}
示例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;
}