Skip to content

Commit c75d7ff

Browse files
committed
Reapply the YAML_FILES_TO_OMIT for Internal tests
1 parent 70371ee commit c75d7ff

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

util/YamlTests.php

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use RecursiveDirectoryIterator;
2323
use RecursiveIteratorIterator;
2424
use stdClass;
25+
use Throwable;
2526

2627
use function yaml_parse;
2728

@@ -147,22 +148,41 @@ private function getAllTests(string $dir): array
147148
$parsed = [];
148149
// Iterate over the Yaml test files
149150
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 {
153167
$test = yaml_parse($content, -1, $ndocs, [
154168
YAML_MAP_TAG => function($value, $tag, $flags) {
155169
return empty($value) ? new stdClass : $value;
156170
}
157171
]);
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+
));
165184
}
185+
$parsed[$file->getPathname()] = $test;
166186
}
167187
return $parsed;
168188
}

0 commit comments

Comments
 (0)