Skip to content

Commit

Permalink
Fix tests on Drupal 10 (#5054)
Browse files Browse the repository at this point in the history
  • Loading branch information
weitzman committed Jan 31, 2022
1 parent 45b7989 commit 8c71d00
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 9 deletions.
10 changes: 10 additions & 0 deletions src/Application.php
Expand Up @@ -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);
}
}
3 changes: 3 additions & 0 deletions src/Command/RemoteCommandProxy.php
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Drupal/Commands/core/DeployHookCommands.php
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions src/Symfony/BufferedConsoleOutput.php
Expand Up @@ -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;

/**
Expand All @@ -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)
Expand Down Expand Up @@ -41,4 +43,9 @@ public function setErrorOutput(OutputInterface $error): void
{
$this->stderr = $error;
}

public function section(): ConsoleSectionOutput
{
// @todo
}
}
5 changes: 2 additions & 3 deletions src/TestTraits/CliTestTrait.php
Expand Up @@ -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.
Expand All @@ -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);
Expand Down
@@ -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
Expand Up @@ -14,7 +14,7 @@ class ConfigSubscriber extends ConfigImportValidateEventSubscriberBase
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
$events = [];

Expand Down
5 changes: 3 additions & 2 deletions tests/unish/CommandUnishTestCase.php
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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];
}
Expand Down

0 comments on commit 8c71d00

Please sign in to comment.