Ejemplo n.º 1
0
 public function test_kill()
 {
     $start = time();
     $process = Process::make(Command::make('sleep')->withArgs(5))->runAsync();
     usleep(100000);
     $process->kill();
     $this->assertLessThan(5, time() - $start);
     $this->assertEquals(SIGTERM, $process->getSignal());
 }
Ejemplo n.º 2
0
 /**
  * @param $command
  * @param array $args
  * @param array $options
  * @param array $paths
  * @param Closure $onSuccess
  * @param Closure $onError
  * @return Process
  */
 protected final function buildProcess($command, array $args = [], array $options = [], array $paths = [], Closure $onSuccess = null, Closure $onError = null)
 {
     if (in_array($command, static::$subcommands)) {
         list($command, $subcommand) = explode('-', $command);
         array_unshift($args, $subcommand);
     }
     array_unshift($args, $command);
     if (!empty($paths)) {
         $options['--'] = $paths;
     }
     $cmd = Command::make('git')->withArgs($args)->withOptions($options);
     return Process::make($cmd, $this->output)->usingCwd($this->project_dir)->onError($onError)->onSuccess($onSuccess);
 }
Ejemplo n.º 3
0
 public function test_serialize_nameless_option()
 {
     $options = ['--' => ['/tmp/1.txt', '/tmp/2.txt']];
     $cmd = new Command($_SERVER['PHP_SELF'], [], $options);
     $this->assertEquals("{$_SERVER['PHP_SELF']} -- /tmp/1.txt /tmp/2.txt", $cmd->serialize());
 }