/**
  * Returns the executable path
  *
  * Allows returning a customized command for cygwin when the
  * command is just displayed, when using exec(), system() and
  * friends we stay with DIRECTORY_SEPARATOR as they use the
  * normal cmd.exe (in Windows).
  *
  * @param  bool $custombyterm  If the provided command should depend on the terminal where it runs
  * @return string
  */
 public static final function get_behat_command($custombyterm = false)
 {
     $separator = DIRECTORY_SEPARATOR;
     $exec = 'behat';
     // Cygwin uses linux-style directory separators.
     if ($custombyterm && testing_is_cygwin()) {
         $separator = '/';
         // MinGW can not execute .bat scripts.
         if (!testing_is_mingw()) {
             $exec = 'behat.bat';
         }
     }
     return 'vendor' . $separator . 'bin' . $separator . $exec;
 }
 protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect)
 {
     global $CFG;
     parent::printDefectTrace($defect);
     $failedTest = $defect->failedTest();
     $testName = get_class($failedTest);
     $exception = $defect->thrownException();
     $trace = $exception->getTrace();
     if (class_exists('ReflectionClass')) {
         $reflection = new ReflectionClass($testName);
         $file = $reflection->getFileName();
     } else {
         $file = false;
         $dirroot = realpath($CFG->dirroot) . DIRECTORY_SEPARATOR;
         $classpath = realpath("{$CFG->dirroot}/lib/phpunit/classes") . DIRECTORY_SEPARATOR;
         foreach ($trace as $item) {
             if (strpos($item['file'], $dirroot) === 0 and strpos($item['file'], $classpath) !== 0) {
                 if ($content = file_get_contents($item['file'])) {
                     if (preg_match('/class\\s+' . $testName . '\\s+extends/', $content)) {
                         $file = $item['file'];
                         break;
                     }
                 }
             }
         }
     }
     if ($file === false) {
         return;
     }
     $cwd = getcwd();
     if (strpos($file, $cwd) === 0) {
         $file = substr($file, strlen($cwd) + 1);
     }
     $executable = null;
     if (isset($_SERVER['argv'][0])) {
         if (preg_match('/phpunit(\\.bat|\\.cmd)?$/', $_SERVER['argv'][0])) {
             $executable = $_SERVER['argv'][0];
             for ($i = 1; $i < count($_SERVER['argv']); $i++) {
                 if (!isset($_SERVER['argv'][$i])) {
                     break;
                 }
                 if (in_array($_SERVER['argv'][$i], array('--colors', '--verbose', '-v', '--debug', '--strict'))) {
                     $executable .= ' ' . $_SERVER['argv'][$i];
                 }
             }
         }
     }
     if (!$executable) {
         $executable = 'phpunit';
         if (testing_is_cygwin()) {
             $file = str_replace('\\', '/', $file);
             if (!testing_is_mingw()) {
                 $executable = 'phpunit.bat';
             }
         }
     }
     $this->write("\nTo re-run:\n {$executable} {$testName} {$file}\n");
 }
示例#3
0
 /**
  * Returns the executable path
  *
  * Allows returning a customized command for cygwin when the
  * command is just displayed, when using exec(), system() and
  * friends we stay with DIRECTORY_SEPARATOR as they use the
  * normal cmd.exe (in Windows).
  *
  * @param  bool $custombyterm  If the provided command should depend on the terminal where it runs
  * @param bool $parallelrun If parallel run is installed.
  * @param bool $absolutepath return command with absolute path.
  * @return string
  */
 public static final function get_behat_command($custombyterm = false, $parallerun = false, $absolutepath = false)
 {
     $separator = DIRECTORY_SEPARATOR;
     $exec = 'behat';
     // Cygwin uses linux-style directory separators.
     if ($custombyterm && testing_is_cygwin()) {
         $separator = '/';
         // MinGW can not execute .bat scripts.
         if (!testing_is_mingw()) {
             $exec = 'behat.bat';
         }
     }
     // If relative path then prefix relative path.
     if ($absolutepath) {
         $pathprefix = testing_cli_argument_path('/') . $separator;
     } else {
         $pathprefix = '';
     }
     if (!$parallerun) {
         $command = $pathprefix . 'vendor' . $separator . 'bin' . $separator . $exec;
     } else {
         $command = 'php ' . $pathprefix . 'admin' . $separator . 'tool' . $separator . 'behat' . $separator . 'cli' . $separator . 'run.php';
     }
     return $command;
 }
示例#4
0
 /**
  * Returns the executable path
  *
  * Allows returning a customized command for cygwin when the
  * command is just displayed, when using exec(), system() and
  * friends we stay with DIRECTORY_SEPARATOR as they use the
  * normal cmd.exe (in Windows).
  *
  * @param  bool $custombyterm  If the provided command should depend on the terminal where it runs
  * @param bool $parallelrun If parallel run is installed.
  * @return string
  */
 public static final function get_behat_command($custombyterm = false, $parallerun = false)
 {
     $separator = DIRECTORY_SEPARATOR;
     if (!$parallerun) {
         $exec = 'behat';
         // Cygwin uses linux-style directory separators.
         if ($custombyterm && testing_is_cygwin()) {
             $separator = '/';
             // MinGW can not execute .bat scripts.
             if (!testing_is_mingw()) {
                 $exec = 'behat.bat';
             }
         }
         $command = 'vendor' . $separator . 'bin' . $separator . $exec;
     } else {
         $command = 'php admin' . $separator . 'tool' . $separator . 'behat' . $separator . 'cli' . $separator . 'run.php';
     }
     return $command;
 }