From ceef2716448b37c1ff5c47db7e16a690f85df1d2 Mon Sep 17 00:00:00 2001 From: Moshe Weitzman Date: Sun, 30 Jan 2022 15:51:31 -0500 Subject: [PATCH 1/3] Fix tetss on Drupal 10 --- src/TestTraits/CliTestTrait.php | 5 ++--- .../modules/woot/src/EventSubscriber/ConfigSubscriber.php | 2 +- tests/unish/CommandUnishTestCase.php | 5 +++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/TestTraits/CliTestTrait.php b/src/TestTraits/CliTestTrait.php index dc3db23d57..194773d178 100644 --- a/src/TestTraits/CliTestTrait.php +++ b/src/TestTraits/CliTestTrait.php @@ -79,7 +79,7 @@ public function getErrorOutputRaw() /** * Run a command and return the process without waiting for it to finish. * - * @param string $command + * @param string|array $command * The actual command line to run. * @param sting cd * The directory to run the command in. @@ -88,12 +88,11 @@ public function getErrorOutputRaw() * @param string $input * A string representing the STDIN that is piped to the command. */ - public function startExecute(string $command, $cd = null, $env = null, $input = null) + public function startExecute($command, $cd = null, $env = null, $input = null) { try { // Process uses a default timeout of 60 seconds, set it to 0 (none). $this->process = new Process($command, $cd, $env, $input, 0); - $this->process->inheritEnvironmentVariables(true); if ($this->timeout) { $this->process->setTimeout($this->timeout) ->setIdleTimeout($this->idleTimeout); diff --git a/tests/fixtures/modules/woot/src/EventSubscriber/ConfigSubscriber.php b/tests/fixtures/modules/woot/src/EventSubscriber/ConfigSubscriber.php index f97bc396f2..93d240d878 100644 --- a/tests/fixtures/modules/woot/src/EventSubscriber/ConfigSubscriber.php +++ b/tests/fixtures/modules/woot/src/EventSubscriber/ConfigSubscriber.php @@ -14,7 +14,7 @@ class ConfigSubscriber extends ConfigImportValidateEventSubscriberBase /** * {@inheritdoc} */ - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { $events = []; diff --git a/tests/unish/CommandUnishTestCase.php b/tests/unish/CommandUnishTestCase.php index 7728367506..4333f464bb 100644 --- a/tests/unish/CommandUnishTestCase.php +++ b/tests/unish/CommandUnishTestCase.php @@ -71,7 +71,7 @@ public function getErrorOutputRaw() public function drushBackground($command, array $args = [], array $options = [], $site_specification = null, $cd = null, $suffix = null, $env = []) { list($cmd, ) = $this->prepareDrushCommand($command, $args, $options, $site_specification, $suffix); - return $this->startExecute($cmd, $cd, $env); + return $this->startExecute(explode(' ', $cmd), $cd, $env); } /** @@ -191,7 +191,8 @@ protected function prepareDrushCommand($command, array $args = [], array $option if ($hide_stderr) { $cmd[] = '2>' . $this->bitBucket(); } - $exec = array_filter($cmd, 'strlen'); // Remove NULLs + // Remove NULLs + $exec = @array_filter($cmd, 'strlen'); $cmd = implode(' ', $exec); return [$cmd, $coverage_file]; } From cc4ae541862b386e81dcf404446246eacbbba102 Mon Sep 17 00:00:00 2001 From: Moshe Weitzman Date: Sun, 30 Jan 2022 18:12:36 -0500 Subject: [PATCH 2/3] More test fixes. --- src/Application.php | 10 ++++++++++ src/Command/RemoteCommandProxy.php | 3 +++ src/Drupal/Commands/core/DeployHookCommands.php | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Application.php b/src/Application.php index 88d41741e8..0a224de2cf 100644 --- a/src/Application.php +++ b/src/Application.php @@ -405,4 +405,14 @@ public function renderException(\Exception $e, OutputInterface $output) $this->doRenderException($e, $output); } + + /** + * Renders a caught Throwable. Omits the command docs at end. + */ + public function renderThrowable(\Throwable $e, OutputInterface $output): void + { + $output->writeln('', OutputInterface::VERBOSITY_QUIET); + + $this->doRenderThrowable($e, $output); + } } diff --git a/src/Command/RemoteCommandProxy.php b/src/Command/RemoteCommandProxy.php index ef7256d854..ff83f5c17a 100644 --- a/src/Command/RemoteCommandProxy.php +++ b/src/Command/RemoteCommandProxy.php @@ -40,6 +40,9 @@ public function __construct($name, RedispatchHook $redispatchHook) InputArgument::IS_ARRAY, 'Proxy for command arguments' ); + + // The above should be enough but isn't in Drupal 10. + $this->ignoreValidationErrors(); } protected function execute(InputInterface $input, OutputInterface $output): void diff --git a/src/Drupal/Commands/core/DeployHookCommands.php b/src/Drupal/Commands/core/DeployHookCommands.php index f6477eea2d..9bcbb0a761 100644 --- a/src/Drupal/Commands/core/DeployHookCommands.php +++ b/src/Drupal/Commands/core/DeployHookCommands.php @@ -25,8 +25,8 @@ class DeployHookCommands extends DrushCommands implements SiteAliasManagerAwareI public static function getRegistry(): UpdateRegistry { $registry = new class ( - \Drupal::service('app.root'), - \Drupal::service('site.path'), + \Drupal::getContainer()->getParameter('app.root'), + \Drupal::getContainer()->getParameter('site.path'), array_keys(\Drupal::service('module_handler')->getModuleList()), \Drupal::service('keyvalue')->get('deploy_hook') ) extends UpdateRegistry { From 871b7485e85988215415bf6c23216a9db4a2c0e9 Mon Sep 17 00:00:00 2001 From: Moshe Weitzman Date: Sun, 30 Jan 2022 20:26:07 -0500 Subject: [PATCH 3/3] Integration fixes --- src/Symfony/BufferedConsoleOutput.php | 7 +++++++ .../unish/drush_empty_theme/drush_empty_theme.info.yml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Symfony/BufferedConsoleOutput.php b/src/Symfony/BufferedConsoleOutput.php index cddabd0f9f..96b8af58ab 100644 --- a/src/Symfony/BufferedConsoleOutput.php +++ b/src/Symfony/BufferedConsoleOutput.php @@ -5,6 +5,7 @@ use Symfony\Component\Console\Formatter\OutputFormatterInterface; use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Console\Output\ConsoleOutputInterface; +use Symfony\Component\Console\Output\ConsoleSectionOutput; use Symfony\Component\Console\Output\OutputInterface; /** @@ -13,6 +14,7 @@ class BufferedConsoleOutput extends BufferedOutput implements ConsoleOutputInterface { protected $stderr; + private array $consoleSectionOutputs = []; /** * @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface) @@ -41,4 +43,9 @@ public function setErrorOutput(OutputInterface $error): void { $this->stderr = $error; } + + public function section(): ConsoleSectionOutput + { + // @todo + } } diff --git a/sut/themes/unish/drush_empty_theme/drush_empty_theme.info.yml b/sut/themes/unish/drush_empty_theme/drush_empty_theme.info.yml index b68f22c9b7..ac6a509e08 100644 --- a/sut/themes/unish/drush_empty_theme/drush_empty_theme.info.yml +++ b/sut/themes/unish/drush_empty_theme/drush_empty_theme.info.yml @@ -1,6 +1,6 @@ name: Drush empty theme description: 'Drush empty theme' core: 8.x -core_version_requirement: ^8 || ^9 +core_version_requirement: ^8 || ^9 || ^10 type: theme base theme: stable