comparison core/scripts/run-tests.sh @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents c2387f117808
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
62 if ($args['list']) { 62 if ($args['list']) {
63 // Display all available tests. 63 // Display all available tests.
64 echo "\nAvailable test groups & classes\n"; 64 echo "\nAvailable test groups & classes\n";
65 echo "-------------------------------\n\n"; 65 echo "-------------------------------\n\n";
66 try { 66 try {
67 $groups = simpletest_test_get_all($args['module']); 67 $groups = \Drupal::service('test_discovery')->getTestClasses($args['module']);
68 } 68 }
69 catch (Exception $e) { 69 catch (Exception $e) {
70 error_log((string) $e); 70 error_log((string) $e);
71 echo (string) $e; 71 echo (string) $e;
72 exit(SIMPLETEST_SCRIPT_EXIT_EXCEPTION); 72 exit(SIMPLETEST_SCRIPT_EXIT_EXCEPTION);
123 exit(SIMPLETEST_SCRIPT_EXIT_EXCEPTION); 123 exit(SIMPLETEST_SCRIPT_EXIT_EXCEPTION);
124 } 124 }
125 echo "\nEnvironment cleaned.\n"; 125 echo "\nEnvironment cleaned.\n";
126 126
127 // Get the status messages and print them. 127 // Get the status messages and print them.
128 $messages = drupal_get_messages('status'); 128 $messages = \Drupal::messenger()->messagesByType('status');
129 foreach ($messages['status'] as $text) { 129 foreach ($messages as $text) {
130 echo " - " . $text . "\n"; 130 echo " - " . $text . "\n";
131 } 131 }
132 exit(SIMPLETEST_SCRIPT_EXIT_SUCCESS); 132 exit(SIMPLETEST_SCRIPT_EXIT_SUCCESS);
133 } 133 }
134 134
138 } 138 }
139 else { 139 else {
140 $phpunit_version = Version::id(); 140 $phpunit_version = Version::id();
141 } 141 }
142 if (!Composer::upgradePHPUnitCheck($phpunit_version)) { 142 if (!Composer::upgradePHPUnitCheck($phpunit_version)) {
143 simpletest_script_print_error("PHPUnit testing framework version 6 or greater is required when running on PHP 7.2 or greater. Run the command 'composer run-script drupal-phpunit-upgrade' in order to fix this."); 143 simpletest_script_print_error("PHPUnit testing framework version 6 or greater is required when running on PHP 7.0 or greater. Run the command 'composer run-script drupal-phpunit-upgrade' in order to fix this.");
144 exit(SIMPLETEST_SCRIPT_EXIT_FAILURE); 144 exit(SIMPLETEST_SCRIPT_EXIT_FAILURE);
145 } 145 }
146 146
147 $test_list = simpletest_script_get_test_list(); 147 $test_list = simpletest_script_get_test_list();
148 148
308 --non-html Removes escaping from output. Useful for reading results on the 308 --non-html Removes escaping from output. Useful for reading results on the
309 CLI. 309 CLI.
310 310
311 --suppress-deprecations 311 --suppress-deprecations
312 312
313 Stops tests from failing if deprecation errors are triggered. 313 Stops tests from failing if deprecation errors are triggered. If
314 this is not set the value specified in the
315 SYMFONY_DEPRECATIONS_HELPER environment variable, or the value
316 specified in core/phpunit.xml (if it exists), or the default value
317 will be used. The default is that any unexpected silenced
318 deprecation error will fail tests.
314 319
315 <test1>[,<test2>[,<test3> ...]] 320 <test1>[,<test2>[,<test3> ...]]
316 321
317 One or more tests to be run. By default, these are interpreted 322 One or more tests to be run. By default, these are interpreted
318 as the names of test groups as shown at 323 as the names of test groups as shown at
823 } 828 }
824 $test = new $class_name($test_id); 829 $test = new $class_name($test_id);
825 if ($args['suppress-deprecations']) { 830 if ($args['suppress-deprecations']) {
826 putenv('SYMFONY_DEPRECATIONS_HELPER=disabled'); 831 putenv('SYMFONY_DEPRECATIONS_HELPER=disabled');
827 } 832 }
828 else {
829 // Prevent deprecations caused by vendor code calling deprecated code.
830 // This also prevents mock objects in PHPUnit 6 triggering silenced
831 // deprecations from breaking the test suite. We should consider changing
832 // this to 'strict' once PHPUnit 4 is no longer used.
833 putenv('SYMFONY_DEPRECATIONS_HELPER=weak_vendors');
834 }
835 if (is_subclass_of($test_class, TestCase::class)) { 833 if (is_subclass_of($test_class, TestCase::class)) {
836 $status = simpletest_script_run_phpunit($test_id, $test_class); 834 $status = simpletest_script_run_phpunit($test_id, $test_class);
837 } 835 }
838 else { 836 else {
839 $test->dieOnFail = (bool) $args['die-on-fail']; 837 $test->dieOnFail = (bool) $args['die-on-fail'];
1002 * List of tests. 1000 * List of tests.
1003 */ 1001 */
1004 function simpletest_script_get_test_list() { 1002 function simpletest_script_get_test_list() {
1005 global $args; 1003 global $args;
1006 1004
1005 /** $test_discovery \Drupal\simpletest\TestDiscovery */
1006 $test_discovery = \Drupal::service('test_discovery');
1007 $types_processed = empty($args['types']); 1007 $types_processed = empty($args['types']);
1008 $test_list = []; 1008 $test_list = [];
1009 if ($args['all'] || $args['module']) { 1009 if ($args['all'] || $args['module']) {
1010 try { 1010 try {
1011 $groups = simpletest_test_get_all($args['module'], $args['types']); 1011 $groups = $test_discovery->getTestClasses($args['module'], $args['types']);
1012 $types_processed = TRUE; 1012 $types_processed = TRUE;
1013 } 1013 }
1014 catch (Exception $e) { 1014 catch (Exception $e) {
1015 echo (string) $e; 1015 echo (string) $e;
1016 exit(SIMPLETEST_SCRIPT_EXIT_EXCEPTION); 1016 exit(SIMPLETEST_SCRIPT_EXIT_EXCEPTION);
1029 if (class_exists($class_name)) { 1029 if (class_exists($class_name)) {
1030 $test_list[] = $test_class; 1030 $test_list[] = $test_class;
1031 } 1031 }
1032 else { 1032 else {
1033 try { 1033 try {
1034 $groups = simpletest_test_get_all(NULL, $args['types']); 1034 $groups = $test_discovery->getTestClasses(NULL, $args['types']);
1035 } 1035 }
1036 catch (Exception $e) { 1036 catch (Exception $e) {
1037 echo (string) $e; 1037 echo (string) $e;
1038 exit(SIMPLETEST_SCRIPT_EXIT_EXCEPTION); 1038 exit(SIMPLETEST_SCRIPT_EXIT_EXCEPTION);
1039 } 1039 }
1130 } 1130 }
1131 } 1131 }
1132 } 1132 }
1133 else { 1133 else {
1134 try { 1134 try {
1135 $groups = simpletest_test_get_all(NULL, $args['types']); 1135 $groups = $test_discovery->getTestClasses(NULL, $args['types']);
1136 $types_processed = TRUE; 1136 $types_processed = TRUE;
1137 } 1137 }
1138 catch (Exception $e) { 1138 catch (Exception $e) {
1139 echo (string) $e; 1139 echo (string) $e;
1140 exit(SIMPLETEST_SCRIPT_EXIT_EXCEPTION); 1140 exit(SIMPLETEST_SCRIPT_EXIT_EXCEPTION);