Skip to content

Commit 21926fe

Browse files
drafnelgitster
authored andcommitted
t5304-prune: adjust file mtime based on system time rather than file mtime
test-chmtime can adjust the mtime of a file based on the file's mtime, or based on the system time. For files accessed over NFS, the file's mtime is set by the NFS server, and as such may vary a great deal from the NFS client's system time if the clocks of the client and server are out of sync. Since these tests are testing the expire feature of git-prune, an incorrect mtime could cause a file to be expired or not expired incorrectly and produce a test failure. Avoid this NFS pitfall by modifying the calls to test-chmtime so that the mtime is adjusted based on the system time, rather than the file's mtime. Signed-off-by: Brandon Casey <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ea335b5 commit 21926fe

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

t/t5304-prune.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test_expect_success 'prune stale packs' '
2121
orig_pack=$(echo .git/objects/pack/*.pack) &&
2222
: > .git/objects/tmp_1.pack &&
2323
: > .git/objects/tmp_2.pack &&
24-
test-chmtime -86501 .git/objects/tmp_1.pack &&
24+
test-chmtime =-86501 .git/objects/tmp_1.pack &&
2525
git prune --expire 1.day &&
2626
test -f $orig_pack &&
2727
test -f .git/objects/tmp_2.pack &&
@@ -39,7 +39,7 @@ test_expect_success 'prune --expire' '
3939
git prune --expire=1.hour.ago &&
4040
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
4141
test -f $BLOB_FILE &&
42-
test-chmtime -86500 $BLOB_FILE &&
42+
test-chmtime =-86500 $BLOB_FILE &&
4343
git prune --expire 1.day &&
4444
test $before = $(git count-objects | sed "s/ .*//") &&
4545
! test -f $BLOB_FILE
@@ -53,11 +53,11 @@ test_expect_success 'gc: implicit prune --expire' '
5353
BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
5454
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
5555
test -f $BLOB_FILE &&
56-
test-chmtime -$((86400*14-30)) $BLOB_FILE &&
56+
test-chmtime =-$((86400*14-30)) $BLOB_FILE &&
5757
git gc &&
5858
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
5959
test -f $BLOB_FILE &&
60-
test-chmtime -$((86400*14+1)) $BLOB_FILE &&
60+
test-chmtime =-$((86400*14+1)) $BLOB_FILE &&
6161
git gc &&
6262
test $before = $(git count-objects | sed "s/ .*//") &&
6363
! test -f $BLOB_FILE

0 commit comments

Comments
 (0)