aboutsummaryrefslogtreecommitdiff
path: root/t/test-lib-functions.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-10-10 02:11:14 -0400
committerJunio C Hamano <gitster@pobox.com>2014-10-13 11:27:40 -0700
commit8ad16524183baf196d1db82b99ef52d05ca438e9 (patch)
tree0f40c931965c2f6e7b8679a9a448d1569ce439a8 /t/test-lib-functions.sh
parentf1dd90bd193637eeef772890c37afe3529a665d0 (diff)
downloadgit-8ad16524183baf196d1db82b99ef52d05ca438e9.tar.gz
git-8ad16524183baf196d1db82b99ef52d05ca438e9.tar.xz
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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/test-lib-functions.sh')
-rw-r--r--t/test-lib-functions.sh9
1 files changed, 9 insertions, 0 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index dafd6ad21..b7957b87b 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.