t9811: replace 'test -f' and '! test -f' with 'test_path_*'

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>

Marcelo Machado Lage committed Jul 11, 2026 at 13:04 UTC 156991928c3def5df519d42efc46735b0a090079
1 file changed +10 -10
t/t9811-git-p4-label-import.sh
+10 -10
@@ -62,11 +62,11 @@ test_expect_success 'basic p4 labels' '
62
63 cd main &&
64 git checkout TAG_F1_ONLY &&
65 - ! test -f f2 &&
65 + test_path_is_missing f2 &&
66 git checkout TAG_WITH\$_SHELL_CHAR &&
67 - test -f f1 &&
68 - test -f f2 &&
69 - test -f file_with_\$metachar &&
67 + test_path_is_file f1 &&
68 + test_path_is_file f2 &&
69 + test_path_is_file file_with_\$metachar &&
70
71 git show TAG_LONG_LABEL | grep -q "A Label second line"
72 )
@@ -104,11 +104,11 @@ test_expect_success 'two labels on the same changelist' '
104
105 git checkout TAG_F1_1 &&
106 ls &&
107 - test -f f1 &&
107 + test_path_is_file f1 &&
108
109 git checkout TAG_F1_2 &&
110 ls &&
111 - test -f f1
111 + test_path_is_file f1
112 )
113 '
114
@@ -137,9 +137,9 @@ test_expect_success 'export git tags to p4' '
137 p4 labels ... | grep LIGHTWEIGHT_TAG &&
138 p4 label -o GIT_TAG_1 | grep "tag created in git:xyzzy" &&
139 p4 sync ...@GIT_TAG_1 &&
140 - ! test -f main/f10 &&
140 + test_path_is_missing main/f10 &&
141 p4 sync ...@GIT_TAG_2 &&
142 - test -f main/f10
142 + test_path_is_file main/f10
143 )
144 '
145
@@ -170,9 +170,9 @@ test_expect_success 'export git tags to p4 with deletion' '
170 cd "$cli" &&
171 p4 sync ... &&
172 p4 sync ...@GIT_TAG_ON_DELETED &&
173 - test -f main/deleted_file &&
173 + test_path_is_file main/deleted_file &&
174 p4 sync ...@GIT_TAG_AFTER_DELETION &&
175 - ! test -f main/deleted_file &&
175 + test_path_is_missing main/deleted_file &&
176 echo "checking label contents" &&
177 p4 label -o GIT_TAG_ON_DELETED | grep "tag on deleted file"
178 )