summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar René Scharfe <rene.scharfe@lsrfire.ath.cx>2013-05-20 11:58:26 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2013-05-20 15:31:45 -0700
commitdeb9c8ed858e431008695fa265e8b20f547192bc (patch)
treed10356c38fe62da0d3959b05a2e005e22db9ce91 /t
parentt5000, t5003: create directories for extracted files lazily (diff)
downloadtgif-deb9c8ed858e431008695fa265e8b20f547192bc.tar.xz
t5000: factor out check_tar
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>
Diffstat (limited to 't')
-rwxr-xr-xt/t5000-tar-tree.sh35
1 files changed, 22 insertions, 13 deletions
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index 41cd6094ac..8337a1f2cf 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -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 &&
@@ -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'
@@ -125,19 +147,6 @@ test_expect_success \
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'