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 comma delimited string of test classes or group names.

File

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

Code

function drush_test_run($specs = NULL) {
  if (drush_drupal_major_version() > 7) {
    cache()->delete('simpletest');
  }
  else {
    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_invoke_process('@self', 'test-run', array($class));
      }
    }
    return;
  }
  elseif (empty($specs)) {
    // No argument so list all groups/classes.
    return drush_test_list($groups);
  }
  elseif (strpos($specs, ',') === FALSE && in_array($specs, $all_tests)) {
    // We got one, valid class. Good, now run it.
    simpletest_drush_run_test($specs);
    if (!drush_get_option('dirty')) {
      simpletest_clean_environment();
    }
    return drush_get_error() === DRUSH_SUCCESS;
  }

  // See if we got a list of specs.
  foreach (explode(',', $specs) as $spec) {
    $spec = trim($spec);
    if (in_array($spec, $all_tests)) {
      // Specific test class specified.
      drush_test_run_class($spec);
    }
    if (isset($groups[$spec])) {
      // Specific group specified.
      foreach (array_keys($groups[$spec]) as $class) {
        drush_test_run_class($class);
      }
    }
  }
}