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 389c2bee0b)
merge-requests/8129/head
Lee Rowlands 2024-05-20 08:09:25 +10:00
parent a81b9fc443
commit 58cd9ce083
No known key found for this signature in database
GPG Key ID: 2B829A3DF9204DC4
3 changed files with 13 additions and 1 deletions

View File

@ -65,6 +65,7 @@ final class RecipeCommand extends Command {
$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();

View File

@ -91,6 +91,18 @@ class RecipeCommandTest extends BrowserTestBase {
$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.
*

View File

@ -58,7 +58,6 @@ trait RecipeTestTrait {
*/
protected function applyRecipe(string $path, int $expected_exit_code = 0): Process {
assert($this instanceof BrowserTestBase);
$this->assertDirectoryExists($path);
$arguments = [
(new PhpExecutableFinder())->find(),