]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t7110: replace `test -f` with `test_path_is_*` helpers
authorMatteo Bagnolini <matteobagnolini2003@gmail.com>
Fri, 3 Jan 2025 13:00:35 +0000 (14:00 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 3 Jan 2025 18:35:13 +0000 (10:35 -0800)
`test -f` and `! test -f` do not provide clear error messages when they fail.
To enhance debuggability, use `test_path_is_file` and `test_path_is_missing`,
which instead provide more informative error messages.

Note that `! test -f` checks if a path is not a file, while
`test_path_is_missing` verifies that a path does not exist. In this specific
case the tests are meant to check the absence of the path, making
`test_path_is_missing` a valid replacement.

Signed-off-by: Matteo Bagnolini <matteobagnolini2003@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7110-reset-merge.sh

index 61669a2d2102b80f886a7b95f87a6d866fdc36bd..9a335071af6c0d31094af18cf6cddf8619cf1d2a 100755 (executable)
@@ -270,13 +270,13 @@ test_expect_success '--merge is ok with added/deleted merge' '
        git reset --hard third &&
        rm -f file2 &&
        test_must_fail git merge branch3 &&
-       ! test -f file2 &&
-       test -f file3 &&
+       test_path_is_missing file2 &&
+       test_path_is_file file3 &&
        git diff --exit-code file3 &&
        git diff --exit-code branch3 file3 &&
        git reset --merge HEAD &&
-       ! test -f file3 &&
-       ! test -f file2 &&
+       test_path_is_missing file3 &&
+       test_path_is_missing file2 &&
        git diff --exit-code --cached
 '
 
@@ -284,8 +284,8 @@ test_expect_success '--keep fails with added/deleted merge' '
        git reset --hard third &&
        rm -f file2 &&
        test_must_fail git merge branch3 &&
-       ! test -f file2 &&
-       test -f file3 &&
+       test_path_is_missing file2 &&
+       test_path_is_file file3 &&
        git diff --exit-code file3 &&
        git diff --exit-code branch3 file3 &&
        test_must_fail git reset --keep HEAD 2>err.log &&