diff --git a/core/tests/Drupal/TestSite/Commands/TestSiteInstallCommand.php b/core/tests/Drupal/TestSite/Commands/TestSiteInstallCommand.php index 869688b6fb..527e77118e 100644 --- a/core/tests/Drupal/TestSite/Commands/TestSiteInstallCommand.php +++ b/core/tests/Drupal/TestSite/Commands/TestSiteInstallCommand.php @@ -83,6 +83,9 @@ protected function execute(InputInterface $input, OutputInterface $output) { // Validate the setup class prior to installing a database to avoid creating // unnecessary sites. $this->validateSetupClass($input->getOption('setup_class')); + // Ensure we can install a site in the sites/simpletest directory. + $this->ensureDirectory(); + $db_url = $input->getOption('db_url'); $base_url = $input->getOption('base_url'); putenv("SIMPLETEST_DB=$db_url"); @@ -131,6 +134,18 @@ protected function validateSetupClass($class) { } } + /** + * Ensures that the sites/simpletest directory exists and is writable. + */ + protected function ensureDirectory() { + $root = dirname(dirname(dirname(dirname(dirname(__DIR__))))); + if (!is_writable($root . '/sites/simpletest')) { + if (!@mkdir($root . '/sites/simpletest')) { + throw new \RuntimeException($root . '/sites/simpletest must exist and be writable to install a test site'); + } + } + } + /** * Creates a test drupal installation. *