Skip to content

Commit

Permalink
Added the requires in Yaml tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ezimuel committed Jun 12, 2024
1 parent 55ffae6 commit 0d916d8
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion util/ActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,38 @@ private function length(array $actions)
]);
}

private function requires(array $requires)
{
if (isset($requires['test_runner_features'])) {
if (is_string($requires['test_runner_features'])) {
$requires['test_runner_features'] = [$requires['test_runner_features']];
}
foreach ($requires['test_runner_features'] as $req) {
if (!in_array($requires['test_runner_features'], self::SUPPORTED_FEATURES)) {
return YamlTests::render(self::TEMPLATE_SKIP_FEATURE, [
':testname' => "__CLASS__ . '::' . __FUNCTION__",
':feature' => sprintf("'%s'", $req)
]);
}
}
}
if (isset($requires['cluster_features'])) {
if (is_string($requires['cluster_features'])) {
$part = explode('_', $requires['cluster_features']);
if ($part[0] === 'gte') {
$version = str_replace ('v','', $part[1]);
if (version_compare(YamlTests::$esVersion, $version, '<')) {
return YamlTests::render(self::TEMPLATE_SKIP_VERSION, [
':testname' => "__CLASS__ . '::' . __FUNCTION__",
':esversion' => sprintf("'%s'", YamlTests::$esVersion),
':reason' => sprintf("'%s'", $requires['reason'] ?? '')
]);
}
}
}
}
}

private function skip(array $actions)
{
if (isset($actions['version']) && isset($actions['reason'])) {
Expand Down Expand Up @@ -388,7 +420,21 @@ private function skip(array $actions)
break;
}
}

}
if (isset($actions['cluster_features'])) {
if (is_string($actions['cluster_features'])) {
$part = explode('_', $actions['cluster_features']);
if ($part[0] === 'gte') {
$version = str_replace ('v','', $part[1]);
if (version_compare(YamlTests::$esVersion, $version, '>=')) {
return YamlTests::render(self::TEMPLATE_SKIP_VERSION, [
':testname' => "__CLASS__ . '::' . __FUNCTION__",
':esversion' => sprintf("'%s'", YamlTests::$esVersion),
':reason' => sprintf("'%s'", $actions['reason'] ?? '')
]);
}
}
}
}
}

Expand Down

0 comments on commit 0d916d8

Please sign in to comment.