mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 09:26:35 +02:00
MDL-52721 unittest: Exclude tests in vendor and node_modules
This commit is contained in:
parent
e8d5100212
commit
60237c2ce2
1 changed files with 23 additions and 8 deletions
|
@ -125,16 +125,31 @@ class tests_finder {
|
|||
private static function get_all_directories_with_tests($testtype) {
|
||||
global $CFG;
|
||||
|
||||
// List of directories to exclude from test file searching.
|
||||
$excludedir = array('node_modules', 'vendor');
|
||||
|
||||
// Get first level directories in which tests should be searched.
|
||||
$directoriestosearch = array();
|
||||
$alldirs = glob($CFG->dirroot . DIRECTORY_SEPARATOR . '*' , GLOB_ONLYDIR);
|
||||
foreach ($alldirs as $dir) {
|
||||
if (!in_array(basename($dir), $excludedir)) {
|
||||
$directoriestosearch[] = $dir;
|
||||
}
|
||||
}
|
||||
|
||||
// Search for tests in valid directories.
|
||||
$dirs = array();
|
||||
$dirite = new RecursiveDirectoryIterator($CFG->dirroot);
|
||||
foreach ($directoriestosearch as $dir) {
|
||||
$dirite = new RecursiveDirectoryIterator($dir);
|
||||
$iteite = new RecursiveIteratorIterator($dirite);
|
||||
$regexp = self::get_regexp($testtype);
|
||||
$regite = new RegexIterator($iteite, $regexp);
|
||||
foreach ($regite as $path => $element) {
|
||||
$key = dirname(dirname($path));
|
||||
$value = trim(str_replace('/', '_', str_replace($CFG->dirroot, '', $key)), '_');
|
||||
$value = trim(str_replace(DIRECTORY_SEPARATOR, '_', str_replace($CFG->dirroot, '', $key)), '_');
|
||||
$dirs[$key] = $value;
|
||||
}
|
||||
}
|
||||
ksort($dirs);
|
||||
return array_flip($dirs);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue