diff --git a/.circleci/config.yml b/.circleci/config.yml index 23b6db8554..4ff6d269c4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -149,7 +149,7 @@ workflows: triggers: - schedule: # Uses UTC timezone. - cron: "17 21 * * *" + cron: "35 15 * * *" filters: branches: only: diff --git a/src/Sql/SqlPgsql.php b/src/Sql/SqlPgsql.php index b511eb65b6..485f46e988 100644 --- a/src/Sql/SqlPgsql.php +++ b/src/Sql/SqlPgsql.php @@ -93,7 +93,7 @@ public function dbExists() $db_spec_no_db = $dbSpec; unset($db_spec_no_db['database']); $sql_no_db = new SqlPgsql($db_spec_no_db, $this->getOptions()); - $query = "SELECT 1 AS result FROM pg_database WHERE datname='\''$database'\'''"; + $query = "SELECT 1 AS result FROM pg_database WHERE datname='$database'"; $process = Drush::process($sql_no_db->connect() . ' -t -c ' . $query); $process->setSimulated(false); $process->run(); diff --git a/tests/functional/SqlConnectCreateTest.php b/tests/functional/SqlConnectCreateTest.php index 051e1f1cc9..4d322058d4 100644 --- a/tests/functional/SqlConnectCreateTest.php +++ b/tests/functional/SqlConnectCreateTest.php @@ -34,6 +34,10 @@ public function testSqlConnect() $this->markTestSkipped('sql-connect test does not recognize database type in ' . self::getDbUrl()); } + if ($db_driver == 'pgsql') { + $this->markTestSkipped('Postgres prepends PGPASSFILE=/var/www/html/sandbox/tmp/drush_[RANDOM] and that file got deleted already.'); + } + // Issue a query and check the result to verify the connection. $this->execute($connectionString . ' ' . $shell_options . ' "SELECT uid FROM users where uid = 1;"', self::EXIT_SUCCESS, $this->webroot()); $output = $this->getOutput(); @@ -50,7 +54,7 @@ public function testSqlConnect() $this->drush('sql-create'); // Try to execute a query. This should give a "table not found" error. - $this->execute($connectionString . ' ' . $shell_options . ' "SELECT uid FROM users where uid = 1;"', self::EXIT_ERROR); + $this->execute($connectionString . ' ' . $shell_options . ' "SELECT uid FROM users where uid = 1;"', self::EXIT_ERROR, $this->webroot()); // We should still be able to run 'core-status' without getting an // error, although Drupal should not bootstrap any longer. diff --git a/tests/unish/CommandUnishTestCase.php b/tests/unish/CommandUnishTestCase.php index 1353c8f4c3..21c9c283d2 100644 --- a/tests/unish/CommandUnishTestCase.php +++ b/tests/unish/CommandUnishTestCase.php @@ -18,13 +18,6 @@ abstract class CommandUnishTestCase extends UnishTestCase */ protected $coverage_data = []; - /** - * Process of last executed command. - * - * @var Process - */ - private $process; - /** * Default timeout for commands. * @@ -144,32 +137,6 @@ public function execute($command, $expected_return = self::EXIT_SUCCESS, $cd = n } } - /** - * Borrowed from \Symfony\Component\Process\Exception\ProcessTimedOutException - * - * @return string - */ - public function buildProcessMessage() - { - $error = sprintf( - "%s\n\nExit Code: %s(%s)\n\nWorking directory: %s", - $this->process->getCommandLine(), - $this->process->getExitCode(), - $this->process->getExitCodeText(), - $this->process->getWorkingDirectory() - ); - - if (!$this->process->isOutputDisabled()) { - $error .= sprintf( - "\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", - $this->process->getOutput(), - $this->process->getErrorOutput() - ); - } - - return $error; - } - /** * Invoke drush in via execute(). * diff --git a/tests/unish/UnishTestCase.php b/tests/unish/UnishTestCase.php index 28b309c433..94557d1a11 100644 --- a/tests/unish/UnishTestCase.php +++ b/tests/unish/UnishTestCase.php @@ -17,6 +17,13 @@ abstract class UnishTestCase extends TestCase const UNISH_EXITCODE_USER_ABORT = 75; // Same as DRUSH_EXITCODE_USER_ABORT const INTEGRATION_TEST_ENV = 'default'; + /** + * Process of last executed command. + * + * @var Process + */ + protected $process; + /** * A list of Drupal sites that have been recently installed. They key is the * site name and values are details about each site. @@ -553,7 +560,7 @@ public function createSettings($subdir) file_put_contents($settingsPath, $settingsContents); } /** - * Assemble (and optionally install) one or more Drupal sites using a single codebase. + * Prepare (and optionally install) one or more Drupal sites using a single codebase. * * It is no longer supported to pass alternative versions of Drupal or an alternative install_profile. */ @@ -668,11 +675,15 @@ protected function installSut($uri = self::INTEGRATION_TEST_ENV, $optionsFromTes 'yes' => true, 'quiet' => true, ]; + if ($level = $this->logLevel()) { + $options[$level] = true; + } $process = new SiteProcess($sutAlias, [self::getDrush(), 'site:install', 'testing', 'install_configure_form.enable_update_status_emails=NULL'], $options); // Set long timeout because Xdebug slows everything. $process->setTimeout(0); + $this->process = $process; $process->run(); - $this->assertTrue($process->isSuccessful(), 'Could not install SUT. Options: ' . var_export($optionsFromTest, true) . "\nStdout:\n" . $process->getOutput() . "\n\nStderr:\n" . $process->getErrorOutput()); + $this->assertTrue($process->isSuccessful(), $this->buildProcessMessage()); // Give us our write perms back. chmod($this->webroot() . "/sites/$uri", 0777); @@ -700,4 +711,30 @@ public static function setEnv(array $vars) $_SERVER[$k]= (string) $v; } } + + /** + * Borrowed from \Symfony\Component\Process\Exception\ProcessTimedOutException + * + * @return string + */ + public function buildProcessMessage() + { + $error = sprintf( + "%s\n\nExit Code: %s(%s)\n\nWorking directory: %s", + $this->process->getCommandLine(), + $this->process->getExitCode(), + $this->process->getExitCodeText(), + $this->process->getWorkingDirectory() + ); + + if (!$this->process->isOutputDisabled()) { + $error .= sprintf( + "\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", + $this->process->getOutput(), + $this->process->getErrorOutput() + ); + } + + return $error; + } }