diff --git a/tests/libtest.sh b/tests/libtest.sh index 2bf2655627a418ddb995c08a9c31655dd271324e..fa40f70e6c12d0b0c562a0ac3d200ce989768d51 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 "# \$($*)..." "$@"