@@ -24,8 +24,11 @@ class TestDependencyCheck implements StaticCheckInterface
24
24
const EXTENDS_REGEX_PATTERN = '/extends=[" \']([^ \'"]*)/ ' ;
25
25
const ACTIONGROUP_REGEX_PATTERN = '/ref=[" \']([^ \'"]*)/ ' ;
26
26
27
- const ERROR_LOG_FILENAME = 'mftf-dependency-checks ' ;
27
+ const ERROR_LOG_FILENAME = 'mftf-dependency-checks-errors ' ;
28
28
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 ' ;
29
32
30
33
/**
31
34
* Array of FullModuleName => [dependencies], including flattened dependency tree
@@ -51,6 +54,17 @@ class TestDependencyCheck implements StaticCheckInterface
51
54
*/
52
55
private $ errors = [];
53
56
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
+
54
68
/**
55
69
* String representing the output summary found after running the execute() function.
56
70
* @var string
@@ -75,6 +89,11 @@ class TestDependencyCheck implements StaticCheckInterface
75
89
*/
76
90
private $ testDependencyUtil ;
77
91
92
+ /**
93
+ * @var array $allowFailureEntities
94
+ */
95
+ private $ allowFailureEntities = [];
96
+
78
97
/**
79
98
* Checks test dependencies, determined by references in tests versus the dependencies listed in the Magento module
80
99
*
@@ -93,6 +112,18 @@ public function execute(InputInterface $input)
93
112
"TEST DEPENDENCY CHECK ABORTED: MFTF must be attached or pointing to Magento codebase. "
94
113
);
95
114
}
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
+
96
127
$ registrar = new \Magento \Framework \Component \ComponentRegistrar ();
97
128
$ this ->moduleNameToPath = $ registrar ->getPaths (\Magento \Framework \Component \ComponentRegistrar::MODULE );
98
129
$ this ->moduleNameToComposerName = $ this ->testDependencyUtil ->buildModuleNameToComposerName (
@@ -124,6 +155,13 @@ public function execute(InputInterface $input)
124
155
StaticChecksList::getErrorFilesPath () . DIRECTORY_SEPARATOR . self ::ERROR_LOG_FILENAME . '.txt ' ,
125
156
self ::ERROR_LOG_MESSAGE
126
157
);
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
+ }
127
165
}
128
166
129
167
/**
@@ -199,6 +237,7 @@ private function findErrorsInFileSet(Finder $files): array
199
237
// Find violating references and set error output
200
238
$ violatingReferences = $ this ->findViolatingReferences ($ moduleName );
201
239
$ testErrors = array_merge ($ testErrors , $ this ->setErrorOutput ($ violatingReferences , $ filePath ));
240
+ $ this ->warnings = array_merge ($ this ->warnings , $ this ->setErrorOutput ($ this ->tempWarnings , $ filePath ));
202
241
}
203
242
return $ testErrors ;
204
243
}
@@ -221,6 +260,7 @@ private function findViolatingReferences(string $moduleName): array
221
260
);
222
261
$ moduleDependencies = $ this ->flattenedDependencies [$ moduleName ];
223
262
foreach ($ modulesReferencedInTest as $ entityName => $ files ) {
263
+ $ isInAllowList = array_key_exists ($ entityName , $ this ->allowFailureEntities );
224
264
$ valid = false ;
225
265
foreach ($ files as $ module ) {
226
266
if (array_key_exists ($ module , $ moduleDependencies ) || $ module === $ currentModule ) {
@@ -229,6 +269,10 @@ private function findViolatingReferences(string $moduleName): array
229
269
}
230
270
}
231
271
if (!$ valid ) {
272
+ if ($ isInAllowList ) {
273
+ $ this ->tempWarnings [$ entityName ] = $ files ;
274
+ continue ;
275
+ }
232
276
$ violatingReferences [$ entityName ] = $ files ;
233
277
}
234
278
}
0 commit comments