コード例 #1
0
 /**
  * Executes the given command via shell and returns the complete output as
  * a string
  *
  * @param string $command
  *
  * @return array(status, stdout, stderr)
  */
 protected function executeCommand($command)
 {
     if (class_exists('Symfony\\Component\\Process\\Process')) {
         $process = new \Symfony\Component\Process\Process($command, $this->env);
         if ($this->timeout !== false) {
             $process->setTimeout($this->timeout);
         }
     } else {
         $process = new Process($command, $this->env);
     }
     $process->run();
     return array($process->getExitCode(), $process->getOutput(), $process->getErrorOutput());
 }
コード例 #2
0
 /**
  * Executes the given command via shell and returns the complete output as
  * a string
  *
  * @param string $command
  *
  * @return array(status, stdout, stderr)
  */
 protected function executeCommand($command)
 {
     $process = new Process($command, null, $this->env);
     if (false !== $this->timeout) {
         $process->setTimeout($this->timeout);
     }
     $process->run();
     return array($process->getExitCode(), $process->getOutput(), $process->getErrorOutput());
 }
コード例 #3
0
/**
 * Print update progress as dots for updating feature file step list.
 *
 * @param Process $process process executing update step command.
 * @param string $featurestepfile feature step file in which steps will be saved.
 * @return int exitcode.
 */
function print_update_step_output($process, $featurestepfile)
{
    $printedlength = 0;
    echo "Updating steps feature file for parallel behat runs" . PHP_EOL;
    // Show progress while running command.
    while ($process->isRunning()) {
        usleep(10000);
        $op = $process->getIncrementalOutput();
        if (trim($op)) {
            echo ".";
            $printedlength++;
            if ($printedlength > 70) {
                $printedlength = 0;
                echo PHP_EOL;
            }
        }
    }
    // If any error then exit.
    $exitcode = $process->getExitCode();
    // Output err.
    if ($exitcode != 0) {
        echo $process->getErrorOutput();
        exit($exitcode);
    }
    // Extract features with step info and save it in file.
    $featuresteps = $process->getOutput();
    $featuresteps = explode(PHP_EOL, $featuresteps);
    $realroot = realpath(__DIR__ . '/../../../../') . '/';
    foreach ($featuresteps as $featurestep) {
        if (trim($featurestep)) {
            $step = explode("::", $featurestep);
            $step[0] = str_replace($realroot, '', $step[0]);
            $steps[$step[0]] = $step[1];
        }
    }
    arsort($steps);
    if (!@file_put_contents($featurestepfile, json_encode($steps, JSON_PRETTY_PRINT))) {
        behat_error(BEHAT_EXITCODE_PERMISSIONS, 'File ' . $featurestepfile . ' can not be created');
        $exitcode = -1;
    }
    echo PHP_EOL . "Updated step count in " . $featurestepfile . PHP_EOL;
    return $exitcode;
}
コード例 #4
0
ファイル: AbstractGenerator.php プロジェクト: jxav/paintstrap
 /**
  * Executes the given command via shell and returns the complete output as
  * a string
  *
  * @param  string $command
  *
  * @return array(status, stdout, stderr)
  */
 protected function executeCommand($command)
 {
     if (class_exists('Symfony\\Component\\Process\\Process')) {
         $process = new \Symfony\Component\Process\Process($command);
     } else {
         $process = new Process($command);
     }
     $process->run();
     return array($process->getExitCode(), $process->getOutput(), $process->getErrorOutput());
 }