t5304: use test_path_is_* instead of "test -f"

This is slightly more robust (checking "! test -f" would not notice a directory of the same name, though that is not likely to happen here). It also makes debugging easier, as the test script will output a message on failure. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Oct 10, 2014 at 02:07 UTC f1dd90bd193637eeef772890c37afe3529a665d0
1 file changed +23 -23
t/t5304-prune.sh
+23 -23
@@ -14,7 +14,7 @@ add_blob() {
14 BLOB=$(echo aleph_0 | git hash-object -w --stdin) &&
15 BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
16 test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
17 - test -f $BLOB_FILE &&
17 + test_path_is_file $BLOB_FILE &&
18 test-chmtime =+0 $BLOB_FILE
19 }
20
@@ -35,9 +35,9 @@ test_expect_success 'prune stale packs' '
35 : > .git/objects/tmp_2.pack &&
36 test-chmtime =-86501 .git/objects/tmp_1.pack &&
37 git prune --expire 1.day &&
38 - test -f $orig_pack &&
39 - test -f .git/objects/tmp_2.pack &&
40 - ! test -f .git/objects/tmp_1.pack
38 + test_path_is_file $orig_pack &&
39 + test_path_is_file .git/objects/tmp_2.pack &&
40 + test_path_is_missing .git/objects/tmp_1.pack
41
42 '
43
@@ -46,11 +46,11 @@ test_expect_success 'prune --expire' '
46 add_blob &&
47 git prune --expire=1.hour.ago &&
48 test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
49 - test -f $BLOB_FILE &&
49 + test_path_is_file $BLOB_FILE &&
50 test-chmtime =-86500 $BLOB_FILE &&
51 git prune --expire 1.day &&
52 test $before = $(git count-objects | sed "s/ .*//") &&
53 - ! test -f $BLOB_FILE
53 + test_path_is_missing $BLOB_FILE
54
55 '
56
@@ -60,11 +60,11 @@ test_expect_success 'gc: implicit prune --expire' '
60 test-chmtime =-$((2*$week-30)) $BLOB_FILE &&
61 git gc &&
62 test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
63 - test -f $BLOB_FILE &&
63 + test_path_is_file $BLOB_FILE &&
64 test-chmtime =-$((2*$week+1)) $BLOB_FILE &&
65 git gc &&
66 test $before = $(git count-objects | sed "s/ .*//") &&
67 - ! test -f $BLOB_FILE
67 + test_path_is_missing $BLOB_FILE
68
69 '
70
@@ -110,7 +110,7 @@ test_expect_success 'prune: do not prune detached HEAD with no reflog' '
110 git commit --allow-empty -m "detached commit" &&
111 # verify that there is no reflogs
112 # (should be removed and disabled by previous test)
113 - test ! -e .git/logs &&
113 + test_path_is_missing .git/logs &&
114 git prune -n >prune_actual &&
115 : >prune_expected &&
116 test_cmp prune_actual prune_expected
@@ -145,7 +145,7 @@ test_expect_success 'gc --no-prune' '
145 git config gc.pruneExpire 2.days.ago &&
146 git gc --no-prune &&
147 test 1 = $(git count-objects | sed "s/ .*//") &&
148 - test -f $BLOB_FILE
148 + test_path_is_file $BLOB_FILE
149
150 '
151
@@ -153,10 +153,10 @@ test_expect_success 'gc respects gc.pruneExpire' '
153
154 git config gc.pruneExpire 5002.days.ago &&
155 git gc &&
156 - test -f $BLOB_FILE &&
156 + test_path_is_file $BLOB_FILE &&
157 git config gc.pruneExpire 5000.days.ago &&
158 git gc &&
159 - test ! -f $BLOB_FILE
159 + test_path_is_missing $BLOB_FILE
160
161 '
162
@@ -165,9 +165,9 @@ test_expect_success 'gc --prune=<date>' '
165 add_blob &&
166 test-chmtime =-$((5001*$day)) $BLOB_FILE &&
167 git gc --prune=5002.days.ago &&
168 - test -f $BLOB_FILE &&
168 + test_path_is_file $BLOB_FILE &&
169 git gc --prune=5000.days.ago &&
170 - test ! -f $BLOB_FILE
170 + test_path_is_missing $BLOB_FILE
171
172 '
173
@@ -175,9 +175,9 @@ test_expect_success 'gc --prune=never' '
175
176 add_blob &&
177 git gc --prune=never &&
178 - test -f $BLOB_FILE &&
178 + test_path_is_file $BLOB_FILE &&
179 git gc --prune=now &&
180 - test ! -f $BLOB_FILE
180 + test_path_is_missing $BLOB_FILE
181
182 '
183
@@ -186,10 +186,10 @@ test_expect_success 'gc respects gc.pruneExpire=never' '
186 git config gc.pruneExpire never &&
187 add_blob &&
188 git gc &&
189 - test -f $BLOB_FILE &&
189 + test_path_is_file $BLOB_FILE &&
190 git config gc.pruneExpire now &&
191 git gc &&
192 - test ! -f $BLOB_FILE
192 + test_path_is_missing $BLOB_FILE
193
194 '
195
@@ -197,9 +197,9 @@ test_expect_success 'prune --expire=never' '
197
198 add_blob &&
199 git prune --expire=never &&
200 - test -f $BLOB_FILE &&
200 + test_path_is_file $BLOB_FILE &&
201 git prune &&
202 - test ! -f $BLOB_FILE
202 + test_path_is_missing $BLOB_FILE
203
204 '
205
@@ -210,10 +210,10 @@ test_expect_success 'gc: prune old objects after local clone' '
210 (
211 cd aclone &&
212 test 1 = $(git count-objects | sed "s/ .*//") &&
213 - test -f $BLOB_FILE &&
213 + test_path_is_file $BLOB_FILE &&
214 git gc --prune &&
215 test 0 = $(git count-objects | sed "s/ .*//") &&
216 - ! test -f $BLOB_FILE
216 + test_path_is_missing $BLOB_FILE
217 )
218 '
219
@@ -250,7 +250,7 @@ test_expect_success 'prune .git/shallow' '
250 grep $SHA1 .git/shallow &&
251 grep $SHA1 out &&
252 git prune &&
253 - ! test -f .git/shallow
253 + test_path_is_missing .git/shallow
254 '
255
256 test_done