From 8ad16524183baf196d1db82b99ef52d05ca438e9 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 10 Oct 2014 02:11:14 -0400 Subject: t5304: use helper to report failure of "test foo = bar" For small outputs, we sometimes use: test "$(some_cmd)" = "something we expect" instead of a full test_cmp. The downside of this is that when it fails, there is no output at all from the script. Let's introduce a small helper to make tests easier to debug. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/test-lib-functions.sh | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 't/test-lib-functions.sh') diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index dafd6ad21a..b7957b87bb 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -634,6 +634,15 @@ test_cmp_bin() { cmp "$@" } +# Call any command "$@" but be more verbose about its +# failure. This is handy for commands like "test" which do +# not output anything when they fail. +verbose () { + "$@" && return 0 + echo >&2 "command failed: $(git rev-parse --sq-quote "$@")" + return 1 +} + # Check if the file expected to be empty is indeed empty, and barfs # otherwise. -- cgit v1.2.1