mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-43461 behat: Using linux-style directory separators when using cygwin
This commit is contained in:
parent
8a0667a994
commit
19a40b1468
@ -127,8 +127,8 @@ if ($options['install']) {
|
||||
mtrace("Acceptance tests site dropped");
|
||||
} else if ($options['enable']) {
|
||||
behat_util::start_test_mode();
|
||||
$runtestscommand = behat_command::get_behat_command() . ' --config '
|
||||
. $CFG->behat_dataroot . DIRECTORY_SEPARATOR . 'behat' . DIRECTORY_SEPARATOR . 'behat.yml';
|
||||
$runtestscommand = behat_command::get_behat_command(true) .
|
||||
' --config ' . behat_config_manager::get_behat_cli_config_filepath();
|
||||
mtrace("Acceptance tests environment enabled on $CFG->behat_wwwroot, to run the tests use:\n " . $runtestscommand);
|
||||
} else if ($options['disable']) {
|
||||
behat_util::stop_test_mode();
|
||||
|
@ -66,10 +66,26 @@ class behat_command {
|
||||
|
||||
/**
|
||||
* Returns the executable path
|
||||
*
|
||||
* Allows returning a customized command for cygwin when the
|
||||
* command is just displayed, when using exec(), system() and
|
||||
* friends we stay with DIRECTORY_SEPARATOR as they use the
|
||||
* normal cmd.exe (in Windows).
|
||||
*
|
||||
* @param bool $custombyterm If the provided command should depend on the terminal where it runs
|
||||
* @return string
|
||||
*/
|
||||
public final static function get_behat_command() {
|
||||
return 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'behat';
|
||||
public final static function get_behat_command($custombyterm = false) {
|
||||
|
||||
$separator = DIRECTORY_SEPARATOR;
|
||||
$exec = 'behat';
|
||||
|
||||
// Cygwin uses linux-style directory separators.
|
||||
if ($custombyterm && testing_is_cygwin()) {
|
||||
$exec = 'behat.bat';
|
||||
$separator = '/';
|
||||
}
|
||||
return 'vendor' . $separator . 'bin' . $separator . $exec;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,21 +154,36 @@ class behat_config_manager {
|
||||
/**
|
||||
* Returns the behat config file path used by the steps definition list
|
||||
*
|
||||
* Note this can only be called from web-based scripts so it will return the
|
||||
* production dataroot not behat_dataroot. With this the steps definitions
|
||||
* list is accessible without having to install the behat test site.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_steps_list_config_filepath() {
|
||||
global $USER;
|
||||
|
||||
// We don't cygwin-it as it is called using exec().
|
||||
$userdir = behat_command::get_behat_dir() . '/users/' . $USER->id;
|
||||
make_writable_directory($userdir);
|
||||
|
||||
return $userdir . '/behat.yml';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the behat config file path used by the behat cli command.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_behat_cli_config_filepath() {
|
||||
global $CFG;
|
||||
|
||||
$command = $CFG->behat_dataroot . DIRECTORY_SEPARATOR . 'behat' . DIRECTORY_SEPARATOR . 'behat.yml';
|
||||
|
||||
// Cygwin uses linux-style directory separators.
|
||||
if (testing_is_cygwin()) {
|
||||
$command = str_replace('\\', '/', $command);
|
||||
}
|
||||
|
||||
return $command;
|
||||
}
|
||||
|
||||
/**
|
||||
* Behat config file specifing the main context class,
|
||||
* the required Behat extensions and Moodle test wwwroot.
|
||||
|
Loading…
x
Reference in New Issue
Block a user