Ejemplo n.º 1
0
 /**
  * @param \Stagehand\TestRunner\Notification\Notification $notification
  *
  * @return string
  */
 protected function buildNotifyCommand(Notification $notification)
 {
     if ($notification->isPassed()) {
         $title = self::TITLE_PASSED;
         $icon = self::$ICON_PASSED;
         $sound = self::SOUND_PASSED;
     } elseif ($notification->isFailed()) {
         $title = self::TITLE_FAILED;
         $icon = self::$ICON_FAILED;
         $sound = self::SOUND_FAILED;
     } elseif ($notification->isStopped()) {
         $title = self::TITLE_STOPPED;
         $icon = self::$ICON_STOPPED;
         $sound = self::SOUND_STOPPED;
     }
     if ($this->os->isWin()) {
         return sprintf('growlnotify /t:%s /p:-2 /i:%s /a:Stagehand_TestRunner /r:%s,%s,%s /n:%s /silent:true %s', escapeshellarg($title), escapeshellarg($icon), escapeshellarg(self::TITLE_PASSED), escapeshellarg(self::TITLE_FAILED), escapeshellarg(self::TITLE_STOPPED), escapeshellarg($title), escapeshellarg($notification->getMessage()));
     } elseif ($this->os->isAfterMarvericks() && !$this->hasGrowl('osascript')) {
         return sprintf('osascript -e "display notification \\"%s\\" subtitle \\"%s\\" sound name \\"%s\\""', escapeshellarg($notification->getMessage()), escapeshellcmd($title), escapeshellcmd($sound));
     } elseif ($this->os->isDarwin()) {
         return sprintf('growlnotify --name %s --priority -2 --image %s --title %s --message %s', escapeshellarg($title), escapeshellarg($icon), escapeshellarg($title), escapeshellarg($notification->getMessage()));
     } elseif ($this->os->isLinux()) {
         return sprintf('notify-send --urgency=low --icon=%s %s %s', escapeshellarg($icon), escapeshellarg($title), escapeshellarg(str_replace('\\', '\\\\', $notification->getMessage())));
     }
 }
 /**
  * @return string
  */
 protected function buildCommand()
 {
     if (array_key_exists('_', $_SERVER)) {
         $command = $_SERVER['_'];
     } elseif (array_key_exists('PHP_COMMAND', $_SERVER)) {
         $command = $_SERVER['PHP_COMMAND'];
     } else {
         $command = $_SERVER['argv'][0];
     }
     if (preg_match('!^/cygdrive/([a-z])/(.+)!', $command, $matches)) {
         $command = $matches[1] . ':\\' . str_replace('/', '\\', $matches[2]);
     }
     if ($this->os->isWin()) {
         putenv(sprintf('ENVPATH="%s"', $command));
         return '%ENVPATH%';
     } else {
         return escapeshellarg($command);
     }
 }
Ejemplo n.º 3
0
 /**
  * @param \Stagehand\TestRunner\Notification\Notification $notification
  * @return string
  */
 protected function buildNotifyCommand(Notification $notification)
 {
     if ($notification->isPassed()) {
         $title = self::TITLE_PASSED;
         $icon = self::$ICON_PASSED;
     } elseif ($notification->isFailed()) {
         $title = self::TITLE_FAILED;
         $icon = self::$ICON_FAILED;
     } elseif ($notification->isStopped()) {
         $title = self::TITLE_STOPPED;
         $icon = self::$ICON_STOPPED;
     }
     if ($this->os->isWin()) {
         return sprintf('growlnotify /t:%s /p:-2 /i:%s /a:Stagehand_TestRunner /r:%s,%s,%s /n:%s /silent:true %s', escapeshellarg($title), escapeshellarg($icon), escapeshellarg(self::TITLE_PASSED), escapeshellarg(self::TITLE_FAILED), escapeshellarg(self::TITLE_STOPPED), escapeshellarg($title), escapeshellarg($notification->getMessage()));
     } elseif ($this->os->isDarwin()) {
         return sprintf('growlnotify --name %s --priority -2 --image %s --title %s --message %s', escapeshellarg($title), escapeshellarg($icon), escapeshellarg($title), escapeshellarg($notification->getMessage()));
     } elseif ($this->os->isLinux()) {
         return sprintf('notify-send --urgency=low --icon=%s %s %s', escapeshellarg($icon), escapeshellarg($title), escapeshellarg(str_replace('\\', '\\\\', $notification->getMessage())));
     }
 }
 /**
  * @param string $commandLine
  *
  * @since Method available since Release 2.18.0
  */
 public function runTests($commandLine)
 {
     $streamOutput = '';
     if ($this->os->isWin()) {
         // TODO: Remove Windows specific code if the bug #60120 and #51800 are really fixed.
         ob_start(function ($buffer) use(&$streamOutput) {
             $streamOutput .= $buffer;
             return $buffer;
         }, 2);
         passthru($commandLine, $exitStatus);
         ob_end_flush();
     } else {
         $process = new Process($commandLine);
         $process->setTimeout(60);
         $exitStatus = $process->run(function ($type, $data) {
             echo $data;
         });
         $streamOutput = $process->getOutput();
     }
     if ($exitStatus != 0 && $this->runner->shouldNotify()) {
         $fatalError = new FatalError($streamOutput);
         $this->notifier->notifyResult(new Notification(Notification::RESULT_STOPPED, $fatalError->getFullMessage()));
     }
 }