Skip to content

Commit

Permalink
Fixed VectorTile YAML tests quoting y
Browse files Browse the repository at this point in the history
  • Loading branch information
ezimuel committed Feb 3, 2022
1 parent 275de8d commit c759198
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions util/YamlTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,31 @@ public function __construct(string $testDir, string $testOutput, string $esVersi
self::$minorEsVersion = sprintf("%s.%s", $major, $minor);
}

/**
* @see https://www.php.net/manual/en/function.yaml-parse-file.php#124980
*/
private function quoteYInYamlFile(string $file)
{
return str_replace (' y: ', ' "y": ', file_get_contents($file));
}

private function getAllTests(string $dir): array
{
$it = new RecursiveDirectoryIterator($dir);
$parsed = [];
// Iterate over the Yaml test files
foreach (new RecursiveIteratorIterator($it) as $file) {
if ($file->getExtension() === 'yml') {
$test = yaml_parse_file($file->getPathname(), -1, $ndocs, [
YAML_MAP_TAG => function($value, $tag, $flags) {
return empty($value) ? new stdClass : $value;
}
]);
$test = yaml_parse(
$this->quoteYInYamlFile($file->getPathname()),
-1,
$ndocs,
[
YAML_MAP_TAG => function($value, $tag, $flags) {
return empty($value) ? new stdClass : $value;
}
]
);
if (false === $test) {
throw new Exception(sprintf(
"YAML parse error file %s",
Expand Down

0 comments on commit c759198

Please sign in to comment.