Index: simpletest.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.module,v
retrieving revision 1.3
diff -u -b -u -p -r1.3 simpletest.module
--- simpletest.module	10 May 2008 07:46:22 -0000	1.3
+++ simpletest.module	28 May 2008 08:01:16 -0000
@@ -33,6 +33,20 @@ function simpletest_menu() {
     'page arguments' => array('simpletest_settings'),
     'access arguments' => array('access administration pages'),
   );
+  $items['admin/reports/simpletest'] = array(
+    'title' => 'Testing',
+    'description' => 'Run tests against Drupal core and your active modules. These tests help assure that your site code is working as designed.',
+    'page callback' => 'simpletest_test_overview',
+    'access arguments' => array('administer unit tests'),
+    'type' => MENU_NORMAL_ITEM,
+  );
+  $items['admin/reports/simpletest/run'] = array(
+    'title' => 'Run tests',
+    'description' => 'Run tests against Drupal core and you active modules.',
+    'page callback' => 'simpletest_run',
+    'access arguments' => array('administer unit tests'),
+    'type' => MENU_CALLBACK,
+  );
   return $items;
 }
 
@@ -475,3 +489,58 @@ function simpletest_settings() {
   return system_settings_form($form);
 
 }
+
+/**
+ * Page callback for generating a list of all available SimpleTest test
+ * with url's to callbacks that run these tests
+ */
+function simpletest_test_overview() {
+  // load the required simple test includes
+  $output = '';
+  simpletest_load();
+
+  $items = array();
+  $test_suite = new DrupalTests();
+  // iterate over the test groups in the test suite
+  foreach ($test_suite->getTestInstances() as $test_group) {
+    $group_name = $test_group->getLabel();
+
+    $group_test_classes = array();
+    // iterate over the test classes in the test group
+    foreach ($test_group->getTestInstances() as $test) {
+      $test_info = $test->getInfo();
+      $test_name = $test_info['name'];
+      $test_desc = $test_info['description'];
+      $test_class = get_class($test);
+      $group_test_classes[] = $test_class;
+      // add test class to group list
+      $items[$group_name]['children'][] = t('!testurl: !descr', array(
+        '!testurl' => l($test_name, 'admin/reports/simpletest/run/' . $test_class, array('attributes' => array('title' => check_plain($test_class)))),
+        '!descr' => filter_xss($test_desc),
+      ));
+    }
+    // add test group to list
+    $items[$group_name]['data'] = t('@group_name (<a href="!testurl">run all</a>):', array(
+      '@group_name' => $group_name,
+      '!testurl' => url('admin/reports/simpletest/run/' . join(',', $group_test_classes))
+    ));
+  }
+
+  // render as item list
+  $output .= theme('item_list', $items);
+
+  return $output;
+}
+
+/**
+ * Page callback for running the SimpleTest tests
+ */
+function simpletest_run($test_classes=NULL) {
+  $output = '';
+  if (!$test_classes) {
+    drupal_set_message(t('No tests requested.'));
+    return $output;
+  }
+  $test_classes = explode(',', $test_classes);
+  return simpletest_run_tests($test_classes);
+}
