From 40886bd6e715a0d9f648d233ef8bf81ada85683f Mon Sep 17 00:00:00 2001 From: Simon McVittie <smcv@collabora.com> Date: Thu, 21 Sep 2017 14:23:07 +0100 Subject: [PATCH] tests: Add shell_like Signed-off-by: Simon McVittie <smcv@collabora.com> --- tests/libtest.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/libtest.sh b/tests/libtest.sh index 2bf265562..fa40f70e6 100644 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -132,6 +132,29 @@ shell_is () { fi } +shell_like () { + local command="$1" + local expected_status="$2" + local expected="$3" + local status=0 + shift 3 + + echo_tap "# \$($command)..." + got="$(eval "$command")" || status="$?" + + if [ "x$status" != "x$expected_status" ]; then + fail "$* (status $status != $expected_status)" + fi + + if [[ $got == $expected ]]; then + pass "$* ($got matches $expected)" + else + echo_tap "# Got: $got" + echo_tap "# Expected extglob: $expected" + fail "$* ($got does not match extglob $expected)" + fi +} + run_verbose () { echo_tap "# \$($*)..." "$@" -- GitLab