Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ workflows:
triggers:
- schedule:
# Uses UTC timezone.
cron: "17 21 * * *"
cron: "35 15 * * *"
filters:
branches:
only:
Expand Down
2 changes: 1 addition & 1 deletion src/Sql/SqlPgsql.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 5 additions & 1 deletion tests/functional/SqlConnectCreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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.
Expand Down
33 changes: 0 additions & 33 deletions tests/unish/CommandUnishTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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().
*
Expand Down
41 changes: 39 additions & 2 deletions tests/unish/UnishTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}