]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t9811: replace 'test -f' and '! test -f' with 'test_path_*'
authorMarcelo Machado Lage <marcelomlage@usp.br>
Sat, 11 Jul 2026 16:04:47 +0000 (13:04 -0300)
committerJunio C Hamano <gitster@pobox.com>
Sat, 11 Jul 2026 21:14:35 +0000 (14:14 -0700)
Replace the basic shell commands 'test -f', with more modern test
helpers 'test_path_is_file' and 'test_path_is_missing'.
These modern helpers emit useful information when the corresponding
tests fail, unlike 'test -f' and '! test -f'.

The occurrences of '! test -f filename' were replaced by
'file_path_is_missing filename', a stronger guarantee equivalent to
'! test -e filename'.

Co-authored-by: Vinicius Lira de Freitas <vinilira@usp.br>
Signed-off-by: Vinicius Lira de Freitas <vinilira@usp.br>
Signed-off-by: Marcelo Machado Lage <marcelomlage@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t9811-git-p4-label-import.sh

index 9c161036f2dc249e2f9a4ecf9436b379f2f7449d..ee257011b3c97f6f733e88a6f0bd5c08abd8205c 100755 (executable)
@@ -62,11 +62,11 @@ test_expect_success 'basic p4 labels' '
 
                cd main &&
                git checkout TAG_F1_ONLY &&
-               ! test -f f2 &&
+               test_path_is_missing f2 &&
                git checkout TAG_WITH\$_SHELL_CHAR &&
-               test -f f1 &&
-               test -f f2 &&
-               test -f file_with_\$metachar &&
+               test_path_is_file f1 &&
+               test_path_is_file f2 &&
+               test_path_is_file file_with_\$metachar &&
 
                git show TAG_LONG_LABEL | grep -q "A Label second line"
        )
@@ -104,11 +104,11 @@ test_expect_success 'two labels on the same changelist' '
 
                git checkout TAG_F1_1 &&
                ls &&
-               test -f f1 &&
+               test_path_is_file f1 &&
 
                git checkout TAG_F1_2 &&
                ls &&
-               test -f f1
+               test_path_is_file f1
        )
 '
 
@@ -137,9 +137,9 @@ test_expect_success 'export git tags to p4' '
                p4 labels ... | grep LIGHTWEIGHT_TAG &&
                p4 label -o GIT_TAG_1 | grep "tag created in git:xyzzy" &&
                p4 sync ...@GIT_TAG_1 &&
-               ! test -f main/f10 &&
+               test_path_is_missing main/f10 &&
                p4 sync ...@GIT_TAG_2 &&
-               test -f main/f10
+               test_path_is_file main/f10
        )
 '
 
@@ -170,9 +170,9 @@ test_expect_success 'export git tags to p4 with deletion' '
                cd "$cli" &&
                p4 sync ... &&
                p4 sync ...@GIT_TAG_ON_DELETED &&
-               test -f main/deleted_file &&
+               test_path_is_file main/deleted_file &&
                p4 sync ...@GIT_TAG_AFTER_DELETION &&
-               ! test -f main/deleted_file &&
+               test_path_is_missing main/deleted_file &&
                echo "checking label contents" &&
                p4 label -o GIT_TAG_ON_DELETED | grep "tag on deleted file"
        )