test: Use yq for yaml2json when available

Signed-off-by: Ricardo Branco <rbranco@suse.de>
This commit is contained in:
Ricardo Branco 2026-02-22 10:51:48 +01:00
parent ec0f63c6e5
commit 476ca11994
No known key found for this signature in database
2 changed files with 6 additions and 1 deletions

View file

@ -45,6 +45,7 @@ The test currently depend on:
- tar
- docker
- systemd/systemctl
- yq
Most of these are only required for a few tests so it is not a big issue if not everything is installed. Only a few test should fail then.

View file

@ -14,10 +14,14 @@ capabilities='{"drop":["CAP_FOWNER","CAP_SETFCAP"]}'
# filter: convert yaml to json, because bash+yaml=madness
function yaml2json() {
python3 -c 'import yaml
if command -v yq >/dev/null; then
yq -p yaml -o json
else
python3 -c 'import yaml
import json
import sys
json.dump(yaml.safe_load(sys.stdin), sys.stdout)'
fi
}
###############################################################################