diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-06-09 20:29:20 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-06-10 01:45:14 +0200 |
commit | ca8d148daf3014577222c2562ca2c8170a866aa4 (patch) | |
tree | d3225e86102154d591d8b25336eb4166c32efd0a /t/test-lib-functions.sh | |
parent | trivial: Add missing period in documentation (diff) | |
download | git-ca8d148daf3014577222c2562ca2c8170a866aa4.tar.xz git-ca8d148daf3014577222c2562ca2c8170a866aa4.zip |
test: test_must_be_empty helper
There are quite a lot places where an output file is expected to be
empty, and we fail the test when it is not. The output from running
the test script with -i -v can be helped if we showed the unexpected
contents at that point.
We could of course do
>expected.empty && test_cmp expected.empty actual
but this is commmon enough to be done with a dedicated helper.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/test-lib-functions.sh')
-rw-r--r-- | t/test-lib-functions.sh | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 3fc9cc9288..a8e57f05c1 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -606,6 +606,18 @@ test_cmp() { $GIT_TEST_CMP "$@" } +# Check if the file expected to be empty is indeed empty, and barfs +# otherwise. + +test_must_be_empty () { + if test -s "$1" + then + echo "'$1' is not empty, it contains:" + cat "$1" + return 1 + fi +} + # Tests that its two parameters refer to the same revision test_cmp_rev () { git rev-parse --verify "$1" >expect.rev && |