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>
This commit is contained in:
parent
63a45136a3
commit
f1dd90bd19
@ -14,7 +14,7 @@ add_blob() {
|
|||||||
BLOB=$(echo aleph_0 | git hash-object -w --stdin) &&
|
BLOB=$(echo aleph_0 | git hash-object -w --stdin) &&
|
||||||
BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
|
BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
|
||||||
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
|
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
|
||||||
test -f $BLOB_FILE &&
|
test_path_is_file $BLOB_FILE &&
|
||||||
test-chmtime =+0 $BLOB_FILE
|
test-chmtime =+0 $BLOB_FILE
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,9 +35,9 @@ test_expect_success 'prune stale packs' '
|
|||||||
: > .git/objects/tmp_2.pack &&
|
: > .git/objects/tmp_2.pack &&
|
||||||
test-chmtime =-86501 .git/objects/tmp_1.pack &&
|
test-chmtime =-86501 .git/objects/tmp_1.pack &&
|
||||||
git prune --expire 1.day &&
|
git prune --expire 1.day &&
|
||||||
test -f $orig_pack &&
|
test_path_is_file $orig_pack &&
|
||||||
test -f .git/objects/tmp_2.pack &&
|
test_path_is_file .git/objects/tmp_2.pack &&
|
||||||
! test -f .git/objects/tmp_1.pack
|
test_path_is_missing .git/objects/tmp_1.pack
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -46,11 +46,11 @@ test_expect_success 'prune --expire' '
|
|||||||
add_blob &&
|
add_blob &&
|
||||||
git prune --expire=1.hour.ago &&
|
git prune --expire=1.hour.ago &&
|
||||||
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
|
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
|
||||||
test -f $BLOB_FILE &&
|
test_path_is_file $BLOB_FILE &&
|
||||||
test-chmtime =-86500 $BLOB_FILE &&
|
test-chmtime =-86500 $BLOB_FILE &&
|
||||||
git prune --expire 1.day &&
|
git prune --expire 1.day &&
|
||||||
test $before = $(git count-objects | sed "s/ .*//") &&
|
test $before = $(git count-objects | sed "s/ .*//") &&
|
||||||
! test -f $BLOB_FILE
|
test_path_is_missing $BLOB_FILE
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -60,11 +60,11 @@ test_expect_success 'gc: implicit prune --expire' '
|
|||||||
test-chmtime =-$((2*$week-30)) $BLOB_FILE &&
|
test-chmtime =-$((2*$week-30)) $BLOB_FILE &&
|
||||||
git gc &&
|
git gc &&
|
||||||
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
|
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
|
||||||
test -f $BLOB_FILE &&
|
test_path_is_file $BLOB_FILE &&
|
||||||
test-chmtime =-$((2*$week+1)) $BLOB_FILE &&
|
test-chmtime =-$((2*$week+1)) $BLOB_FILE &&
|
||||||
git gc &&
|
git gc &&
|
||||||
test $before = $(git count-objects | sed "s/ .*//") &&
|
test $before = $(git count-objects | sed "s/ .*//") &&
|
||||||
! test -f $BLOB_FILE
|
test_path_is_missing $BLOB_FILE
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ test_expect_success 'prune: do not prune detached HEAD with no reflog' '
|
|||||||
git commit --allow-empty -m "detached commit" &&
|
git commit --allow-empty -m "detached commit" &&
|
||||||
# verify that there is no reflogs
|
# verify that there is no reflogs
|
||||||
# (should be removed and disabled by previous test)
|
# (should be removed and disabled by previous test)
|
||||||
test ! -e .git/logs &&
|
test_path_is_missing .git/logs &&
|
||||||
git prune -n >prune_actual &&
|
git prune -n >prune_actual &&
|
||||||
: >prune_expected &&
|
: >prune_expected &&
|
||||||
test_cmp prune_actual prune_expected
|
test_cmp prune_actual prune_expected
|
||||||
@ -145,7 +145,7 @@ test_expect_success 'gc --no-prune' '
|
|||||||
git config gc.pruneExpire 2.days.ago &&
|
git config gc.pruneExpire 2.days.ago &&
|
||||||
git gc --no-prune &&
|
git gc --no-prune &&
|
||||||
test 1 = $(git count-objects | sed "s/ .*//") &&
|
test 1 = $(git count-objects | sed "s/ .*//") &&
|
||||||
test -f $BLOB_FILE
|
test_path_is_file $BLOB_FILE
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -153,10 +153,10 @@ test_expect_success 'gc respects gc.pruneExpire' '
|
|||||||
|
|
||||||
git config gc.pruneExpire 5002.days.ago &&
|
git config gc.pruneExpire 5002.days.ago &&
|
||||||
git gc &&
|
git gc &&
|
||||||
test -f $BLOB_FILE &&
|
test_path_is_file $BLOB_FILE &&
|
||||||
git config gc.pruneExpire 5000.days.ago &&
|
git config gc.pruneExpire 5000.days.ago &&
|
||||||
git gc &&
|
git gc &&
|
||||||
test ! -f $BLOB_FILE
|
test_path_is_missing $BLOB_FILE
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -165,9 +165,9 @@ test_expect_success 'gc --prune=<date>' '
|
|||||||
add_blob &&
|
add_blob &&
|
||||||
test-chmtime =-$((5001*$day)) $BLOB_FILE &&
|
test-chmtime =-$((5001*$day)) $BLOB_FILE &&
|
||||||
git gc --prune=5002.days.ago &&
|
git gc --prune=5002.days.ago &&
|
||||||
test -f $BLOB_FILE &&
|
test_path_is_file $BLOB_FILE &&
|
||||||
git gc --prune=5000.days.ago &&
|
git gc --prune=5000.days.ago &&
|
||||||
test ! -f $BLOB_FILE
|
test_path_is_missing $BLOB_FILE
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -175,9 +175,9 @@ test_expect_success 'gc --prune=never' '
|
|||||||
|
|
||||||
add_blob &&
|
add_blob &&
|
||||||
git gc --prune=never &&
|
git gc --prune=never &&
|
||||||
test -f $BLOB_FILE &&
|
test_path_is_file $BLOB_FILE &&
|
||||||
git gc --prune=now &&
|
git gc --prune=now &&
|
||||||
test ! -f $BLOB_FILE
|
test_path_is_missing $BLOB_FILE
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -186,10 +186,10 @@ test_expect_success 'gc respects gc.pruneExpire=never' '
|
|||||||
git config gc.pruneExpire never &&
|
git config gc.pruneExpire never &&
|
||||||
add_blob &&
|
add_blob &&
|
||||||
git gc &&
|
git gc &&
|
||||||
test -f $BLOB_FILE &&
|
test_path_is_file $BLOB_FILE &&
|
||||||
git config gc.pruneExpire now &&
|
git config gc.pruneExpire now &&
|
||||||
git gc &&
|
git gc &&
|
||||||
test ! -f $BLOB_FILE
|
test_path_is_missing $BLOB_FILE
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -197,9 +197,9 @@ test_expect_success 'prune --expire=never' '
|
|||||||
|
|
||||||
add_blob &&
|
add_blob &&
|
||||||
git prune --expire=never &&
|
git prune --expire=never &&
|
||||||
test -f $BLOB_FILE &&
|
test_path_is_file $BLOB_FILE &&
|
||||||
git prune &&
|
git prune &&
|
||||||
test ! -f $BLOB_FILE
|
test_path_is_missing $BLOB_FILE
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -210,10 +210,10 @@ test_expect_success 'gc: prune old objects after local clone' '
|
|||||||
(
|
(
|
||||||
cd aclone &&
|
cd aclone &&
|
||||||
test 1 = $(git count-objects | sed "s/ .*//") &&
|
test 1 = $(git count-objects | sed "s/ .*//") &&
|
||||||
test -f $BLOB_FILE &&
|
test_path_is_file $BLOB_FILE &&
|
||||||
git gc --prune &&
|
git gc --prune &&
|
||||||
test 0 = $(git count-objects | sed "s/ .*//") &&
|
test 0 = $(git count-objects | sed "s/ .*//") &&
|
||||||
! test -f $BLOB_FILE
|
test_path_is_missing $BLOB_FILE
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ test_expect_success 'prune .git/shallow' '
|
|||||||
grep $SHA1 .git/shallow &&
|
grep $SHA1 .git/shallow &&
|
||||||
grep $SHA1 out &&
|
grep $SHA1 out &&
|
||||||
git prune &&
|
git prune &&
|
||||||
! test -f .git/shallow
|
test_path_is_missing .git/shallow
|
||||||
'
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user