MDL-49456 behat: Use proper dir separator to support different os

This commit is contained in:
Rajesh Taneja
2015-04-17 11:48:37 +08:00
committed by David Monllao
parent b312e7f13a
commit f8b71928d2
2 changed files with 25 additions and 15 deletions
+22 -12
View File
@@ -86,26 +86,36 @@ class behat_command {
*
* @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 final static function get_behat_command($custombyterm = false, $parallerun = false) {
public final static function get_behat_command($custombyterm = false, $parallerun = false, $absolutepath = false) {
$separator = DIRECTORY_SEPARATOR;
if (!$parallerun) {
$exec = 'behat';
$exec = 'behat';
// Cygwin uses linux-style directory separators.
if ($custombyterm && testing_is_cygwin()) {
$separator = '/';
// 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';
}
// MinGW can not execute .bat scripts.
if (!testing_is_mingw()) {
$exec = 'behat.bat';
}
$command = 'vendor' . $separator . 'bin' . $separator . $exec;
}
// If relative path then prefix relative path.
if ($absolutepath) {
$pathprefix = testing_cli_argument_path('/') . $separator;
} else {
$command = 'php admin' . $separator . 'tool' . $separator . 'behat' . $separator . 'cli' . $separator . 'run.php';
$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;
}