Skip to content
Snippets Groups Projects
Commit d0685981 authored by Kunal Sachdev's avatar Kunal Sachdev Committed by Adam G-H
Browse files

Issue #3306163 by kunal.sachdev: Also skip info.yml files in more test...

Issue #3306163 by kunal.sachdev:  Also skip info.yml files in more test directories in DuplicateInfoFileValidator
parent 7f45a8ab
No related branches found
No related tags found
1 merge request!454Issue #3306163: Also skip info.yml files in more test directories in DuplicateInfoFileValidator
......@@ -99,13 +99,7 @@ class DuplicateInfoFileValidator implements EventSubscriberInterface {
$info_files = [];
/** @var \Symfony\Component\Finder\SplFileInfo $info_file */
foreach (iterator_to_array($info_files_finder) as $info_file) {
// Skipping info.yml files in tests/fixtures because Drupal will not scan
// these directories when doing extension discovery.
//
// @todo We should also skip info.yml files in tests/modules,
// tests/themes, and tests/profiles directories in
// https://www.drupal.org/i/3306163.
if (strpos($info_file->getPath(), DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'fixtures') !== FALSE) {
if ($this->skipInfoFile($info_file->getPath())) {
continue;
}
$file_name = $info_file->getFilename();
......@@ -114,4 +108,31 @@ class DuplicateInfoFileValidator implements EventSubscriberInterface {
return $info_files;
}
/**
* Determines if an info.yml file should be skipped.
*
* @param string $info_file_path
* The path of the info.yml file.
*
* @return bool
* TRUE if the info.yml file should be skipped, FALSE otherwise.
*/
private function skipInfoFile(string $info_file_path): bool {
$directories_to_skip = [
DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'fixtures',
DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'modules',
DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'themes',
DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'profiles',
];
foreach ($directories_to_skip as $directory_to_skip) {
// Skipping info.yml files in tests/fixtures, tests/modules, tests/themes,
// tests/profiles because Drupal will not scan these directories when
// doing extension discovery.
if (str_contains($info_file_path, $directory_to_skip)) {
return TRUE;
}
}
return FALSE;
}
}
......@@ -47,7 +47,7 @@ class DuplicateInfoFileValidatorTest extends PackageManagerKernelTestBase {
],
[],
],
'Duplicate info.yml files in stage with one file in tests folder' => [
'Duplicate info.yml files in stage with one file in tests/fixtures folder' => [
[
'/tests/fixtures/module.info.yml',
],
......@@ -57,6 +57,36 @@ class DuplicateInfoFileValidatorTest extends PackageManagerKernelTestBase {
],
[],
],
'Duplicate info.yml files in stage with one file in tests/modules folder' => [
[
'/tests/modules/module.info.yml',
],
[
'/tests/modules/module.info.yml',
'/modules/module.info.yml',
],
[],
],
'Duplicate info.yml files in stage with one file in tests/themes folder' => [
[
'/tests/themes/theme.info.yml',
],
[
'/tests/themes/theme.info.yml',
'/themes/theme.info.yml',
],
[],
],
'Duplicate info.yml files in stage with one file in tests/profiles folder' => [
[
'/tests/profiles/profile.info.yml',
],
[
'/tests/profiles/profile.info.yml',
'/profiles/profile.info.yml',
],
[],
],
'Duplicate info.yml files in stage not present in active' => [
[],
[
......
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