Exemplo n.º 1
0
 protected function detectProcessorNumberByGrep()
 {
     if (Utils::findBin('grep') && file_exists('/proc/cpuinfo')) {
         $process = new Process('grep -c ^processor /proc/cpuinfo 2>/dev/null');
         $process->run();
         $this->processorNumber = intval($process->getOutput());
         return $this->processorNumber;
     }
     return;
 }
 /**
  * Blocks until call is complete.
  *
  * @throws \Exception        If this function is called before start()
  * @throws \RuntimeException
  *
  * @return string
  */
 public function wait()
 {
     if ($this->processAsync == null) {
         throw new \Exception('You must run `start` before running `wait`');
     }
     // blocks here until process completes
     $this->processAsync->wait();
     if (!$this->processAsync->isSuccessful()) {
         throw new \RuntimeException($this->processAsync->getErrorOutput());
     }
     return $this->processAsync->getOutput();
 }
 /**
  * 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());
 }
Exemplo n.º 4
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;
}
 /**
  * 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());
 }
Exemplo n.º 6
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);
     } else {
         $process = new Process($command);
     }
     $process->run();
     return array($process->getExitCode(), $process->getOutput(), $process->getErrorOutput());
 }