本文整理汇总了PHP中ExecFuture::resolvex方法的典型用法代码示例。如果您正苦于以下问题:PHP ExecFuture::resolvex方法的具体用法?PHP ExecFuture::resolvex怎么用?PHP ExecFuture::resolvex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecFuture
的用法示例。
在下文中一共展示了ExecFuture::resolvex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: lintPath
public function lintPath($path)
{
$working_copy = $this->getEngine()->getWorkingCopy();
$pyflakes_path = $working_copy->getConfig('lint.pyflakes.path');
$pyflakes_prefix = $working_copy->getConfig('lint.pyflakes.prefix');
// Default to just finding pyflakes in the users path
$pyflakes_bin = 'pyflakes';
$python_path = '';
// If a pyflakes path was specified, then just use that as the
// pyflakes binary and assume that the libraries will be imported
// correctly.
//
// If no pyflakes path was specified and a pyflakes prefix was
// specified, then use the binary from this prefix and add it to
// the PYTHONPATH environment variable so that the libs are imported
// correctly. This is useful when pyflakes is installed into a
// non-default location.
if ($pyflakes_path !== null) {
$pyflakes_bin = $pyflakes_path;
} else {
if ($pyflakes_prefix !== null) {
$pyflakes_bin = $pyflakes_prefix . '/bin/pyflakes';
$python_path = $pyflakes_prefix . '/lib/python2.6/site-packages:';
}
}
$options = $this->getPyFlakesOptions();
$f = new ExecFuture("/usr/bin/env PYTHONPATH=%s\$PYTHONPATH " . "{$pyflakes_bin} {$options}", $python_path);
$f->write($this->getData($path));
try {
list($stdout, $_) = $f->resolvex();
} catch (CommandException $e) {
// PyFlakes will return an exit code of 1 if warnings/errors
// are found but print nothing to stderr in this case. Therefore,
// if we see any output on stderr or a return code other than 1 or 0,
// pyflakes failed.
if ($e->getError() !== 1 || $e->getStderr() !== '') {
throw $e;
} else {
$stdout = $e->getStdout();
}
}
$lines = explode("\n", $stdout);
$messages = array();
foreach ($lines as $line) {
$matches = null;
if (!preg_match('/^(.*?):(\\d+): (.*)$/', $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[2]);
$message->setCode($this->getLinterName());
$message->setDescription($matches[3]);
$message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
$this->addLintMessage($message);
}
}
示例2: findMavenDirectories
/**
* Returns an array of the full canonical paths to all the Maven directories
* (directories containing pom.xml files) in the project.
*/
private function findMavenDirectories()
{
if (file_exists($this->project_root . "/.git")) {
// The fastest way to find all the pom.xml files is to let git scan
// its index.
$future = new ExecFuture('git ls-files \\*/pom.xml');
} else {
// Not a git repo. Do it the old-fashioned way.
$future = new ExecFuture('find . -name pom.xml -print');
}
// TODO: This will find *all* the pom.xml files in the working copy.
// Need to obey the optional paths argument to "arc unit" to let users
// run just a subset of tests.
$future->setCWD($this->project_root);
list($stdout) = $future->resolvex();
$poms = explode("\n", trim($stdout));
if (!$poms) {
throw new Exception("No pom.xml files found");
}
$maven_dirs = array_map(function ($pom) {
$maven_dir = dirname($pom);
return realpath($this->project_root . '/' . $maven_dir);
}, $poms);
return $maven_dirs;
}
示例3: runTests
private function runTests()
{
$root = $this->getWorkingCopy()->getProjectRoot();
$script = $this->getConfiguredScript();
$path = $this->getConfiguredTestResultPath();
foreach (glob($root . DIRECTORY_SEPARATOR . $path . "/*.xml") as $filename) {
// Remove existing files so we cannot report old results
$this->unlink($filename);
}
// Provide changed paths to process
putenv("ARCANIST_DIFF_PATHS=" . implode(PATH_SEPARATOR, $this->getPaths()));
$future = new ExecFuture('%C %s', $script, $path);
$future->setCWD($root);
$err = null;
try {
$future->resolvex();
} catch (CommandException $exc) {
$err = $exc;
}
$results = $this->parseTestResults($root . DIRECTORY_SEPARATOR . $path);
if ($err) {
$result = new ArcanistUnitTestResult();
$result->setName('Unit Test Script');
$result->setResult(ArcanistUnitTestResult::RESULT_BROKEN);
$result->setUserData("ERROR: Command failed with code {$err->getError()}\nCOMMAND: `{$err->getCommand()}`");
$results[] = $result;
}
return $results;
}
示例4: testMultipleResolves
public function testMultipleResolves()
{
// It should be safe to call resolve(), resolvex(), resolveKill(), etc.,
// as many times as you want on the same process.
$future = new ExecFuture('echo quack');
$future->resolve();
$future->resolvex();
list($err) = $future->resolveKill();
$this->assertEqual(0, $err);
}
示例5: run
public function run()
{
$working_copy = $this->getWorkingCopy();
$this->projectRoot = $working_copy->getProjectRoot();
$junit_tmp = new TempFile();
$cover_tmp = new TempFile();
$future = $this->buildTestFuture($junit_tmp, $cover_tmp);
$future->resolvex();
$future = new ExecFuture('coverage xml -o %s', $cover_tmp);
$future->setCWD($this->projectRoot);
$future->resolvex();
return $this->parseTestResults($junit_tmp, $cover_tmp);
}
示例6: testCloseExecWriteChannel
public function testCloseExecWriteChannel()
{
$future = new ExecFuture('cat');
// If this test breaks, we want to explode, not hang forever.
$future->setTimeout(5);
$exec_channel = new PhutilExecChannel($future);
$exec_channel->write('quack');
$exec_channel->closeWriteChannel();
// If `closeWriteChannel()` did what it is supposed to, this will just
// echo "quack" and exit with no error code. If the channel did not close,
// this will time out after 5 seconds and throw.
$future->resolvex();
$this->assertTrue(true);
}
示例7: checkRequirements
private function checkRequirements()
{
$working_copy = $this->getWorkingCopy();
$project_root = $working_copy->getProjectRoot();
$piplint_files = $this->getConfigurationManager()->getConfigFromAnySource('unit.piplint.files');
if (empty($piplint_files)) {
return;
}
$args = array('piplint');
$args = array_merge($args, $piplint_files);
$cmd = implode(' ', $args);
$future = new ExecFuture($cmd);
$future->setCWD($project_root);
$future->resolvex();
}
示例8: 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;
}
}
示例9: run
public function run()
{
$working_copy = $this->getWorkingCopy();
$this->projectRoot = $working_copy->getProjectRoot();
$junit_tmp = new TempFile();
$cover_tmp = new TempFile();
$future = $this->buildTestFuture($junit_tmp, $cover_tmp);
list($err, $stdout, $stderr) = $future->resolve();
if (!Filesystem::pathExists($junit_tmp)) {
throw new CommandException(pht('Command failed with error #%s!', $err), $future->getCommand(), $err, $stdout, $stderr);
}
$future = new ExecFuture('coverage xml -o %s', $cover_tmp);
$future->setCWD($this->projectRoot);
$future->resolvex();
return $this->parseTestResults($junit_tmp, $cover_tmp);
}
示例10: startProjectBuilds
public function startProjectBuilds($async, $diff_id = null)
{
// Push the source up to the master repo so that Jenkins
// can pull it down and build it
$gitcmd = "git push origin HEAD:refs/autobuilds/{$diff_id}";
$git_future = new ExecFuture($gitcmd);
$git_future->resolvex();
$url = $this->getJobURI();
// Initiate a git poll for the mysql jobs in Jenkins
$cmd = "curl --max-time 5 -s {$url}";
$future = new ExecFuture($cmd);
if ($async === true) {
echo "Launching a build on the Jenkins server...\n";
$future->resolvex();
}
}
示例11: newFromArcBundle
public static function newFromArcBundle($path)
{
$path = Filesystem::resolvePath($path);
$future = new ExecFuture(csprintf('tar tfO %s', $path));
list($stdout, $file_list) = $future->resolvex();
$file_list = explode("\n", trim($file_list));
if (in_array('meta.json', $file_list)) {
$future = new ExecFuture(csprintf('tar xfO %s meta.json', $path));
$meta_info = $future->resolveJSON();
$version = idx($meta_info, 'version', 0);
$project_name = idx($meta_info, 'projectName');
$base_revision = idx($meta_info, 'baseRevision');
$revision_id = idx($meta_info, 'revisionID');
$encoding = idx($meta_info, 'encoding');
// this arc bundle was probably made before we started storing meta info
} else {
$version = 0;
$project_name = null;
$base_revision = null;
$revision_id = null;
$encoding = null;
}
$future = new ExecFuture(csprintf('tar xfO %s changes.json', $path));
$changes = $future->resolveJSON();
foreach ($changes as $change_key => $change) {
foreach ($change['hunks'] as $key => $hunk) {
list($hunk_data) = execx('tar xfO %s hunks/%s', $path, $hunk['corpus']);
$changes[$change_key]['hunks'][$key]['corpus'] = $hunk_data;
}
}
foreach ($changes as $change_key => $change) {
$changes[$change_key] = ArcanistDiffChange::newFromDictionary($change);
}
$obj = new ArcanistBundle();
$obj->changes = $changes;
$obj->diskPath = $path;
$obj->setProjectID($project_name);
$obj->setBaseRevision($base_revision);
$obj->setRevisionID($revision_id);
$obj->setEncoding($encoding);
return $obj;
}
示例12: runTests
private function runTests()
{
$root = $this->getWorkingCopy()->getProjectRoot();
$script = $this->getConfiguredScript();
$path = $this->getConfiguredTestResultPath();
foreach (glob($path . "/*.xml") as $filename) {
// Remove existing files so we cannot report old results
$this->unlink($filename);
}
$future = new ExecFuture('%C %s', $script, $path);
$future->setCWD($root);
try {
$future->resolvex();
} catch (CommandException $exc) {
if ($exc->getError() != 0) {
throw $exc;
}
}
return $this->parseTestResults($path);
}
示例13: rebuildPackages
public static function rebuildPackages($root)
{
$packages = JavelinSyncSpec::getPackageMap();
$data = array();
foreach ($packages as $package => $items) {
$content = array();
foreach ($items as $item) {
if (empty($data[$item])) {
$data[$item] = Filesystem::readFile($root . '/src/' . $item);
}
$content[] = $data[$item];
}
$content = implode("\n\n", $content);
echo "Writing {$package}.dev.js...\n";
Filesystem::writeFile($root . '/pkg/' . $package . '.dev.js', $content);
echo "Writing {$package}.min.js...\n";
$exec = new ExecFuture($root . '/support/jsxmin/jsxmin __DEV__:0');
$exec->write($content);
list($stdout) = $exec->resolvex();
Filesystem::writeFile($root . '/pkg/' . $package . '.min.js', $stdout);
}
}
示例14: run
public function run()
{
$results = array();
$build_start = microtime(true);
$config_manager = $this->getConfigurationManager();
if ($this->getEnableCoverage() !== false) {
$command = $config_manager->getConfigFromAnySource('unit.engine.tap.cover');
} else {
$command = $config_manager->getConfigFromAnySource('unit.engine.tap.command');
}
$timeout = $config_manager->getConfigFromAnySource('unit.engine.tap.timeout');
if (!$timeout) {
$timeout = 15;
}
$future = new ExecFuture('%C', $command);
$future->setTimeout($timeout);
$result = new ArcanistUnitTestResult();
$result->setName($command ? $command : 'unknown');
try {
list($stdout, $stderr) = $future->resolvex();
$result->setResult(ArcanistUnitTestResult::RESULT_PASS);
if ($this->getEnableCoverage() !== false) {
$coverage = $this->readCoverage('coverage/cobertura-coverage.xml');
$result->setCoverage($coverage);
}
} catch (CommandException $exc) {
$result->setResult(ArcanistUnitTestResult::RESULT_FAIL);
if ($future->getWasKilledByTimeout()) {
print "Process stdout:\n" . $exc->getStdout() . "\nProcess stderr:\n" . $exc->getStderr() . "\nExceeded timeout of {$timeout} secs.\nMake unit tests faster.";
} else {
$result->setUserdata($exc->getStdout() . $exc->getStderr());
}
}
$result->setDuration(microtime(true) - $build_start);
$results[] = $result;
return $results;
}
示例15: launchDaemon
/**
* @task internal
*/
private function launchDaemon()
{
$root = dirname(phutil_get_library_root('arcanist'));
$bin = $root . '/scripts/hgdaemon/hgdaemon_server.php';
$proxy = new ExecFuture('%s %s --idle-limit 15 --quiet %C', $bin, $this->workingCopy, $this->skipHello ? '--skip-hello' : null);
$proxy->resolvex();
}