Skip to content

Commit

Permalink
t4200-rerere.sh: use test_path_is_* functions in the script
Browse files Browse the repository at this point in the history
The original code works fine. However, since the code base has already had help-functions(in test-lib-functions),
the change is able to help people understand the code better, as well as improve debug-friendliness.

* t4200-rerere.sh: replace "test -d" with "test_path_is_dir"
* t4200-rerere.sh: replace "test -f" with "test_path_is_file"

Signed-off-by: Angel Pan <[email protected]>
  • Loading branch information
dinoallo committed Apr 4, 2020
1 parent 9fadedd commit c704627
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions t/t4200-rerere.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ test_expect_success 'nothing recorded without rerere' '
rm -rf .git/rr-cache &&
git config rerere.enabled false &&
test_must_fail git merge first &&
! test -d .git/rr-cache
! test_path_is_dir .git/rr-cache
'

test_expect_success 'activate rerere, old style (conflicting merge)' '
Expand All @@ -82,8 +82,8 @@ test_expect_success 'activate rerere, old style (conflicting merge)' '
sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) &&
rr=.git/rr-cache/$sha1 &&
grep "^=======\$" $rr/preimage &&
! test -f $rr/postimage &&
! test -f $rr/thisimage
! test_path_is_file $rr/postimage &&
! test_path_is_file $rr/thisimage
'

test_expect_success 'rerere.enabled works, too' '
Expand All @@ -108,8 +108,8 @@ test_expect_success 'set up rr-cache' '

test_expect_success 'rr-cache looks sane' '
# no postimage or thisimage yet
! test -f $rr/postimage &&
! test -f $rr/thisimage &&
! test_path_is_file $rr/postimage &&
! test_path_is_file $rr/thisimage &&
# preimage has right number of lines
cnt=$(sed -ne "/^<<<<<<</,/^>>>>>>>/p" $rr/preimage | wc -l) &&
Expand Down Expand Up @@ -165,7 +165,7 @@ test_expect_success 'first postimage wins' '
git show first:a1 | sed "s/To die: t/To die! T/" >expect &&
git commit -q -a -m "prefer first over second" &&
test -f $rr/postimage &&
test_path_is_file $rr/postimage &&
oldmtimepost=$(test-tool chmtime --get -60 $rr/postimage) &&
Expand All @@ -188,22 +188,22 @@ test_expect_success 'rerere clear' '
mv $rr/postimage .git/post-saved &&
echo "$sha1 a1" | perl -pe "y/\012/\000/" >.git/MERGE_RR &&
git rerere clear &&
! test -d $rr
! test_path_is_dir $rr
'

test_expect_success 'leftover directory' '
git reset --hard &&
mkdir -p $rr &&
test_must_fail git merge first &&
test -f $rr/preimage
test_path_is_file $rr/preimage
'

test_expect_success 'missing preimage' '
git reset --hard &&
mkdir -p $rr &&
cp .git/post-saved $rr/postimage &&
test_must_fail git merge first &&
test -f $rr/preimage
test_path_is_file $rr/preimage
'

test_expect_success 'set up for garbage collection tests' '
Expand All @@ -228,16 +228,16 @@ test_expect_success 'set up for garbage collection tests' '

test_expect_success 'gc preserves young or recently used records' '
git rerere gc &&
test -f $rr/preimage &&
test -f $rr2/preimage
test_path_is_file $rr/preimage &&
test_path_is_file $rr2/preimage
'

test_expect_success 'old records rest in peace' '
test-tool chmtime =$just_over_60_days_ago $rr/postimage &&
test-tool chmtime =$just_over_15_days_ago $rr2/preimage &&
git rerere gc &&
! test -f $rr/preimage &&
! test -f $rr2/preimage
! test_path_is_file $rr/preimage &&
! test_path_is_file $rr2/preimage
'

rerere_gc_custom_expiry_test () {
Expand Down

0 comments on commit c704627

Please sign in to comment.