@@ -24,8 +24,11 @@ class TestDependencyCheck implements StaticCheckInterface
2424 const EXTENDS_REGEX_PATTERN = '/extends=[" \']([^ \'"]*)/ ' ;
2525 const ACTIONGROUP_REGEX_PATTERN = '/ref=[" \']([^ \'"]*)/ ' ;
2626
27- const ERROR_LOG_FILENAME = 'mftf-dependency-checks ' ;
27+ const ERROR_LOG_FILENAME = 'mftf-dependency-checks-errors ' ;
2828 const ERROR_LOG_MESSAGE = 'MFTF File Dependency Check ' ;
29+ const WARNING_LOG_FILENAME = 'mftf-dependency-checks-warnings ' ;
30+
31+ const ALLOW_LIST_FILENAME = 'test-dependency-allowlist ' ;
2932
3033 /**
3134 * Array of FullModuleName => [dependencies], including flattened dependency tree
@@ -51,6 +54,17 @@ class TestDependencyCheck implements StaticCheckInterface
5154 */
5255 private $ errors = [];
5356
57+ /**
58+ * Array containing all warnings found after running the execute() function.
59+ * @var array
60+ */
61+ private $ warnings = [];
62+ /**
63+ * Array containing warnings found while iterating through files
64+ * @var array
65+ */
66+ private $ tempWarnings = [];
67+
5468 /**
5569 * String representing the output summary found after running the execute() function.
5670 * @var string
@@ -75,6 +89,11 @@ class TestDependencyCheck implements StaticCheckInterface
7589 */
7690 private $ testDependencyUtil ;
7791
92+ /**
93+ * @var array $allowFailureEntities
94+ */
95+ private $ allowFailureEntities = [];
96+
7897 /**
7998 * Checks test dependencies, determined by references in tests versus the dependencies listed in the Magento module
8099 *
@@ -93,6 +112,18 @@ public function execute(InputInterface $input)
93112 "TEST DEPENDENCY CHECK ABORTED: MFTF must be attached or pointing to Magento codebase. "
94113 );
95114 }
115+
116+ // Build array of entities found in allow-list files
117+ // Expect one entity per file line, no commas or anything else
118+ foreach ($ allModules as $ modulePath ) {
119+ if (file_exists ($ modulePath . DIRECTORY_SEPARATOR . self ::ALLOW_LIST_FILENAME )) {
120+ $ contents = file_get_contents ($ modulePath . DIRECTORY_SEPARATOR . self ::ALLOW_LIST_FILENAME );
121+ foreach (explode ("\n" , $ contents ) as $ entity ) {
122+ $ this ->allowFailureEntities [$ entity ] = true ;
123+ }
124+ }
125+ }
126+
96127 $ registrar = new \Magento \Framework \Component \ComponentRegistrar ();
97128 $ this ->moduleNameToPath = $ registrar ->getPaths (\Magento \Framework \Component \ComponentRegistrar::MODULE );
98129 $ this ->moduleNameToComposerName = $ this ->testDependencyUtil ->buildModuleNameToComposerName (
@@ -124,6 +155,13 @@ public function execute(InputInterface $input)
124155 StaticChecksList::getErrorFilesPath () . DIRECTORY_SEPARATOR . self ::ERROR_LOG_FILENAME . '.txt ' ,
125156 self ::ERROR_LOG_MESSAGE
126157 );
158+ if (!empty ($ this ->warnings )) {
159+ $ this ->output .= "\n " . $ this ->scriptUtil ->printWarningsToFile (
160+ $ this ->warnings ,
161+ StaticChecksList::getErrorFilesPath () . DIRECTORY_SEPARATOR . self ::WARNING_LOG_FILENAME . '.txt ' ,
162+ self ::ERROR_LOG_MESSAGE
163+ );
164+ }
127165 }
128166
129167 /**
@@ -199,6 +237,7 @@ private function findErrorsInFileSet(Finder $files): array
199237 // Find violating references and set error output
200238 $ violatingReferences = $ this ->findViolatingReferences ($ moduleName );
201239 $ testErrors = array_merge ($ testErrors , $ this ->setErrorOutput ($ violatingReferences , $ filePath ));
240+ $ this ->warnings = array_merge ($ this ->warnings , $ this ->setErrorOutput ($ this ->tempWarnings , $ filePath ));
202241 }
203242 return $ testErrors ;
204243 }
@@ -221,6 +260,7 @@ private function findViolatingReferences(string $moduleName): array
221260 );
222261 $ moduleDependencies = $ this ->flattenedDependencies [$ moduleName ];
223262 foreach ($ modulesReferencedInTest as $ entityName => $ files ) {
263+ $ isInAllowList = array_key_exists ($ entityName , $ this ->allowFailureEntities );
224264 $ valid = false ;
225265 foreach ($ files as $ module ) {
226266 if (array_key_exists ($ module , $ moduleDependencies ) || $ module === $ currentModule ) {
@@ -229,6 +269,10 @@ private function findViolatingReferences(string $moduleName): array
229269 }
230270 }
231271 if (!$ valid ) {
272+ if ($ isInAllowList ) {
273+ $ this ->tempWarnings [$ entityName ] = $ files ;
274+ continue ;
275+ }
232276 $ violatingReferences [$ entityName ] = $ files ;
233277 }
234278 }
0 commit comments