Permalink
Browse files

Some enhancements to Finder and misc Unish fixes for Windows.

  • Loading branch information...
1 parent aa598de commit abb5448c2b4afc0ee60d32eec66e6953545c36de @weitzman weitzman committed Aug 20, 2016
Showing with 22 additions and 7 deletions.
  1. +5 −0 dr.bat
  2. +8 −1 includes/startup.inc
  3. +8 −5 tests/Unish/CommandUnishTestCase.php
  4. +1 −1 tests/commandTest.php
View
@@ -0,0 +1,5 @@
+@ECHO OFF
+REM Running this file is equivalent to running `php drush`
+setlocal DISABLEDELAYEDEXPANSION
+SET BIN_TARGET=%~dp0drush
+php "%BIN_TARGET%" %*
@@ -420,7 +420,14 @@ function drush_startup($argv) {
else {
$escaped_args = array_map(function($item) { return drush_escapeshellarg($item); }, $arguments);
// Double quotes around $found_script as it can contain spaces.
- $process = proc_open('"'. $found_script. '" '. implode(' ', $escaped_args), array(0 => STDIN, 1 => STDOUT, 2 => STDERR), $pipes);
+ $cmd = drush_escapeshellarg($found_script). ' '. implode(' ', $escaped_args);
+ if (drush_is_windows()) {
+ // Windows requires double quotes around whole command.
+ // @see https://bugs.php.net/bug.php?id=49139
+ // @see https://bugs.php.net/bug.php?id=60181
+ $cmd = '"'. $cmd. '"';
+ }
+ $process = proc_open($cmd, array(0 => STDIN, 1 => STDOUT, 2 => STDERR), $pipes);
$proc_status = proc_get_status($process);
$exit_code = proc_close($process);
exit($proc_status["running"] ? $exit_code : $proc_status["exitcode"] );
@@ -166,14 +166,16 @@ function execute($command, $expected_return = self::EXIT_SUCCESS, $cd = NULL, $e
$this->tick();
// Apply the environment variables we need for our test to the head of the
- // command. Process does have an $env argument, but it replaces the entire
+ // command (excludes Windows). Process does have an $env argument, but it replaces the entire
// environment with the one given. This *could* be used for ensuring the
// test ran with a clean environment, but it also makes tests fail hard on
// Travis, for unknown reasons.
// @see https://github.com/drush-ops/drush/pull/646
$prefix = '';
- foreach ($env as $env_name => $env_value) {
- $prefix .= $env_name . '=' . self::escapeshellarg($env_value) . ' ';
+ if(!$this->is_windows()) {
+ foreach ($env as $env_name => $env_value) {
+ $prefix .= $env_name . '=' . self::escapeshellarg($env_value) . ' ';
+ }
}
$this->log("Executing: $prefix$command", 'warning');
@@ -288,6 +290,7 @@ function drush($command, array $args = array(), array $options = array(), $site_
$exec = array_filter($cmd, 'strlen'); // Remove NULLs
// Set sendmail_path to 'true' to disable any outgoing emails
// that tests might cause Drupal to send.
+
$php_options = (array_key_exists('PHP_OPTIONS', $env)) ? $env['PHP_OPTIONS'] . " " : "";
$env['PHP_OPTIONS'] = "${php_options}-d sendmail_path='true'";
$return = $this->execute(implode(' ', $exec), $expected_return, $cd, $env);
@@ -353,14 +356,14 @@ public function run(\PHPUnit_Framework_TestResult $result = NULL) {
function parse_backend_output($string) {
$regex = sprintf(UNISH_BACKEND_OUTPUT_DELIMITER, '(.*)');
preg_match("/$regex/s", $string, $match);
- if ($match[1]) {
+ if (isset($match[1])) {
// we have our JSON encoded string
$output = $match[1];
// remove the match we just made and any non printing characters
$string = trim(str_replace(sprintf(UNISH_BACKEND_OUTPUT_DELIMITER, $match[1]), '', $string));
}
- if ($output) {
+ if (!empty($output)) {
$data = json_decode($output, TRUE);
if (is_array($data)) {
return $data;
@@ -79,7 +79,7 @@ public function testMissingDrushDependency() {
}
/**
- * Assert that commands in disabled modules are detected.
+ * Assert that commands in disabled/uninstalled modules throw an error.
*/
public function testDisabledModule() {
$sites = $this->setUpDrupal(1, TRUE);

0 comments on commit abb5448

Please sign in to comment.