Permalink
Browse files

MDL-34147 use cygwin style paths in phpunit hints

  • Loading branch information...
1 parent f2867a8 commit 880f8e7b84d495cc629474c3a67dba60bf96e409 @skodak skodak committed Jul 3, 2012
Showing with 24 additions and 3 deletions.
  1. +1 −1 admin/tool/phpunit/cli/util.php
  2. +16 −1 lib/phpunit/bootstraplib.php
  3. +7 −1 lib/phpunit/classes/hint_resultprinter.php
@@ -123,7 +123,7 @@
-h, --help Print out this help
Example:
-\$/usr/bin/php lib/phpunit/tool.php --install
+\$ php ".phpunit_bootstrap_cli_argument_path('/admin/tool/phpunit/cli/util.php')." --install
";
echo $help;
exit(0);
@@ -101,7 +101,11 @@ function phpunit_bootstrap_cli_argument_path($moodlepath) {
$path = realpath($CFG->dirroot.$moodlepath);
if (strpos($path, $cwd) === 0) {
- return substr($path, strlen($cwd));
+ $path = substr($path, strlen($cwd));
+ }
+
+ if (phpunit_bootstrap_is_cygwin()) {
+ $path = str_replace('\\', '/', $path);
}
return $path;
@@ -140,3 +144,14 @@ function phpunit_boostrap_fix_file_permissions($file) {
return true;
}
+
+/**
+ * Find out if running under Cygwin on Windows.
+ * @return bool
+ */
+function phpunit_bootstrap_is_cygwin() {
+ if (empty($_SERVER['SHELL']) or empty($_SERVER['OS'])) {
+ return false;
+ }
+ return ($_SERVER['OS'] === 'Windows_NT' and $_SERVER['SHELL'] === '/bin/bash');
+}
@@ -74,6 +74,12 @@ protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect) {
$file = substr($file, strlen($cwd)+1);
}
- $this->write("\nTo re-run:\n phpunit $testName $file\n");
+ $executable = 'phpunit';
+ if (phpunit_bootstrap_is_cygwin()) {
+ $file = str_replace('\\', '/', $file);
+ $executable = 'phpunit.bat';
+ }
+
+ $this->write("\nTo re-run:\n $executable $testName $file\n");
}
}

0 comments on commit 880f8e7

Please sign in to comment.