test: test_must_be_empty helper
[gitweb.git] / t / test-lib-functions.sh
index 3fc9cc92884bd03f1d4f6a2b543b4c0e0fb55959..a8e57f05c1efb2e5302709296fb4169a0fc86c78 100644 (file)
@@ -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 &&