|
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 |
|
@@ -147,22 +148,41 @@ private function getAllTests(string $dir): array
|
147 | 148 | $parsed = [];
|
148 | 149 | // Iterate over the Yaml test files
|
149 | 150 | foreach (new RecursiveIteratorIterator($it) as $file) {
|
150 |
| - if ($file->getExtension() === 'yml') { |
151 |
| - $content = file_get_contents($file->getPathname()); |
152 |
| - $content = str_replace(' y: ', " 'y': ", $content); // replace "y:" with "'y':" due the y/true conversion in YAML 1.1 |
| 151 | + if ($file->getExtension() !== 'yml') { |
| 152 | + continue; |
| 153 | + } |
| 154 | + $omit = false; |
| 155 | + foreach (self::YAML_FILES_TO_OMIT as $fileOmit) { |
| 156 | + if (false !== strpos($file->getPathname(), $fileOmit)) { |
| 157 | + $omit = true; |
| 158 | + break; |
| 159 | + } |
| 160 | + } |
| 161 | + if ($omit) { |
| 162 | + continue; |
| 163 | + } |
| 164 | + $content = file_get_contents($file->getPathname()); |
| 165 | + $content = str_replace(' y: ', " 'y': ", $content); // replace "y:" with "'y':" due the y/true conversion in YAML 1.1 |
| 166 | + try { |
153 | 167 | $test = yaml_parse($content, -1, $ndocs, [
|
154 | 168 | YAML_MAP_TAG => function($value, $tag, $flags) {
|
155 | 169 | return empty($value) ? new stdClass : $value;
|
156 | 170 | }
|
157 | 171 | ]);
|
158 |
| - if (false === $test) { |
159 |
| - throw new Exception(sprintf( |
160 |
| - "YAML parse error file %s", |
161 |
| - $file->getPathname() |
162 |
| - )); |
163 |
| - } |
164 |
| - $parsed[$file->getPathname()] = $test; |
| 172 | + } catch (Throwable $e) { |
| 173 | + throw new Exception(sprintf( |
| 174 | + "YAML parse error file %s: %s", |
| 175 | + $file->getPathname(), |
| 176 | + $e->getMessage() |
| 177 | + )); |
| 178 | + } |
| 179 | + if (false === $test) { |
| 180 | + throw new Exception(sprintf( |
| 181 | + "YAML parse error file %s", |
| 182 | + $file->getPathname() |
| 183 | + )); |
165 | 184 | }
|
| 185 | + $parsed[$file->getPathname()] = $test; |
166 | 186 | }
|
167 | 187 | return $parsed;
|
168 | 188 | }
|
|
0 commit comments