mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-49456 behat: Use proper dir separator to support different os
This commit is contained in:
parent
b312e7f13a
commit
f8b71928d2
@ -152,7 +152,7 @@ $extraopts = implode(' ', $extraopts);
|
||||
if (empty($parallelrun)) {
|
||||
$cwd = getcwd();
|
||||
chdir(__DIR__);
|
||||
$runtestscommand = '../../../../' . behat_command::get_behat_command();
|
||||
$runtestscommand = behat_command::get_behat_command(false, false, true);
|
||||
$runtestscommand .= ' --config ' . behat_config_manager::get_behat_cli_config_filepath();
|
||||
$runtestscommand .= ' ' . $extraopts;
|
||||
echo "Running single behat site:" . PHP_EOL;
|
||||
@ -195,11 +195,11 @@ for ($i = $options['fromrun']; $i <= $options['torun']; $i++) {
|
||||
// Options parameters to be added to each run.
|
||||
$myopts = !empty($options['replace']) ? str_replace($options['replace'], $i, $extraopts) : $extraopts;
|
||||
|
||||
$behatcommand = behat_command::get_behat_command();
|
||||
$behatcommand = behat_command::get_behat_command(false, false, true);
|
||||
$behatconfigpath = behat_config_manager::get_behat_cli_config_filepath($i);
|
||||
|
||||
// Command to execute behat run.
|
||||
$cmds[BEHAT_PARALLEL_SITE_NAME . $i] = '../../../../' . $behatcommand . ' --config ' . $behatconfigpath . " " . $myopts;
|
||||
$cmds[BEHAT_PARALLEL_SITE_NAME . $i] = $behatcommand . ' --config ' . $behatconfigpath . " " . $myopts;
|
||||
echo "[" . BEHAT_PARALLEL_SITE_NAME . $i . "] " . $cmds[BEHAT_PARALLEL_SITE_NAME . $i] . PHP_EOL;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user