本文整理汇总了PHP中ExecFuture::resolve方法的典型用法代码示例。如果您正苦于以下问题:PHP ExecFuture::resolve方法的具体用法?PHP ExecFuture::resolve怎么用?PHP ExecFuture::resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecFuture
的用法示例。
在下文中一共展示了ExecFuture::resolve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Runs the test suite.
*/
public function run()
{
$results = array();
$command = '(mkdir -p build && cd build && cmake ..)';
$command .= '&& make -C build all';
$command .= '&& make -C build test';
// Execute the test command & time it.
$timeStart = microtime(true);
$future = new ExecFuture($command);
do {
$future->read();
sleep(0.5);
} while (!$future->isReady());
list($error, $stdout, $stderr) = $future->resolve();
$timeEnd = microtime(true);
// Create a unit test result structure.
$result = new ArcanistUnitTestResult();
$result->setNamespace('DerpVision');
$result->setName('Core');
$result->setDuration($timeEnd - $timeStart);
if ($error == 0) {
$result->setResult(ArcanistUnitTestResult::RESULT_PASS);
} else {
$result->setResult(ArcanistUnitTestResult::RESULT_FAIL);
$result->setUserData($stdout . $stderr);
}
$results[] = $result;
return $results;
}
示例2: lintPath
public function lintPath($path)
{
$sbt = $this->getSBTPath();
// Tell SBT to not use color codes so our regex life is easy.
// TODO: Should this be "clean compile" instead of "compile"?
$f = new ExecFuture("%s -Dsbt.log.noformat=true compile", $sbt);
list($err, $stdout, $stderr) = $f->resolve();
$lines = explode("\n", $stdout);
$messages = array();
foreach ($lines as $line) {
$matches = null;
if (!preg_match("/\\[(warn|error)\\] (.*?):(\\d+): (.*?)\$/", $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
$message = new ArcanistLintMessage();
$message->setPath($matches[2]);
$message->setLine($matches[3]);
$message->setCode($this->getLinterName());
$message->setDescription($matches[4]);
$message->setSeverity($this->getMessageCodeSeverity($matches[1]));
$this->addLintMessage($message);
}
}
示例3: lintPath
public function lintPath($path)
{
$rubyp = $this->getRubyPath();
$f = new ExecFuture("%s -wc", $rubyp);
$f->write($this->getData($path));
list($err, $stdout, $stderr) = $f->resolve();
if ($err === 0) {
return;
}
$lines = explode("\n", $stderr);
$messages = array();
foreach ($lines as $line) {
$matches = null;
if (!preg_match("/(.*?):(\\d+): (.*?)\$/", $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
$code = head(explode(',', $matches[3]));
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[2]);
$message->setName($this->getLinterName() . " " . $code);
$message->setDescription($matches[3]);
$message->setSeverity($this->getMessageCodeSeverity($code));
$this->addLintMessage($message);
}
}
示例4: runTests
private function runTests($targets)
{
$future = new ExecFuture($this->bazelCommand(array_merge(["test", "--noshow_loading_progress", "--noshow_progress"], $targets)));
$future->setCWD($this->project_root);
$status = $future->resolve();
return $this->parseTestResults($targets, $status);
}
示例5: lintPath
public function lintPath($path)
{
$bin = $this->getLintPath();
$path = $this->rocksdbDir() . '/' . $path;
$f = new ExecFuture("%C {$path}", $bin);
list($err, $stdout, $stderr) = $f->resolve();
if ($err === 2) {
throw new Exception("cpplint failed to run correctly:\n" . $stderr);
}
$lines = explode("\n", $stderr);
$messages = array();
foreach ($lines as $line) {
$line = trim($line);
$matches = null;
$regex = '/^[^:]+:(\\d+):\\s*(.*)\\s*\\[(.*)\\] \\[(\\d+)\\]$/';
if (!preg_match($regex, $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[1]);
$message->setCode($matches[3]);
$message->setName($matches[3]);
$message->setDescription($matches[2]);
$message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
$this->addLintMessage($message);
}
}
示例6: ctags_check_executable
function ctags_check_executable()
{
$future = new ExecFuture('ctags --version');
$result = $future->resolve();
if (empty($result[1])) {
return false;
}
return true;
}
示例7: run
public function run()
{
$working_copy = $this->getWorkingCopy();
$this->project_root = $working_copy->getProjectRoot();
// We only want to report results for tests that actually ran, so
// we'll compare the test result files' timestamps to the start time
// of the test run. This will probably break if multiple test runs
// are happening in parallel, but if that's happening then we can't
// count on the results files being intact anyway.
$start_time = time();
$maven_top_dirs = $this->findTopLevelMavenDirectories();
// We'll figure out if any of the modified files we're testing are in
// Maven directories. We won't want to run a bunch of Java tests for
// changes to CSS files or whatever.
$modified_paths = $this->getModifiedPaths();
$maven_failed = false;
foreach ($maven_top_dirs as $dir) {
$dir_with_trailing_slash = $dir . '/';
foreach ($modified_paths as $path) {
if ($dir_with_trailing_slash === substr($path, 0, strlen($dir_with_trailing_slash))) {
$future = new ExecFuture('mvn test');
$future->setCWD($dir);
list($status, $stdout, $stderr) = $future->resolve();
if ($status) {
// Maven exits with a nonzero status if there were test failures
// or if there was a compilation error.
$maven_failed = true;
break 2;
}
break;
}
}
}
$testResults = $this->parseTestResultsSince($start_time);
if ($maven_failed) {
// If there wasn't a test failure, then synthesize one to represent
// the failure of the test run as a whole, since it probably means the
// code failed to compile.
$found_failure = false;
foreach ($testResults as $testResult) {
if ($testResult->getResult() === ArcanistUnitTestResult::RESULT_FAIL || $testResult->getResult() === ArcanistUnitTestResult::RESULT_BROKEN) {
$found_failure = true;
break;
}
}
if (!$found_failure) {
$testResult = new ArcanistUnitTestResult();
$testResult->setResult(ArcanistUnitTestResult::RESULT_BROKEN);
$testResult->setName('mvn test');
$testResults[] = $testResult;
}
}
return $testResults;
}
示例8: run
public function run()
{
$command = $this->getConfigurationManager()->getConfigFromAnySource('unit.engine.tap.command');
$future = new ExecFuture($command);
do {
list($stdout, $stderr) = $future->read();
echo $stdout;
echo $stderr;
sleep(0.5);
} while (!$future->isReady());
list($error, $stdout, $stderr) = $future->resolve();
return $this->parseOutput($stdout);
}
示例9: transformResource
/**
* @phutil-external-symbol function jsShrink
*/
public function transformResource($path, $data)
{
$type = self::getResourceType($path);
switch ($type) {
case 'css':
$data = $this->replaceCSSPrintRules($path, $data);
$data = $this->replaceCSSVariables($path, $data);
$data = preg_replace_callback('@url\\s*\\((\\s*[\'"]?.*?)\\)@s', nonempty($this->translateURICallback, array($this, 'translateResourceURI')), $data);
break;
}
if (!$this->minify) {
return $data;
}
// Some resources won't survive minification (like Raphael.js), and are
// marked so as not to be minified.
if (strpos($data, '@' . 'do-not-minify') !== false) {
return $data;
}
switch ($type) {
case 'css':
// Remove comments.
$data = preg_replace('@/\\*.*?\\*/@s', '', $data);
// Remove whitespace around symbols.
$data = preg_replace('@\\s*([{}:;,])\\s*@', '\\1', $data);
// Remove unnecessary semicolons.
$data = preg_replace('@;}@', '}', $data);
// Replace #rrggbb with #rgb when possible.
$data = preg_replace('@#([a-f0-9])\\1([a-f0-9])\\2([a-f0-9])\\3@i', '#\\1\\2\\3', $data);
$data = trim($data);
break;
case 'js':
// If `jsxmin` is available, use it. jsxmin is the Javelin minifier and
// produces the smallest output, but is complicated to build.
if (Filesystem::binaryExists('jsxmin')) {
$future = new ExecFuture('jsxmin __DEV__:0');
$future->write($data);
list($err, $result) = $future->resolve();
if (!$err) {
$data = $result;
break;
}
}
// If `jsxmin` is not available, use `JsShrink`, which doesn't compress
// quite as well but is always available.
$root = dirname(phutil_get_library_root('phabricator'));
require_once $root . '/externals/JsShrink/jsShrink.php';
$data = jsShrink($data);
break;
}
return $data;
}
示例10: resolveBlameFuture
protected function resolveBlameFuture(ExecFuture $future)
{
list($err, $stdout) = $future->resolve();
if ($err) {
return null;
}
$result = array();
$lines = phutil_split_lines($stdout);
foreach ($lines as $line) {
list($commit) = explode(' ', $line, 2);
$result[] = $commit;
}
return $result;
}
示例11: run
public function run()
{
$working_copy = $this->getWorkingCopy();
$this->projectRoot = $working_copy->getProjectRoot();
$future = new ExecFuture('npm run coverage');
$future->setCWD($this->projectRoot);
list($err, $stdout, $stderr) = $future->resolve();
$result = new ArcanistUnitTestResult();
$result->setName("Node test engine");
$result->setUserData($stdout);
if ($err) {
$result->setResult(ArcanistUnitTestResult::RESULT_FAIL);
} else {
$result->setResult(ArcanistUnitTestResult::RESULT_PASS);
}
return array($result);
}
示例12: resolveBlameFuture
protected function resolveBlameFuture(ExecFuture $future)
{
list($err, $stdout) = $future->resolve();
if ($err) {
return null;
}
$result = array();
$matches = null;
$lines = phutil_split_lines($stdout);
foreach ($lines as $line) {
if (preg_match('/^\\s*(\\d+)/', $line, $matches)) {
$result[] = (int) $matches[1];
} else {
$result[] = null;
}
}
return $result;
}
示例13: transformResource
public function transformResource($path, $data)
{
$type = self::getResourceType($path);
switch ($type) {
case 'css':
$data = preg_replace_callback('@url\\s*\\((\\s*[\'"]?/rsrc/.*?)\\)@s', array($this, 'translateResourceURI'), $data);
break;
}
if (!$this->minify) {
return $data;
}
// Some resources won't survive minification (like Raphael.js), and are
// marked so as not to be minified.
if (strpos($data, '@' . 'do-not-minify') !== false) {
return $data;
}
switch ($type) {
case 'css':
// Remove comments.
$data = preg_replace('@/\\*.*?\\*/@s', '', $data);
// Remove whitespace around symbols.
$data = preg_replace('@\\s*([{}:;,])\\s*@', '\\1', $data);
// Remove unnecessary semicolons.
$data = preg_replace('@;}@', '}', $data);
// Replace #rrggbb with #rgb when possible.
$data = preg_replace('@#([a-f0-9])\\1([a-f0-9])\\2([a-f0-9])\\3@i', '#\\1\\2\\3', $data);
$data = trim($data);
break;
case 'js':
$root = dirname(phutil_get_library_root('phabricator'));
$bin = $root . '/externals/javelin/support/jsxmin/jsxmin';
if (@file_exists($bin)) {
$future = new ExecFuture("{$bin} __DEV__:0");
$future->write($data);
list($err, $result) = $future->resolve();
if (!$err) {
$data = $result;
}
}
break;
}
return $data;
}
示例14: lintPath
public function lintPath($path)
{
$flake8_bin = $this->getFlake8Path();
$options = $this->getFlake8Options();
$f = new ExecFuture("%C %C -", $flake8_bin, $options);
$f->write($this->getData($path));
list($err, $stdout, $stderr) = $f->resolve();
if ($err === 2) {
throw new Exception("flake8 failed to run correctly:\n" . $stderr);
}
$lines = explode("\n", $stdout);
$messages = array();
foreach ($lines as $line) {
$matches = null;
// stdin:2: W802 undefined name 'foo' # pyflakes
// stdin:3:1: E302 expected 2 blank lines, found 1 # pep8
if (!preg_match('/^(.*?):(\\d+):(?:(\\d+):)? (\\S+) (.*)$/', $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
if (substr($matches[4], 0, 1) == 'E') {
$severity = ArcanistLintSeverity::SEVERITY_ERROR;
} else {
$severity = ArcanistLintSeverity::SEVERITY_WARNING;
}
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[2]);
if (!empty($matches[3])) {
$message->setChar($matches[3]);
}
$message->setCode($matches[4]);
$message->setName($this->getLinterName() . ' ' . $matches[3]);
$message->setDescription($matches[5]);
$message->setSeverity($severity);
$this->addLintMessage($message);
}
}
示例15: lintPath
public function lintPath($path)
{
$this->checkBinaryConfiguration();
$data = $this->getData($path);
$future = new ExecFuture('%C', $this->getBinary());
$future->write($data);
list($err, $stdout, $stderr) = $future->resolve();
if (empty($stdout) && $err) {
throw new Exception(sprintf("%s\n\nSTDOUT\n%s\n\nSTDERR\n%s", pht($this->getLinterName() . ' failed to parse output!'), $stdout, $stderr));
}
if ($stdout !== $data) {
$lines = explode("\n", $data);
$formatted_lines = explode("\n", $stdout);
foreach ($lines as $line_idx => $line) {
if ($line != $formatted_lines[$line_idx]) {
$lines = array_slice($lines, $line_idx);
$formatted_lines = array_slice($formatted_lines, $line_idx);
break;
}
}
$this->raiseLintAtLine($line_idx + 1, 1, self::LINT_GO_UNFORMATTED, pht('%s was not formatted correctly. Please setup your ' . 'editor to run gofmt on save', $path), implode("\n", $lines), implode("\n", $formatted_lines));
}
}