t7406: prefer test_* helper functions to test -[feds]
authorElijah Newren <newren@gmail.com>
Wed, 8 Aug 2018 16:31:06 +0000 (09:31 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Aug 2018 17:52:55 +0000 (10:52 -0700)
test -e, test -s, etc. do not provide nice error messages when we hit
test failures, so use the test_* helper functions from
test-lib-functions.sh.

Also, add test_path_exists() to test-lib-function.sh while at it, so
that we don't need to worry whether submodule/.git is a file or a
directory. It currently is a file with contents of the form
gitdir: ../.git/modules/submodule
but it could be changed in the future to be a directory; this test
only really cares that it exists.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7406-submodule-update.sh
t/test-lib-functions.sh
index 2463863a51f3ca0dcb112cbcb24c6682b2af67a7..24aa732312824ab21a712e1b88e3d6098d9aca57 100755 (executable)
@@ -174,7 +174,7 @@ test_expect_success 'submodule update does not fetch already present commits' '
          git submodule update > ../actual 2> ../actual.err
        ) &&
        test_i18ncmp expected actual &&
-       ! test -s actual.err
+       test_must_be_empty actual.err
 '
 
 test_expect_success 'submodule update should fail due to local changes' '
@@ -620,8 +620,8 @@ test_expect_success 'submodule update --init skips submodule with update=none' '
        git clone super cloned &&
        (cd cloned &&
         git submodule update --init &&
-        test -e submodule/.git &&
-        test_must_fail test -e none/.git
+        test_path_exists submodule/.git &&
+        test_path_is_missing none/.git
        )
 '
 
index 2b2181dca09089ed36d10ee8f6f67eedda8cf352..4207af40777c69365dc395e800a7e4214beab076 100644 (file)
@@ -565,6 +565,14 @@ test_path_is_dir () {
        fi
 }
 
+test_path_exists () {
+       if ! test -e "$1"
+       then
+               echo "Path $1 doesn't exist. $2"
+               false
+       fi
+}
+
 # Check if the directory exists and is empty as expected, barf otherwise.
 test_dir_is_empty () {
        test_path_is_dir "$1" &&