- Patch #243773 by chx, catch, boombatower, cwgordon7, yched, dmitrig01, et al: small revert of batch API patch. Also forgot to mention cwgordon7 in the previous commit.
parent
9b82787b22
commit
5efec92ac3
|
@ -37,6 +37,9 @@ All arguments are long options.
|
||||||
need this parameter if Drupal is in a subdirectory on your
|
need this parameter if Drupal is in a subdirectory on your
|
||||||
localhost and you have not set \$base_url in settings.php.
|
localhost and you have not set \$base_url in settings.php.
|
||||||
|
|
||||||
|
--reporter Immediatly preceeds the name of the output reporter to use. This
|
||||||
|
Defaults to "text", while other options include "xml" and "html".
|
||||||
|
|
||||||
--all Run all available tests.
|
--all Run all available tests.
|
||||||
|
|
||||||
--class Run tests identified by speficic class names.
|
--class Run tests identified by speficic class names.
|
||||||
|
@ -64,7 +67,6 @@ $list = FALSE;
|
||||||
$clean = FALSE;
|
$clean = FALSE;
|
||||||
$all = FALSE;
|
$all = FALSE;
|
||||||
$class_names = FALSE;
|
$class_names = FALSE;
|
||||||
$verbose = FALSE;
|
|
||||||
$test_names = array();
|
$test_names = array();
|
||||||
|
|
||||||
while ($param = array_shift($_SERVER['argv'])) {
|
while ($param = array_shift($_SERVER['argv'])) {
|
||||||
|
@ -87,6 +89,12 @@ while ($param = array_shift($_SERVER['argv'])) {
|
||||||
case '--clean':
|
case '--clean':
|
||||||
$clean = TRUE;
|
$clean = TRUE;
|
||||||
break;
|
break;
|
||||||
|
case '--reporter':
|
||||||
|
$reporter = array_shift($_SERVER['argv']);
|
||||||
|
if (!in_array($reporter, array("text", "xml", "html"))) {
|
||||||
|
$reporter = "text";
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$test_names += explode(',', $param);
|
$test_names += explode(',', $param);
|
||||||
break;
|
break;
|
||||||
|
@ -108,7 +116,8 @@ require_once './includes/bootstrap.inc';
|
||||||
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
|
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
|
||||||
|
|
||||||
if (!module_exists('simpletest')) {
|
if (!module_exists('simpletest')) {
|
||||||
die(t('Error: The simpletest module must be enabled before this script can run.') ."\n");
|
echo("ERROR: The simpletest module must be enabled before this script can run.\n");
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($clean) {
|
if ($clean) {
|
||||||
|
@ -122,28 +131,34 @@ if ($clean) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tests = simpletest_get_all_tests();
|
// Run tests as user #1.
|
||||||
$test_list = array();
|
$GLOBALS['user'] = user_load(1);
|
||||||
|
|
||||||
|
//Load simpletest files
|
||||||
|
$total_test = &simpletest_get_total_test();
|
||||||
|
|
||||||
|
$test_instances = $total_test->getTestInstances();
|
||||||
|
|
||||||
|
if ($list) {
|
||||||
|
// Display all availabe tests.
|
||||||
|
echo("Available test groups:\n----------------------\n");
|
||||||
|
foreach ($test_instances as $group_test) {
|
||||||
|
echo($group_test->getLabel() . "\n");
|
||||||
|
}
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
if ($all) {
|
if ($all) {
|
||||||
$test_list = $tests;
|
$test_list = NULL;
|
||||||
}
|
|
||||||
else if ($class_names) {
|
|
||||||
foreach ($test_names as $test) {
|
|
||||||
if (isset($tests[$test])) {
|
|
||||||
$test_list[$test] = $tests[$test];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$groups = simpletest_categorize_tests($tests);
|
if ($class_names) {
|
||||||
foreach ($test_names as $test) {
|
$test_list = _run_tests_check_classes($test_names, $test_instances);
|
||||||
if (isset($groups[$test])) {
|
}
|
||||||
$test_list += $groups[$test];
|
else {
|
||||||
}
|
$test_list = _run_tests_find_classes($test_names, $test_instances);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($test_list) && !$all) {
|
if (empty($test_list) && !$all) {
|
||||||
echo("ERROR: No valid tests were specified.\n");
|
echo("ERROR: No valid tests were specified.\n");
|
||||||
exit;
|
exit;
|
||||||
|
@ -156,30 +171,55 @@ if (!ini_get('safe_mode')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell the user about what tests are to be run.
|
// Tell the user about what tests are to be run.
|
||||||
if (!$all) {
|
if (!$all && $reporter == 'text') {
|
||||||
echo("Tests to be run:\n");
|
echo("Tests to be run:\n");
|
||||||
foreach ($test_list as $instance) {
|
foreach ($test_list as $name) {
|
||||||
$info = $instance->getInfo();
|
echo("- " . $name . "\n");
|
||||||
echo("- " . $info['name'] . "\n");
|
|
||||||
}
|
}
|
||||||
echo("\n");
|
echo("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
db_query('INSERT INTO {simpletest_test_id} VALUES (default)');
|
simpletest_run_tests(array_keys($test_list), $reporter);
|
||||||
$test_id = db_last_insert_id('simpletest_test_id', 'test_id');
|
|
||||||
|
|
||||||
$test_results = array('#pass' => 0, '#fail' => 0, '#exception' => 0);
|
// Utility functions:
|
||||||
|
/**
|
||||||
|
* Check that each class name exists as a test, return the list of valid ones.
|
||||||
|
*/
|
||||||
|
function _run_tests_check_classes($test_names, $test_instances) {
|
||||||
|
$test_list = array();
|
||||||
|
$test_names = array_flip($test_names);
|
||||||
|
|
||||||
foreach ($test_list as $class => $instance) {
|
foreach ($test_instances as $group_test) {
|
||||||
$instance = new $class($test_id);
|
$tests = $group_test->getTestInstances();
|
||||||
$instance->run();
|
foreach ($tests as $test) {
|
||||||
$info = $instance->getInfo();
|
$class = get_class($test);
|
||||||
$test_results[$class] = $instance->_results;
|
$info = $test->getInfo();
|
||||||
foreach ($test_results[$class] as $key => $value) {
|
if (isset($test_names[$class])) {
|
||||||
$test_results[$key] += $value;
|
$test_list[$class] = $info['name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
echo(t('@name: @summary', array('@name' => $info['name'], '@summary' => _simpletest_format_summary_line($test_results[$class]))) . "\n");
|
return $test_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo(_simpletest_format_summary_line($test_results) . "\n");
|
/**
|
||||||
|
* Check that each group name exists, return the list of class in valid groups.
|
||||||
|
*/
|
||||||
|
function _run_tests_find_classes($test_names, &$test_instances) {
|
||||||
|
$test_list = array();
|
||||||
|
$test_names = array_flip($test_names);
|
||||||
|
|
||||||
|
uasort($test_instances, 'simpletest_compare_instances');
|
||||||
|
foreach ($test_instances as $group_test) {
|
||||||
|
$group = $group_test->getLabel();
|
||||||
|
if (isset($test_names[$group])) {
|
||||||
|
$tests = $group_test->getTestInstances();
|
||||||
|
foreach ($tests as $test) {
|
||||||
|
$info = $test->getInfo();
|
||||||
|
$test_list[get_class($test)] = $info['name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $test_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue