From e1b62d0f7dbe2082a9326f9c34af63474a2629ce Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 3 Aug 2018 13:27:53 -0400 Subject: [PATCH] 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 --- tests/common/libtest.sh | 11 ----------- tests/common/libvm.sh | 12 +++++++++++- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/common/libtest.sh b/tests/common/libtest.sh index 10a530e5..711724ee 100644 --- a/tests/common/libtest.sh +++ b/tests/common/libtest.sh @@ -359,17 +359,6 @@ skip_one_with_asan () { 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() { repo=$1; shift csum=$1; shift diff --git a/tests/common/libvm.sh b/tests/common/libvm.sh index 6f36ec3a..e7ad470e 100644 --- a/tests/common/libvm.sh +++ b/tests/common/libvm.sh @@ -350,9 +350,19 @@ vm_assert_layered_pkg() { 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_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() {