22
22
use RecursiveDirectoryIterator ;
23
23
use RecursiveIteratorIterator ;
24
24
use stdClass ;
25
+ use Throwable ;
25
26
26
27
use function yaml_parse ;
27
28
@@ -34,6 +35,10 @@ class YamlTests
34
35
const TEMPLATE_FUNCTION_SKIPPED = __DIR__ . '/template/test/function-skipped ' ;
35
36
const ELASTICSEARCH_GIT_URL = 'https://github.com/elastic/elasticsearch/tree/%s/rest-api-spec/src/main/resources/rest-api-spec/test/%s ' ;
36
37
38
+ const YAML_FILES_TO_OMIT = [
39
+ 'platinum/eql/10_basic.yml '
40
+ ];
41
+
37
42
const SKIPPED_TEST_OSS = [
38
43
'Cat\Nodeattrs\_10_BasicTest::TestCatNodesAttrsOutput ' => 'Regexp error, it seems not compatible with PHP ' ,
39
44
'Cat\Shards\_10_BasicTest::TestCatShardsOutput ' => 'Regexp error, it seems not compatible with PHP ' ,
@@ -142,22 +147,41 @@ private function getAllTests(string $dir): array
142
147
$ parsed = [];
143
148
// Iterate over the Yaml test files
144
149
foreach (new RecursiveIteratorIterator ($ it ) as $ file ) {
145
- if ($ file ->getExtension () === 'yml ' ) {
146
- $ content = file_get_contents ($ file ->getPathname ());
147
- $ content = str_replace (' y: ' , " 'y': " , $ content ); // replace "y:" with "'y':" due the y/true conversion in YAML 1.1
150
+ if ($ file ->getExtension () !== 'yml ' ) {
151
+ continue ;
152
+ }
153
+ $ omit = false ;
154
+ foreach (self ::YAML_FILES_TO_OMIT as $ fileOmit ) {
155
+ if (false !== strpos ($ file ->getPathname (), $ fileOmit )) {
156
+ $ omit = true ;
157
+ break ;
158
+ }
159
+ }
160
+ if ($ omit ) {
161
+ continue ;
162
+ }
163
+ $ content = file_get_contents ($ file ->getPathname ());
164
+ $ content = str_replace (' y: ' , " 'y': " , $ content ); // replace "y:" with "'y':" due the y/true conversion in YAML 1.1
165
+ try {
148
166
$ test = yaml_parse ($ content , -1 , $ ndocs , [
149
167
YAML_MAP_TAG => function ($ value , $ tag , $ flags ) {
150
168
return empty ($ value ) ? new stdClass : $ value ;
151
169
}
152
170
]);
153
- if (false === $ test ) {
154
- throw new Exception (sprintf (
155
- "YAML parse error file %s " ,
156
- $ file ->getPathname ()
157
- ));
158
- }
159
- $ parsed [$ file ->getPathname ()] = $ test ;
171
+ } catch (Throwable $ e ) {
172
+ throw new Exception (sprintf (
173
+ "YAML parse error file %s: %s " ,
174
+ $ file ->getPathname (),
175
+ $ e ->getMessage ()
176
+ ));
177
+ }
178
+ if (false === $ test ) {
179
+ throw new Exception (sprintf (
180
+ "YAML parse error file %s " ,
181
+ $ file ->getPathname ()
182
+ ));
160
183
}
184
+ $ parsed [$ file ->getPathname ()] = $ test ;
161
185
}
162
186
return $ parsed ;
163
187
}
0 commit comments