public function hugeStderr()
 {
     $p = new Process($this->executable(), array('-r', 'fputs(STDERR, str_repeat("*", 65536));'));
     $err = '';
     while (!$p->err->eof()) {
         $err .= $p->err->read();
     }
     $p->close();
     $this->assertEquals(65536, strlen($err));
 }
示例#2
0
 /**
  * Produce diff between the contents
  *
  * @param   string left
  * @param   string right
  */
 protected function diff($left, $right)
 {
     with($templ = (new TempFile())->open(File::WRITE), $tempr = (new TempFile())->open(File::WRITE));
     $templ->write($left);
     $tempr->write($right);
     $templ->close();
     $tempr->close();
     // TODO: Implement "diff" in userland
     try {
         $p = new Process(sprintf('diff -u %s %s', $templ->getURI(), $tempr->getURI()));
         $p->in->close();
         while (!$p->out->eof()) {
             $this->out->writeLine($p->out->readLine());
         }
         $p->close();
     } catch (IOException $e) {
         $this->err->writeLine('!=> Invocation of `diff` program failed.');
         $templ->unlink();
         $tempr->unlink();
         return;
     }
     $templ->unlink();
     $tempr->unlink();
 }
 public function resolve()
 {
     $this->assertEquals('/bin/ls', Process::resolve('ls'));
 }
示例#4
0
 /**
  * Retrieve the executable associated with this runtime.
  *
  * @return  lang.Process
  */
 public function getExecutable()
 {
     if (null === $this->executable) {
         // Lazy-init
         $this->executable = Process::getProcessById(getmypid(), defined('PHP_BINARY') ? constant('PHP_BINARY') : null);
     }
     return $this->executable;
 }