Skip to content

Commit

Permalink
t5000: factor out check_tar
Browse files Browse the repository at this point in the history
Create a helper function that extracts a tar archive and checks its
contents, modelled after check_zip in t5003.

Signed-off-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
René Scharfe authored and Junio C Hamano committed May 20, 2013
1 parent 1355241 commit deb9c8e
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions t/t5000-tar-tree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ GUNZIP=${GUNZIP:-gzip -d}

SUBSTFORMAT=%H%n

check_tar() {
tarfile=$1.tar
listfile=$1.lst
dir=$1
dir_with_prefix=$dir/$2

test_expect_success ' extract tar archive' '
(mkdir $dir && cd $dir && "$TAR" xf -) <$tarfile
'

test_expect_success ' validate filenames' '
(cd ${dir_with_prefix}a && find .) | sort >$listfile &&
test_cmp a.lst $listfile
'

test_expect_success ' validate file contents' '
diff -r a ${dir_with_prefix}a
'
}

test_expect_success \
'populate workdir' \
'mkdir a &&
Expand Down Expand Up @@ -81,6 +101,8 @@ test_expect_success \
'git archive' \
'git archive HEAD >b.tar'

check_tar b

test_expect_success \
'git tar-tree' \
'git tar-tree HEAD >b2.tar'
Expand Down Expand Up @@ -124,19 +146,6 @@ test_expect_success \
'git get-tar-commit-id <b.tar >b.commitid &&
test_cmp .git/$(git symbolic-ref HEAD) b.commitid'

test_expect_success \
'extract tar archive' \
'(mkdir b && cd b && "$TAR" xf -) <b.tar'

test_expect_success \
'validate filenames' \
'(cd b/a && find .) | sort >b.lst &&
test_cmp a.lst b.lst'

test_expect_success \
'validate file contents' \
'diff -r a b/a'

test_expect_success \
'git tar-tree with prefix' \
'git tar-tree HEAD prefix >c.tar'
Expand Down

0 comments on commit deb9c8e

Please sign in to comment.