Verified Commit 7437958d authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3447198 by phenaproxima, alexpott, nicxvan, larowlan: RecipeCommand...

Issue #3447198 by phenaproxima, alexpott, nicxvan, larowlan: RecipeCommand mistakenly tries to apply a recipe even if you don't give it a valid directory

(cherry picked from commit 389c2bee)
parent c89af852
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
    $recipe_path = $input->getArgument('path');
    if (!is_string($recipe_path) || !is_dir($recipe_path)) {
      $io->error(sprintf('The supplied path %s is not a directory', $recipe_path));
      return 1;
    }
    // Recipes can only be applied to an already-installed site.
    $container = $this->boot()->getContainer();
+12 −0
Original line number Diff line number Diff line
@@ -91,6 +91,18 @@ public function testExceptionOnRollback(): void {
    $this->assertStringContainsString('There were validation errors in system.image:', $process->getErrorOutput());
  }

  /**
   * Tests the recipe command with a non-existent directory.
   */
  public function testErrorOnNonExistentDirectory(): void {
    $process = $this->applyRecipe('core/tests/fixtures/recipes/does_not_exist', 1);

    // The directory error should be the only error visible.
    $output = trim(preg_replace('/\s+/', ' ', $process->getOutput()));
    $this->assertSame('[ERROR] The supplied path core/tests/fixtures/recipes/does_not_exist is not a directory', $output);
    $this->assertEmpty($process->getErrorOutput());
  }

  /**
   * Asserts that the current set of checkpoints matches the given labels.
   *
+0 −1
Original line number Diff line number Diff line
@@ -58,7 +58,6 @@ protected function createRecipe(string|array $data, ?string $machine_name = NULL
   */
  protected function applyRecipe(string $path, int $expected_exit_code = 0): Process {
    assert($this instanceof BrowserTestBase);
    $this->assertDirectoryExists($path);

    $arguments = [
      (new PhpExecutableFinder())->find(),