Skip to content
Snippets Groups Projects
Commit fa4c50a8 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2841948 by Mile23, dawehner: Modify run-tests.sh to show file paths of all discovered tests

parent f182e9d2
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -89,6 +89,36 @@ ...@@ -89,6 +89,36 @@
exit(SIMPLETEST_SCRIPT_EXIT_SUCCESS); exit(SIMPLETEST_SCRIPT_EXIT_SUCCESS);
} }
// List-files and list-files-json provide a way for external tools such as the
// testbot to prioritize running changed tests.
// @see https://www.drupal.org/node/2569585
if ($args['list-files'] || $args['list-files-json']) {
// List all files which could be run as tests.
$test_discovery = NULL;
try {
$test_discovery = \Drupal::service('test_discovery');
} catch (Exception $e) {
error_log((string) $e);
echo (string)$e;
exit(SIMPLETEST_SCRIPT_EXIT_EXCEPTION);
}
// TestDiscovery::findAllClassFiles() gives us a classmap similar to a
// Composer 'classmap' array.
$test_classes = $test_discovery->findAllClassFiles();
// JSON output is the easiest.
if ($args['list-files-json']) {
echo json_encode($test_classes);
exit(SIMPLETEST_SCRIPT_EXIT_SUCCESS);
}
// Output the list of files.
else {
foreach(array_values($test_classes) as $test_class) {
echo $test_class . "\n";
}
}
exit(SIMPLETEST_SCRIPT_EXIT_SUCCESS);
}
simpletest_script_setup_database(TRUE); simpletest_script_setup_database(TRUE);
if ($args['clean']) { if ($args['clean']) {
...@@ -178,6 +208,14 @@ function simpletest_script_help() { ...@@ -178,6 +208,14 @@ function simpletest_script_help() {
--list Display all available test groups. --list Display all available test groups.
--list-files
Display all discoverable test file paths.
--list-files-json
Display all discoverable test files as JSON. The array key will be
the test class name, and the value will be the file path of the
test.
--clean Cleans up database tables or directories from previous, failed, --clean Cleans up database tables or directories from previous, failed,
tests and then exits (no tests are run). tests and then exits (no tests are run).
...@@ -309,6 +347,8 @@ function simpletest_script_parse_args() { ...@@ -309,6 +347,8 @@ function simpletest_script_parse_args() {
'script' => '', 'script' => '',
'help' => FALSE, 'help' => FALSE,
'list' => FALSE, 'list' => FALSE,
'list-files' => FALSE,
'list-files-json' => FALSE,
'clean' => FALSE, 'clean' => FALSE,
'url' => '', 'url' => '',
'sqlite' => NULL, 'sqlite' => NULL,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment