Ejemplo n.º 1
0
 public function execute()
 {
     if (!isset($this->options['executable'])) {
         $this->error('Tester executable is not defined.');
     }
     $cmd = '';
     $cmd .= escapeshellarg($this->options['executable']) . ' ';
     $cmd .= '-s ';
     // show skipped tests
     $cmd .= escapeshellarg($this->target) . ' ';
     $optionalSwitches = ['iniFile' => '-c', 'interpreter' => '-p', 'threads' => '-j', 'mode' => '-o'];
     foreach ($optionalSwitches as $name => $switch) {
         if (isset($this->options[$name])) {
             $cmd .= $switch . ' ';
             $cmd .= escapeshellarg($this->options[$name]) . ' ';
         }
     }
     $currdir = getcwd();
     $result = @chdir($this->workingDir);
     if (!$result) {
         $this->error("Cannot change working directory to '{$this->workingDir}'.");
     }
     $command = new Exec();
     $command->setCommand($cmd);
     $result = $command->execute();
     if ($result->getResult() !== 0) {
         $this->error(sprintf('Tests failed with code %d.', $result->getResult()));
     }
     $result = @chdir($currdir);
     if (!$result) {
         $this->error("Cannot change working directory back to '{$currdir}'.");
     }
 }
Ejemplo n.º 2
0
 public function execute()
 {
     if (!isset($this->options['executable'])) {
         $this->error('PHPUnit executable not defined.');
     }
     $cmd = '';
     if (isset($this->options['xdebugExtensionFile'])) {
         if (!is_file($this->options['xdebugExtensionFile'])) {
             // PHP is quite when extension file does not exists
             $this->error("Xdebug extension file '{$this->options['xdebugExtensionFile']}' does not exists.");
         }
         $cmd .= 'php -d zend_extension=' . escapeshellarg($this->options['xdebugExtensionFile']) . ' ';
     }
     $cmd .= escapeshellarg($this->options['executable']) . ' ';
     $cmd .= escapeshellarg($this->target) . ' ';
     $options = ['configFile' => '--configuration'];
     foreach ($options as $name => $switch) {
         if (isset($this->options[$name])) {
             $cmd .= $switch . ' ';
             $cmd .= escapeshellarg($this->options[$name]) . ' ';
         }
     }
     $currdir = getcwd();
     $result = @chdir($this->workingDir);
     if (!$result) {
         $this->error("Cannot change working directory to '{$this->workingDir}'.");
     }
     $command = new Exec();
     $command->setCommand($cmd);
     $result = $command->execute();
     if ($result->getResult() !== 0) {
         $this->error(sprintf('Tests failed with code %d.', $result->getResult()));
     }
     $result = @chdir($currdir);
     if (!$result) {
         $this->error("Cannot change working directory back to '{$currdir}'.");
     }
 }