tests/vmcheck: Display human-readable status on jq failure

So it's easier to debug.

This inlines the helper into the only function that uses it.

Closes: #1430
Approved by: jlebon
This commit is contained in:
Colin Walters 2018-08-03 13:27:53 -04:00 committed by Atomic Bot
parent 2278b60a15
commit e1b62d0f7d
2 changed files with 11 additions and 12 deletions

View File

@ -359,17 +359,6 @@ skip_one_with_asan () {
fi fi
} }
assert_status_file_jq() {
status_file=$1; shift
for expression in "$@"; do
if ! jq -e "${expression}" >/dev/null < $status_file; then
jq . < $status_file | sed -e 's/^/# /' >&2
echo 1>&2 "${expression} failed to match in $status_file"
exit 1
fi
done
}
get_obj_path() { get_obj_path() {
repo=$1; shift repo=$1; shift
csum=$1; shift csum=$1; shift

View File

@ -350,9 +350,19 @@ vm_assert_layered_pkg() {
fi fi
} }
# Takes a list of `jq` expressions, each of which should evaluate to a boolean,
# and asserts that they are true.
vm_assert_status_jq() { vm_assert_status_jq() {
vm_rpmostree status --json > status.json vm_rpmostree status --json > status.json
assert_status_file_jq status.json "$@" vm_rpmostree status > status.txt
for expression in "$@"; do
if ! jq -e "${expression}" >/dev/null < status.json; then
jq . < status.json | sed -e 's/^/# /' >&2
echo 1>&2 "${expression} failed to match status.json"
cat status.txt
exit 1
fi
done
} }
vm_pending_is_staged() { vm_pending_is_staged() {