Index: drush_simpletest.module =================================================================== --- drush_simpletest.module (revision 884) +++ drush_simpletest.module (working copy) @@ -12,9 +12,13 @@ function drush_simpletest_help($section) { switch ($section) { case 'drush:test run': - return t("Usage drush [options] test run.\n\nRun the specified specified unit tests. If is omitted, all tests are run. should be a list of classes separated by a comma. For example: PageCreationTest,PageViewTest."); + return t("Usage drush [options] test run .\n\nRun the specified unit tests. If is omitted, all tests are run. should be a list of classes separated by a comma. For example: PageCreationTest,PageViewTest."); case 'drush:test list': return t("Usage drush [options] test list.\n\nList the available tests. Use drush test run command to run them. "); + case 'drush:test group': + return t("Usage drush [options] test group .\n\nRun all unit tests in the specified groups. For example: drush test group Group1,Group2"); + case 'drush:test re': + return t("Usage drush [options] test re .\n\nRun all unit tests matching this regular expression. For example: drush test re Page.*"); } } @@ -30,10 +34,18 @@ 'callback' => 'drush_test_list', 'description' => 'List the available Simpletest test classes.', ); + $items['test re'] = array( + 'callback' => 'drush_test_re', + 'description' => 'Run one or more Simpletest tests based on regular expressions.', + ); + $items['test group'] = array( + 'callback' => 'drush_test_group', + 'description' => 'Run one or more Simpletest test groups.', + ); return $items; } -function drush_test_list() { +function drush_test_get_list() { simpletest_load(); // TODO: Refactor simpletest.module so we don't copy code from DrupalUnitTests $files = array(); @@ -60,6 +72,11 @@ $rows[] = array($class, $info['name'], truncate_utf8($info['desc'], 30, TRUE, TRUE)); } } + return $rows; +} + +function drush_test_list() { + $rows = drush_test_get_list(); return drush_print_table($rows, 0, TRUE); } @@ -75,3 +92,31 @@ } return $result; } + +function drush_test_re($expression) { + if (!$expression) { + die('You must specify a regular expression.'); + } + $rows = drush_test_get_list(); + $tests = array(); + foreach ($rows as $row) { + if (ereg($expression, $row[0])) { + $tests[] = $row[0]; + } + } + simpletest_run_tests($tests, 'text'); + return $result; +} + +function drush_test_group($groups) { + $rows = drush_test_get_list(); + $tests = array(); + $groups = explode(',', $groups); + foreach ($rows as $row) { + if (in_array($row[1], $groups)) { + $tests[] = $row[0]; + } + } + simpletest_run_tests($tests, 'text'); + return $result; +}