DrupalDriver icon indicating copy to clipboard operation
DrupalDriver copied to clipboard

Error output lost when creating a term with the drush driver

Open chasingmaxwell opened this issue 9 years ago • 6 comments

I'm using behat-drush-endpoint on a Pantheon site and was having trouble creating a term with behat. The step Given a/an :vocabulary term with the name :name was failing with (RuntimeException) as the only output. I eventually found out that the error message was "Command not supported as typed." but it lives in $process->getOutput() and not in $process->getErrorOutput(). Perhaps this is an issue in the behat drush command, but I wasn't sure if getOutput() was a valid place for error output.

When I ran the resulting drush command manually:

drush @pantheon.alias  behat  --nocolor= create-term '{"name":"Test Term","vocabulary_machine_name":"Test Vocab","description":"g&lx\\#r)J\"kBm~?>Z^sY$;v23l=Mi7%Jsn|w93AgHCJ\/UBw9oZ|ss>+I#|'\''\\h*TXlU8i%lJ4{e-~Jr\"*^Rs81v=z5~8u$3u@M;@y#h.boHf*NX&(DI}AiR!V0H,i8^h\/3<M$NEz3]@`<4f3v58nzq{:e[Y PX5lN#$5N>zat\/u@aye$a@0q Lf7H3OT3Xm,&2^><;<4Vg(l8>7EiRljaggt~IOwbWuTlB`B*`6LM>}+E3WbzA8Ez[DfVH\"C}#}0"}'

It did produce a non-zero exit code.

chasingmaxwell avatar Dec 10 '15 22:12 chasingmaxwell

Issue for behat-drush-endpoint: https://github.com/jhedstrom/DrupalDriver/issues/73

chasingmaxwell avatar Dec 10 '15 22:12 chasingmaxwell

Relevant line where $process->getErrorOutput() is called: https://github.com/jhedstrom/DrupalDriver/blob/master/src/Drupal/Driver/DrushDriver.php#L301

chasingmaxwell avatar Dec 10 '15 22:12 chasingmaxwell

Related: https://github.com/jhedstrom/drupalextension/pull/220

greg-1-anderson avatar Feb 25 '16 04:02 greg-1-anderson

It looks like this is the location of the code in question: https://github.com/jhedstrom/DrupalDriver/blob/8e2827e205758326950fddb20218e70b3d130934/src/Drupal/Driver/DrushDriver.php#L381-L393

When drush fails hard for me, I see a stack trace and no useful message appears to indicate what caused it.

arosboro avatar Jun 09 '18 16:06 arosboro

Is this still an issue? I thought that https://github.com/jhedstrom/drupalextension/pull/220 cleared this problem up.

greg-1-anderson avatar Sep 20 '18 14:09 greg-1-anderson

Hi @greg-1-anderson, I switched away from drush as per advice you gave me on slack. Before I had done so, I identified the error output with:

 diff --git a/src/Drupal/Driver/DrushDriver.php b/src/Drupal/Driver/DrushDriver.php
index 0993074..6233b0f 100644
--- a/src/Drupal/Driver/DrushDriver.php
+++ b/src/Drupal/Driver/DrushDriver.php
@@ -373,13 +373,14 @@ class DrushDriver extends BaseDriver {

     // Add any global arguments.
     $global = $this->getArguments();
-
     $process = new Process("{$this->binary} {$alias} {$string_options} {$global} {$command} {$arguments}");
     $process->setTimeout(3600);
+    $time = time();
     $process->run();

     if (!$process->isSuccessful()) {
-      throw new \RuntimeException($process->getErrorOutput());
+      $time_end = time();
+      throw new \RuntimeException(sprintf("Time: %s\nOutput: %s\nError message: %s\n", ($time_end - $time), $process->getOutput(), $process->getErrorOutput()));
     }

     // Some drush commands write to standard error output (for example enable

arosboro avatar Sep 20 '18 14:09 arosboro