From 06ae12bd4ef9447dae69827b1c11fbf40d1615bc Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Mon, 29 Mar 2021 06:06:04 -0600 Subject: system tests: friendier messages for 2-arg is() The 'is' check was intended to be called with three arguments, the last one being a nice helpful test name. There's a fallback for two-argument calls, but it was a horrible FIXME. New fallback: the most recently run podman command. We keep track of it in each run_podman() invocation. This is not ideal, because it's theoretically possible to invoke 'is' on something other than the output of run_podman, but this at least fixes the by-far-most-common case. [NO TESTS NEEDED] Signed-off-by: Ed Santiago --- test/system/helpers.bash | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/system/helpers.bash b/test/system/helpers.bash index 38e317709..823dc3376 100644 --- a/test/system/helpers.bash +++ b/test/system/helpers.bash @@ -72,6 +72,9 @@ function basic_setup() { # on cleanup. # TODO: do this outside of setup, so it carries across tests? PODMAN_TMPDIR=$(mktemp -d --tmpdir=${BATS_TMPDIR:-/tmp} podman_bats.XXXXXX) + + # In the unlikely event that a test runs is() before a run_podman() + MOST_RECENT_PODMAN_COMMAND= } # Basic teardown: remove all pods and containers @@ -150,6 +153,9 @@ function run_podman() { '?') expected_rc= ; shift;; # ignore exit code esac + # Remember command args, for possible use in later diagnostic messages + MOST_RECENT_PODMAN_COMMAND="podman $*" + # stdout is only emitted upon error; this echo is to help a debugger echo "$_LOG_PROMPT $PODMAN $*" # BATS hangs if a subprocess remains and keeps FD 3 open; this happens @@ -384,7 +390,7 @@ function die() { function is() { local actual="$1" local expect="$2" - local testname="${3:-FIXME}" + local testname="${3:-${MOST_RECENT_PODMAN_COMMAND:-[no test name given]}}" if [ -z "$expect" ]; then if [ -z "$actual" ]; then -- cgit v1.2.3-54-g00ecf