From a7f202de4e0e7cf2018d3d80ebf79922d74e3a9d Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Tue, 16 Aug 2016 14:57:02 +0800 Subject: [PATCH] MDL-55379 phpunit: Fixed hint_result for rerun --- lib/phpunit/classes/hint_resultprinter.php | 27 +++++++++++----------- lib/testing/lib.php | 8 +++++-- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/lib/phpunit/classes/hint_resultprinter.php b/lib/phpunit/classes/hint_resultprinter.php index 51d941621e8..0a92712e9d1 100644 --- a/lib/phpunit/classes/hint_resultprinter.php +++ b/lib/phpunit/classes/hint_resultprinter.php @@ -88,32 +88,33 @@ class Hint_ResultPrinter extends PHPUnit_TextUI_ResultPrinter { $file = substr($file, strlen($cwd)+1); } - $executable = null; + $pathprefix = testing_cli_argument_path('/'); + if ($pathprefix) { + $pathprefix .= DIRECTORY_SEPARATOR; + } + // There is only vendor/bin/phpunit executable. There is no .cmd or .bat files. + $executable = $pathprefix . 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'phpunit'; + + if (testing_is_cygwin()) { + $file = str_replace('\\', '/', $file); + $executable = str_replace('\\', '/', $executable); + } + + // Add server arguments to the rerun if passed. if (isset($_SERVER['argv'][0])) { if (preg_match('/phpunit(\.bat|\.cmd)?$/', $_SERVER['argv'][0])) { - $executable = $_SERVER['argv'][0]; for($i=1;$iwrite("\nTo re-run:\n $executable $testName $file\n"); } } diff --git a/lib/testing/lib.php b/lib/testing/lib.php index 999a5008bc9..cef731adf8c 100644 --- a/lib/testing/lib.php +++ b/lib/testing/lib.php @@ -52,13 +52,17 @@ function testing_cli_argument_path($moodlepath) { // This is the real CLI script, work with relative paths. $cwd = getcwd(); } + + // In sub path, we want to remove leading Directory separator. + $removeseparator = 0; if (substr($cwd, -1) !== DIRECTORY_SEPARATOR) { - $cwd .= DIRECTORY_SEPARATOR; + $removeseparator = 1; } + $path = realpath($CFG->dirroot.$moodlepath); if (strpos($path, $cwd) === 0) { - $path = substr($path, strlen($cwd)); + $path = substr($path, strlen($cwd) + $removeseparator); } if (testing_is_cygwin()) {