Mercurial > hg > cmmr2012-drupal-site
diff core/scripts/run-tests.sh @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
line wrap: on
line diff
--- a/core/scripts/run-tests.sh Thu Feb 28 13:11:55 2019 +0000 +++ b/core/scripts/run-tests.sh Thu May 09 15:34:47 2019 +0100 @@ -12,6 +12,8 @@ use Drupal\Core\Composer\Composer; use Drupal\Core\Asset\AttachedAssets; use Drupal\Core\Database\Database; +use Drupal\Core\File\Exception\FileException; +use Drupal\Core\File\FileSystemInterface; use Drupal\Core\StreamWrapper\PublicStream; use Drupal\Core\Test\TestDatabase; use Drupal\Core\Test\TestRunnerKernel; @@ -60,7 +62,7 @@ } if ($args['list']) { - // Display all available tests. + // Display all available tests organized by one @group annotation. echo "\nAvailable test groups & classes\n"; echo "-------------------------------\n\n"; try { @@ -71,11 +73,18 @@ echo (string) $e; exit(SIMPLETEST_SCRIPT_EXIT_EXCEPTION); } + + // A given class can appear in multiple groups. For historical reasons, we + // need to present each test only once. The test is shown in the group that is + // printed first. + $printed_tests = []; foreach ($groups as $group => $tests) { echo $group . "\n"; - foreach ($tests as $class => $info) { - echo " - $class\n"; + $tests = array_diff(array_keys($tests), $printed_tests); + foreach ($tests as $test) { + echo " - $test\n"; } + $printed_tests = array_merge($printed_tests, $tests); } exit(SIMPLETEST_SCRIPT_EXIT_SUCCESS); } @@ -962,8 +971,13 @@ // simpletest_clean_temporary_directories() cannot be used here, since it // would also delete file directories of other tests that are potentially // running concurrently. - file_unmanaged_delete_recursive($test_directory, ['Drupal\simpletest\TestBase', 'filePreDeleteCallback']); - $messages[] = "- Removed test site directory."; + try { + \Drupal::service('file_system')->deleteRecursive($test_directory, ['Drupal\simpletest\TestBase', 'filePreDeleteCallback']); + $messages[] = "- Removed test site directory."; + } + catch (FileException $e) { + // Ignore failed deletes. + } } // Clear out all database tables from the test. @@ -1019,7 +1033,7 @@ foreach ($groups as $group => $tests) { $all_tests = array_merge($all_tests, array_keys($tests)); } - $test_list = $all_tests; + $test_list = array_unique($all_tests); } else { if ($args['class']) { @@ -1139,16 +1153,20 @@ echo (string) $e; exit(SIMPLETEST_SCRIPT_EXIT_EXCEPTION); } + // Store all the groups so we can suggest alternatives if we need to. + $all_groups = array_keys($groups); + // Verify that the groups exist. + if (!empty($unknown_groups = array_diff($args['test_names'], $all_groups))) { + $first_group = reset($unknown_groups); + simpletest_script_print_error('Test group not found: ' . $first_group); + simpletest_script_print_alternatives($first_group, $all_groups); + exit(SIMPLETEST_SCRIPT_EXIT_FAILURE); + } + // Ensure our list of tests contains only one entry for each test. foreach ($args['test_names'] as $group_name) { - if (isset($groups[$group_name])) { - $test_list = array_merge($test_list, array_keys($groups[$group_name])); - } - else { - simpletest_script_print_error('Test group not found: ' . $group_name); - simpletest_script_print_alternatives($group_name, array_keys($groups)); - exit(SIMPLETEST_SCRIPT_EXIT_FAILURE); - } + $test_list = array_merge($test_list, array_flip(array_keys($groups[$group_name]))); } + $test_list = array_flip($test_list); } } @@ -1565,7 +1583,7 @@ // Ensure we have assets verbose directory - tests with no verbose output will // not have created one. $directory = PublicStream::basePath() . '/simpletest/verbose'; - file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); + \Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS); $php = new Php(); $uuid = $php->generate(); $filename = $directory . '/results-' . $uuid . '.html';