Commit 08616351 authored by webchick's avatar webchick

#377564 by boombatower: Make run-tests.sh respect the 'simpletest_clear_results' variable.

parent 802f7aa0
...@@ -123,10 +123,7 @@ function simpletest_test_form() { ...@@ -123,10 +123,7 @@ function simpletest_test_form() {
} }
// Clear test results. // Clear test results.
if (variable_get('simpletest_clear_results', TRUE)) { simpletest_clean_results_table($_SESSION['test_id']);
db_query('DELETE FROM {simpletest} WHERE test_id = %d', $_SESSION['test_id']);
db_query('DELETE FROM {simpletest_test_id} WHERE test_id = %d', $_SESSION['test_id']);
}
unset($_SESSION['test_id']); unset($_SESSION['test_id']);
$all_ok = TRUE; $all_ok = TRUE;
...@@ -515,7 +512,8 @@ function simpletest_categorize_tests($tests) { ...@@ -515,7 +512,8 @@ function simpletest_categorize_tests($tests) {
function simpletest_clean_environment() { function simpletest_clean_environment() {
simpletest_clean_database(); simpletest_clean_database();
simpletest_clean_temporary_directories(); simpletest_clean_temporary_directories();
simpletest_clean_results_table(); $count = simpletest_clean_results_table();
drupal_set_message(t('Removed @count test results.', array('@count' => $count)));
} }
/** /**
...@@ -564,16 +562,34 @@ function simpletest_clean_temporary_directories() { ...@@ -564,16 +562,34 @@ function simpletest_clean_temporary_directories() {
} }
/** /**
* Clear the test results tables. * Clear the test result tables.
*
* @param $test_id
* Test ID to remove results for, or NULL to remove all results.
* @return
* The number of results removed or FALSE.
*/ */
function simpletest_clean_results_table() { function simpletest_clean_results_table($test_id = NULL) {
if (variable_get('simpletest_clear_results', TRUE)) { if (variable_get('simpletest_clear_results', TRUE)) {
$count = db_result(db_query('SELECT COUNT(test_id) FROM {simpletest_test_id}')); if ($test_id) {
$count = db_result(db_query('SELECT COUNT(test_id) FROM {simpletest_test_id} WHERE test_id = :test_id', array(':test_id' => $test_id)));
db_delete("simpletest")
->condition('test_id', $test_id)
->execute();
db_delete("simpletest_test_id")
->condition('test_id', $test_id)
->execute();
}
else {
$count = db_result(db_query('SELECT COUNT(test_id) FROM {simpletest_test_id}'));
// Clear test results. // Clear test results.
db_query('DELETE FROM {simpletest}'); db_delete("simpletest")->execute();
db_query('DELETE FROM {simpletest_test_id}'); db_delete("simpletest_test_id")->execute();
}
drupal_set_message(t('Removed @count test results.', array('@count' => $count))); return $count;
} }
return FALSE;
} }
...@@ -81,10 +81,7 @@ ...@@ -81,10 +81,7 @@
simpletest_script_reporter_display_results(); simpletest_script_reporter_display_results();
// Cleanup our test results. // Cleanup our test results.
db_delete("simpletest") simpletest_clean_results_table($test_id);
->condition('test_id', $test_id)
->execute();
/** /**
* Print help text. * Print help text.
......
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