@@ -17,6 +17,13 @@ abstract class UnishTestCase extends TestCase
1717 const UNISH_EXITCODE_USER_ABORT = 75 ; // Same as DRUSH_EXITCODE_USER_ABORT
1818 const INTEGRATION_TEST_ENV = 'default ' ;
1919
20+ /**
21+ * Process of last executed command.
22+ *
23+ * @var Process
24+ */
25+ protected $ process ;
26+
2027 /**
2128 * A list of Drupal sites that have been recently installed. They key is the
2229 * site name and values are details about each site.
@@ -553,7 +560,7 @@ public function createSettings($subdir)
553560 file_put_contents ($ settingsPath , $ settingsContents );
554561 }
555562 /**
556- * Assemble (and optionally install) one or more Drupal sites using a single codebase.
563+ * Prepare (and optionally install) one or more Drupal sites using a single codebase.
557564 *
558565 * It is no longer supported to pass alternative versions of Drupal or an alternative install_profile.
559566 */
@@ -668,11 +675,15 @@ protected function installSut($uri = self::INTEGRATION_TEST_ENV, $optionsFromTes
668675 'yes ' => true ,
669676 'quiet ' => true ,
670677 ];
678+ if ($ level = $ this ->logLevel ()) {
679+ $ options [$ level ] = true ;
680+ }
671681 $ process = new SiteProcess ($ sutAlias , [self ::getDrush (), 'site:install ' , 'testing ' , 'install_configure_form.enable_update_status_emails=NULL ' ], $ options );
672682 // Set long timeout because Xdebug slows everything.
673683 $ process ->setTimeout (0 );
684+ $ this ->process = $ process ;
674685 $ process ->run ();
675- $ this ->assertTrue ($ process ->isSuccessful (), ' Could not install SUT. Options: ' . var_export ( $ optionsFromTest , true ) . "\n Stdout: \n" . $ process -> getOutput () . "\n\n Stderr: \n" . $ process -> getErrorOutput ());
686+ $ this ->assertTrue ($ process ->isSuccessful (), $ this -> buildProcessMessage ());
676687
677688 // Give us our write perms back.
678689 chmod ($ this ->webroot () . "/sites/ $ uri " , 0777 );
@@ -700,4 +711,30 @@ public static function setEnv(array $vars)
700711 $ _SERVER [$ k ]= (string ) $ v ;
701712 }
702713 }
714+
715+ /**
716+ * Borrowed from \Symfony\Component\Process\Exception\ProcessTimedOutException
717+ *
718+ * @return string
719+ */
720+ public function buildProcessMessage ()
721+ {
722+ $ error = sprintf (
723+ "%s \n\nExit Code: %s(%s) \n\nWorking directory: %s " ,
724+ $ this ->process ->getCommandLine (),
725+ $ this ->process ->getExitCode (),
726+ $ this ->process ->getExitCodeText (),
727+ $ this ->process ->getWorkingDirectory ()
728+ );
729+
730+ if (!$ this ->process ->isOutputDisabled ()) {
731+ $ error .= sprintf (
732+ "\n\nOutput: \n================ \n%s \n\nError Output: \n================ \n%s " ,
733+ $ this ->process ->getOutput (),
734+ $ this ->process ->getErrorOutput ()
735+ );
736+ }
737+
738+ return $ error ;
739+ }
703740}
0 commit comments