Révision b4adf10d
Ajouté par Assos Assos il y a plus de 9 ans
drupal7/scripts/run-tests.sh | ||
---|---|---|
419 | 419 |
else { |
420 | 420 |
if ($args['class']) { |
421 | 421 |
// Check for valid class names. |
422 |
foreach ($args['test_names'] as $class_name) { |
|
423 |
if (in_array($class_name, $all_tests)) { |
|
424 |
$test_list[] = $class_name; |
|
422 |
$test_list = array(); |
|
423 |
foreach ($args['test_names'] as $test_class) { |
|
424 |
if (class_exists($test_class)) { |
|
425 |
$test_list[] = $test_class; |
|
426 |
} |
|
427 |
else { |
|
428 |
$groups = simpletest_test_get_all(); |
|
429 |
$all_classes = array(); |
|
430 |
foreach ($groups as $group) { |
|
431 |
$all_classes = array_merge($all_classes, array_keys($group)); |
|
432 |
} |
|
433 |
simpletest_script_print_error('Test class not found: ' . $test_class); |
|
434 |
simpletest_script_print_alternatives($test_class, $all_classes, 6); |
|
435 |
exit(1); |
|
425 | 436 |
} |
426 | 437 |
} |
427 | 438 |
} |
... | ... | |
444 | 455 |
// Check for valid group names and get all valid classes in group. |
445 | 456 |
foreach ($args['test_names'] as $group_name) { |
446 | 457 |
if (isset($groups[$group_name])) { |
447 |
foreach ($groups[$group_name] as $class_name => $info) { |
|
448 |
$test_list[] = $class_name; |
|
449 |
} |
|
458 |
$test_list = array_merge($test_list, array_keys($groups[$group_name])); |
|
459 |
} |
|
460 |
else { |
|
461 |
simpletest_script_print_error('Test group not found: ' . $group_name); |
|
462 |
simpletest_script_print_alternatives($group_name, array_keys($groups)); |
|
463 |
exit(1); |
|
450 | 464 |
} |
451 | 465 |
} |
452 | 466 |
} |
... | ... | |
674 | 688 |
} |
675 | 689 |
return 0; // Default formatting. |
676 | 690 |
} |
691 |
|
|
692 |
/** |
|
693 |
* Prints alternative test names. |
|
694 |
* |
|
695 |
* Searches the provided array of string values for close matches based on the |
|
696 |
* Levenshtein algorithm. |
|
697 |
* |
|
698 |
* @see http://php.net/manual/en/function.levenshtein.php |
|
699 |
* |
|
700 |
* @param string $string |
|
701 |
* A string to test. |
|
702 |
* @param array $array |
|
703 |
* A list of strings to search. |
|
704 |
* @param int $degree |
|
705 |
* The matching strictness. Higher values return fewer matches. A value of |
|
706 |
* 4 means that the function will return strings from $array if the candidate |
|
707 |
* string in $array would be identical to $string by changing 1/4 or fewer of |
|
708 |
* its characters. |
|
709 |
*/ |
|
710 |
function simpletest_script_print_alternatives($string, $array, $degree = 4) { |
|
711 |
$alternatives = array(); |
|
712 |
foreach ($array as $item) { |
|
713 |
$lev = levenshtein($string, $item); |
|
714 |
if ($lev <= strlen($item) / $degree || FALSE !== strpos($string, $item)) { |
|
715 |
$alternatives[] = $item; |
|
716 |
} |
|
717 |
} |
|
718 |
if (!empty($alternatives)) { |
|
719 |
simpletest_script_print(" Did you mean?\n", SIMPLETEST_SCRIPT_COLOR_FAIL); |
|
720 |
foreach ($alternatives as $alternative) { |
|
721 |
simpletest_script_print(" - $alternative\n", SIMPLETEST_SCRIPT_COLOR_FAIL); |
|
722 |
} |
|
723 |
} |
|
724 |
} |
Formats disponibles : Unified diff
Udpate to 7.33