Commit 7e01fa53 authored by alexpott's avatar alexpott
Browse files

Issue #2680057 by alexpott, dawehner, isntall: Allow to not override the...

Issue #2680057 by alexpott, dawehner, isntall: Allow to not override the simpletest results on a new test run
parent b5110387
...@@ -180,6 +180,12 @@ function simpletest_script_help() { ...@@ -180,6 +180,12 @@ function simpletest_script_help() {
Note that ':memory:' cannot be used, because this script spawns Note that ':memory:' cannot be used, because this script spawns
sub-processes. However, you may use e.g. '/tmpfs/test.sqlite' sub-processes. However, you may use e.g. '/tmpfs/test.sqlite'
--keep-results-table
Boolean flag to indicate to not cleanup the simpletest result
table. For testbots or repeated execution of a single test it can
be helpful to not cleanup the simpletest result table.
--dburl A URI denoting the database driver, credentials, server hostname, --dburl A URI denoting the database driver, credentials, server hostname,
and database name to use in tests. and database name to use in tests.
Required when running tests without a Drupal installation that Required when running tests without a Drupal installation that
...@@ -303,6 +309,7 @@ function simpletest_script_parse_args() { ...@@ -303,6 +309,7 @@ function simpletest_script_parse_args() {
'color' => FALSE, 'color' => FALSE,
'verbose' => FALSE, 'verbose' => FALSE,
'keep-results' => FALSE, 'keep-results' => FALSE,
'keep-results-table' => FALSE,
'test_names' => array(), 'test_names' => array(),
'repeat' => 1, 'repeat' => 1,
'die-on-fail' => FALSE, 'die-on-fail' => FALSE,
...@@ -539,7 +546,8 @@ function simpletest_script_setup_database($new = FALSE) { ...@@ -539,7 +546,8 @@ function simpletest_script_setup_database($new = FALSE) {
// Create the Simpletest schema. // Create the Simpletest schema.
try { try {
$schema = Database::getConnection('default', 'test-runner')->schema(); $connection = Database::getConnection('default', 'test-runner');
$schema = $connection->schema();
} }
catch (\PDOException $e) { catch (\PDOException $e) {
simpletest_script_print_error($databases['test-runner']['default']['driver'] . ': ' . $e->getMessage()); simpletest_script_print_error($databases['test-runner']['default']['driver'] . ': ' . $e->getMessage());
...@@ -549,10 +557,13 @@ function simpletest_script_setup_database($new = FALSE) { ...@@ -549,10 +557,13 @@ function simpletest_script_setup_database($new = FALSE) {
require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'simpletest') . '/simpletest.install'; require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'simpletest') . '/simpletest.install';
foreach (simpletest_schema() as $name => $table_spec) { foreach (simpletest_schema() as $name => $table_spec) {
try { try {
if ($schema->tableExists($name)) { $table_exists = $schema->tableExists($name);
$schema->dropTable($name); if (empty($args['keep-results-table']) && $table_exists) {
$connection->truncate($name)->execute();
}
if (!$table_exists) {
$schema->createTable($name, $table_spec);
} }
$schema->createTable($name, $table_spec);
} }
catch (Exception $e) { catch (Exception $e) {
echo (string) $e; echo (string) $e;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment