本文整理汇总了PHP中ExecFuture::setCWD方法的典型用法代码示例。如果您正苦于以下问题:PHP ExecFuture::setCWD方法的具体用法?PHP ExecFuture::setCWD怎么用?PHP ExecFuture::setCWD使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecFuture
的用法示例。
在下文中一共展示了ExecFuture::setCWD方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例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: buildTestFuture
public function buildTestFuture($junit_tmp, $cover_tmp)
{
$paths = $this->getPaths();
$config_manager = $this->getConfigurationManager();
$coverage_command = $config_manager->getConfigFromAnySource('unit.golang.command');
$cmd_line = csprintf($coverage_command, $junit_tmp, $cover_tmp);
$future = new ExecFuture('%C', $cmd_line);
$future->setCWD($this->projectRoot);
return $future;
}
示例4: 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);
}
示例5: __construct
public function __construct($sockname, $repo_root, $args, array $command)
{
$this->command = json_encode($command);
$console = PhutilConsole::getConsole();
$console->writeLog("cli query: %s\n", $this->command);
$future = new ExecFuture("%C {$args} -U %s %s %s %s %s", "{$repo_root}/watchman", $sockname, '--no-pretty', '--no-spawn', '--no-local', '-j');
$cwd = getcwd();
if (!$cwd) {
throw new Exception("can't figure out my cwd!?");
}
$future->setCWD($cwd);
$future->write($this->command . "\n");
parent::__construct($future);
}
示例6: 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;
}
}
示例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: 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);
}
示例9: 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);
}
示例10: 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);
}
示例11: buildTestFuture
/**
* Build the future for running a unit test. This can be overridden to enable
* support for code coverage via another tool.
*
* @param string Name of the test assembly.
* @return array The future, output filename and coverage filename
* stored in an array.
*/
protected function buildTestFuture($test_assembly)
{
// FIXME: Can't use TempFile here as xUnit doesn't like
// UNIX-style full paths. It sees the leading / as the
// start of an option flag, even when quoted.
$xunit_temp = Filesystem::readRandomCharacters(10) . '.results.xml';
if (file_exists($xunit_temp)) {
unlink($xunit_temp);
}
$future = new ExecFuture('%C %s /xml %s', trim($this->runtimeEngine . ' ' . $this->testEngine), $test_assembly, $xunit_temp);
$folder = Filesystem::resolvePath($this->projectRoot);
$future->setCWD($folder);
$combined = $folder . '/' . $xunit_temp;
if (phutil_is_windows()) {
$combined = $folder . '\\' . $xunit_temp;
}
return array($future, $combined, null);
}
示例12: launchDaemon
protected final function launchDaemon($class, array $argv, $debug)
{
$daemon = $this->findDaemonClass($class);
$console = PhutilConsole::getConsole();
if ($debug) {
if ($argv) {
$console->writeOut(pht("Launching daemon \"%s\" in debug mode (not daemonized) " . "with arguments %s.\n", $daemon, csprintf('%LR', $argv)));
} else {
$console->writeOut(pht("Launching daemon \"%s\" in debug mode (not daemonized).\n", $daemon));
}
} else {
if ($argv) {
$console->writeOut(pht("Launching daemon \"%s\" with arguments %s.\n", $daemon, csprintf('%LR', $argv)));
} else {
$console->writeOut(pht("Launching daemon \"%s\".\n", $daemon));
}
}
foreach ($argv as $key => $arg) {
$argv[$key] = escapeshellarg($arg);
}
$flags = array();
if ($debug || PhabricatorEnv::getEnvConfig('phd.trace')) {
$flags[] = '--trace';
}
if ($debug || PhabricatorEnv::getEnvConfig('phd.verbose')) {
$flags[] = '--verbose';
}
if (!$debug) {
$flags[] = '--daemonize';
}
if (!$debug) {
$log_file = $this->getLogDirectory() . '/daemons.log';
$flags[] = csprintf('--log=%s', $log_file);
}
$pid_dir = $this->getPIDDirectory();
// TODO: This should be a much better user experience.
Filesystem::assertExists($pid_dir);
Filesystem::assertIsDirectory($pid_dir);
Filesystem::assertWritable($pid_dir);
$flags[] = csprintf('--phd=%s', $pid_dir);
$command = csprintf('./phd-daemon %s %C %C', $daemon, implode(' ', $flags), implode(' ', $argv));
$phabricator_root = dirname(phutil_get_library_root('phabricator'));
$daemon_script_dir = $phabricator_root . '/scripts/daemon/';
if ($debug) {
// Don't terminate when the user sends ^C; it will be sent to the
// subprocess which will terminate normally.
pcntl_signal(SIGINT, array(__CLASS__, 'ignoreSignal'));
echo "\n phabricator/scripts/daemon/ \$ {$command}\n\n";
phutil_passthru('(cd %s && exec %C)', $daemon_script_dir, $command);
} else {
$future = new ExecFuture('exec %C', $command);
// Play games to keep 'ps' looking reasonable.
$future->setCWD($daemon_script_dir);
$future->resolvex();
}
}
示例13: buildAtomizerFutures
private function buildAtomizerFutures(array $file_atomizers)
{
$atomizers = array();
foreach ($file_atomizers as $file => $atomizer) {
$atomizers[$atomizer][] = $file;
}
$root = dirname(phutil_get_library_root('phabricator'));
$config_root = $this->getConfig('root');
$bar = id(new PhutilConsoleProgressBar())->setTotal(count($file_atomizers));
$futures = array();
foreach ($atomizers as $class => $files) {
foreach (array_chunk($files, 32) as $chunk) {
$future = new ExecFuture('%s atomize --ugly --book %s --atomizer %s -- %Ls', $root . '/bin/diviner', $this->getBookConfigPath(), $class, $chunk);
$future->setCWD($config_root);
$futures[] = $future;
$bar->update(count($chunk));
}
}
$bar->done();
return $futures;
}
示例14: buildFutures
protected final function buildFutures(array $paths)
{
$executable = $this->getExecutableCommand();
$bin = csprintf('%C %Ls', $executable, $this->getCommandFlags());
$futures = array();
foreach ($paths as $path) {
$disk_path = $this->getEngine()->getFilePathOnDisk($path);
$path_argument = $this->getPathArgumentForLinterFuture($disk_path);
$future = new ExecFuture('%C %C', $bin, $path_argument);
$future->setCWD($this->getProjectRoot());
$futures[$path] = $future;
}
return $futures;
}
示例15: resolveArcRule
/**
* Handle resolving "arc:*" rules.
*/
private function resolveArcRule($rule, $name, $source)
{
switch ($name) {
case 'verbose':
$this->verbose = true;
$this->log("Enabled verbose mode.");
break;
case 'prompt':
$reason = "it is what you typed when prompted.";
$this->api->setBaseCommitExplanation($reason);
return phutil_console_prompt('Against which commit?');
case 'local':
case 'global':
case 'project':
case 'args':
case 'system':
// Push the other source on top of the list.
array_unshift($this->try, $name);
$this->log("Switching to source '{$name}'.");
return false;
case 'yield':
// Cycle this source to the end of the list.
$this->try[] = array_shift($this->try);
$this->log("Yielding processing of rules from '{$source}'.");
return false;
case 'halt':
// Dump the whole stack.
$this->try = array();
$this->log("Halting all rule processing.");
return false;
case 'skip':
return null;
case 'empty':
case 'upstream':
case 'outgoing':
case 'bookmark':
case 'amended':
case 'this':
return $this->api->resolveBaseCommitRule($rule, $source);
default:
$matches = null;
if (preg_match('/^exec\\((.*)\\)$/', $name, $matches)) {
$root = $this->api->getWorkingCopyIdentity()->getProjectRoot();
$future = new ExecFuture('%C', $matches[1]);
$future->setCWD($root);
list($err, $stdout) = $future->resolve();
if (!$err) {
return trim($stdout);
} else {
return null;
}
} else {
if (preg_match('/^nodiff\\((.*)\\)$/', $name, $matches)) {
return $this->api->resolveBaseCommitRule($rule, $source);
}
}
throw new ArcanistUsageException("Base commit rule '{$rule}' (from source '{$source}') " . "is not a recognized rule.");
}
}