Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / drush / drush / sut
diff --git a/vendor/drush/drush/sut b/vendor/drush/drush/sut
new file mode 100755 (executable)
index 0000000..ff147d2
--- /dev/null
@@ -0,0 +1,47 @@
+#!/usr/bin/env php
+<?php
+
+/**
+ * Run a Drush command against the Site Under Test
+ *
+ * @usage sut core-status --verbose
+ */
+
+require __DIR__. '/tests/unish.inc';
+list($unish_tmp, $unish_sandbox, $unish_drush_dir) = unishGetPaths();
+$sut = dirname($unish_sandbox) . '/drush-sut';
+$vendor = $sut . '/vendor';
+
+// Get the arguments for the command.
+$arguments = $GLOBALS['argv'];
+// Shift off argv[0] which contains the name of this script.
+array_shift($arguments);
+// Add alias if not already specified
+if (!empty($arguments) && ($arguments[0][0] != '@')) {
+  array_unshift($arguments, "@sut.dev");
+}
+
+// Make it easy to just call `./sut si -y testing`, or `./sut @sut.stage -y testing`
+if (in_array('si', $arguments) || in_array('site-install', $arguments)) {
+    $subdir = 'dev';
+    if (in_array('@sut.stage', $arguments)) {
+      $subdir = 'stage';
+    }
+    $db_url = getenv('UNISH_DB_URL') ?: 'mysql://root:@127.0.0.1';
+    $arguments[] = "--db-url=$db_url/unish_$subdir";
+    $arguments[] = "--sites-subdir=$subdir";
+}
+
+/**
+ * DRUSH_AUTOLOAD_PHP must be provided because Drush is symlinked into the SUT.
+ * This confuses our autoload.php detection.
+ */
+$cmd = "DRUSH_AUTOLOAD_PHP=$vendor/autoload.php ETC_PREFIX=$unish_sandbox SHARE_PREFIX=$unish_sandbox TEMP=$unish_sandbox/tmp HOME=$unish_sandbox/home " . escapeshellarg($vendor . '/bin/drush') . ' ' . implode(' ', array_map(function ($item) { return escapeshellarg($item); }, $arguments));
+if (unishIsVerbose()) {
+  fwrite(STDERR, 'Executing: ' . $cmd . "\n");
+}
+chdir($sut);
+$process = proc_open($cmd, [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"] );