summaryrefslogtreecommitdiff
path: root/t/test-lib-functions.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-10-10 06:11:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-10-13 18:27:40 (GMT)
commit8ad16524183baf196d1db82b99ef52d05ca438e9 (patch)
tree0f40c931965c2f6e7b8679a9a448d1569ce439a8 /t/test-lib-functions.sh
parentf1dd90bd193637eeef772890c37afe3529a665d0 (diff)
downloadgit-8ad16524183baf196d1db82b99ef52d05ca438e9.zip
git-8ad16524183baf196d1db82b99ef52d05ca438e9.tar.gz
git-8ad16524183baf196d1db82b99ef52d05ca438e9.tar.bz2
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 dafd6ad..b7957b8 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.