// Cygwin uses linux-style directory separators.
if ($custombyterm && testing_is_cygwin()) {
- $exec = 'behat.bat';
$separator = '/';
+
+ // MinGW can not execute .bat scripts.
+ if (!testing_is_mingw()) {
+ $exec = 'behat.bat';
+ }
}
return 'vendor' . $separator . 'bin' . $separator . $exec;
}
public static function get_steps_list_config_filepath() {
global $USER;
- // We don't cygwin-it as it is called using exec().
+ // We don't cygwin-it as it is called using exec() which uses cmd.exe.
$userdir = behat_command::get_behat_dir() . '/users/' . $USER->id;
make_writable_directory($userdir);
$executable = 'phpunit';
if (testing_is_cygwin()) {
$file = str_replace('\\', '/', $file);
- $executable = 'phpunit.bat';
+ if (!testing_is_mingw()) {
+ $executable = 'phpunit.bat';
+ }
}
}
}
}
+/**
+ * Returns whether a mingw CLI is running.
+ *
+ * MinGW sets $_SERVER['TERM'] to cygwin, but it
+ * can not run .bat files; this function may be useful
+ * when we need to output proposed commands to users
+ * using Windows CLI interfaces.
+ *
+ * @link http://sourceforge.net/p/mingw/bugs/1902
+ * @return bool
+ */
+function testing_is_mingw() {
+
+ if (!testing_is_cygwin()) {
+ return false;
+ }
+
+ if (!empty($_SERVER['MSYSTEM'])) {
+ return true;
+ }
+
+ return false;
+}
+
/**
* Mark empty dataroot to be used for testing.
* @param string $dataroot The dataroot directory