function drush_test_run

6.x test.drush.inc drush_test_run($specs = NULL)
4.x test.drush.inc drush_test_run($specs = NULL)
5.x test.drush.inc drush_test_run($specs = NULL)

Test-run command callback.

@specs A comman delimited string of test classes or group names.

File

commands/core/test.drush.inc, line 68
Simpletest module drush integration.

Code

function drush_test_run($specs = NULL) {
  cache_clear_all('simpletest', 'cache');

  // Retrieve all tests and groups.
  list($groups, $all_tests) = drush_test_get_all_tests();

  if (drush_get_option('all')) {
    // Run all tests.
    foreach (array_keys($groups) as $group) {
      foreach (array_keys($groups[$group]) as $class) {
        drush_backend_invoke_args('test-run', array($class), array('--no-all'));
      }
    }
    return;
  }
  elseif (empty($specs)) {
    return drush_test_list($groups);
  }

  foreach (explode(',', $specs) as $spec) {
    $spec = trim($spec);
    // Specific test class specified.
    if (in_array($spec, $all_tests)) {
      simpletest_drush_run_test($spec);
      if (!drush_get_option('dirty')) {
        simpletest_clean_environment();
      }
    }
    // Specific group specified.
    else if (isset($groups[$spec])) {
      foreach (array_keys($groups[$spec]) as $class) {
        drush_do_command_redispatch('test-run', array($class));
      }
    }
  }
}