mirror of
https://github.com/moodle/moodle.git
synced 2025-04-25 10:26:17 +02:00
Merge branch 'wip-mdl-55379' of https://github.com/rajeshtaneja/moodle
This commit is contained in:
commit
0f4b338fbb
@ -365,12 +365,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
|
||||
|
||||
$behatconfigutil = $this->behatconfigutil;
|
||||
// Fix expected directory path for OS.
|
||||
$cleanfeaturepath = str_replace('\\', DIRECTORY_SEPARATOR, $cleanfeaturepath);
|
||||
$cleanfeaturepath = str_replace('/', DIRECTORY_SEPARATOR, $cleanfeaturepath);
|
||||
|
||||
if (testing_is_cygwin()) {
|
||||
$featurepath = str_replace('\\', '/', $cleanfeaturepath);
|
||||
}
|
||||
$cleanfeaturepath = testing_cli_fix_directory_separator($cleanfeaturepath);
|
||||
|
||||
list($retkey, $retcleanfeaturepath) = $behatconfigutil->get_clean_feature_key_and_path($featurepath);
|
||||
|
||||
|
@ -223,17 +223,13 @@ class behat_config_util {
|
||||
global $CFG;
|
||||
|
||||
// Fix directory path.
|
||||
$featurepath = str_replace('\\', DIRECTORY_SEPARATOR, $featurepath);
|
||||
$featurepath = str_replace('/', DIRECTORY_SEPARATOR, $featurepath);
|
||||
|
||||
if (testing_is_cygwin()) {
|
||||
$featurepath = str_replace('\\', '/', $featurepath);
|
||||
}
|
||||
$featurepath = testing_cli_fix_directory_separator($featurepath);
|
||||
$dirroot = testing_cli_fix_directory_separator($CFG->dirroot . DIRECTORY_SEPARATOR);
|
||||
|
||||
$key = basename($featurepath, '.feature');
|
||||
|
||||
// Get relative path.
|
||||
$featuredirname = str_replace($CFG->dirroot . DIRECTORY_SEPARATOR , '', $featurepath);
|
||||
$featuredirname = str_replace($dirroot , '', $featurepath);
|
||||
// Get 5 levels of feature path to ensure we have a unique key.
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
if (($featuredirname = dirname($featuredirname)) && $featuredirname !== '.') {
|
||||
|
@ -86,34 +86,32 @@ class Hint_ResultPrinter extends PHPUnit_TextUI_ResultPrinter {
|
||||
$cwd = getcwd();
|
||||
if (strpos($file, $cwd) === 0) {
|
||||
$file = substr($file, strlen($cwd)+1);
|
||||
$file = testing_cli_fix_directory_separator($file);
|
||||
}
|
||||
|
||||
$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';
|
||||
$executable = testing_cli_fix_directory_separator($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;$i<count($_SERVER['argv']);$i++) {
|
||||
if (!isset($_SERVER['argv'][$i])) {
|
||||
break;
|
||||
}
|
||||
if (in_array($_SERVER['argv'][$i], array('--colors', '--verbose', '-v', '--debug', '--strict'))) {
|
||||
if (in_array($_SERVER['argv'][$i], array('--colors', '--verbose', '-v', '--debug'))) {
|
||||
$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");
|
||||
}
|
||||
}
|
||||
|
@ -52,18 +52,20 @@ 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()) {
|
||||
$path = str_replace('\\', '/', $path);
|
||||
}
|
||||
$path = testing_cli_fix_directory_separator($path);
|
||||
|
||||
return $path;
|
||||
}
|
||||
@ -238,3 +240,48 @@ function testing_update_composer_dependencies() {
|
||||
// Return to our original location.
|
||||
chdir($cwd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix DIRECTORY_SEPARATOR for windows.
|
||||
*
|
||||
* In PHP on Windows, DIRECTORY_SEPARATOR is set to the backslash (\)
|
||||
* character. However, if you're running a Cygwin/Msys/Git shell
|
||||
* exec() calls will return paths using the forward slash (/) character.
|
||||
*
|
||||
* NOTE: Because PHP on Windows will accept either forward or backslashes,
|
||||
* paths should be built using ONLY forward slashes, regardless of
|
||||
* OS. MOODLE_DIRECTORY_SEPARATOR should only be used when parsing
|
||||
* paths returned by the shell.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string.
|
||||
*/
|
||||
function testing_cli_fix_directory_separator($path) {
|
||||
global $CFG;
|
||||
|
||||
static $dirseparator = null;
|
||||
|
||||
if (!$dirseparator) {
|
||||
// Default directory separator.
|
||||
$dirseparator = DIRECTORY_SEPARATOR;
|
||||
|
||||
// On windows we need to find what directory separator is used.
|
||||
if ($CFG->ostype = 'WINDOWS') {
|
||||
if (!empty($_SERVER['argv'][0])) {
|
||||
if (false === strstr($_SERVER['argv'][0], '\\')) {
|
||||
$dirseparator = '/';
|
||||
} else {
|
||||
$dirseparator = '\\';
|
||||
}
|
||||
} else if (testing_is_cygwin()) {
|
||||
$dirseparator = '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Normalize \ and / to directory separator.
|
||||
$path = str_replace('\\', $dirseparator, $path);
|
||||
$path = str_replace('/', $dirseparator, $path);
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user