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>
René Scharfe committed
May 20, 2013 at 11:58 UTC
deb9c8ed858e431008695fa265e8b20f547192bc
1 file changed
+22
-13
t/t5000-tar-tree.sh
+22
-13
@@ -30,6 +30,26 @@ GUNZIP=${GUNZIP:-gzip -d}
30
31
SUBSTFORMAT=%H%n
32
33
+check_tar() {
34
+ tarfile=$1.tar
35
+ listfile=$1.lst
36
+ dir=$1
37
+ dir_with_prefix=$dir/$2
38
+
39
+ test_expect_success ' extract tar archive' '
40
+ (mkdir $dir && cd $dir && "$TAR" xf -) <$tarfile
41
+ '
42
+
43
+ test_expect_success ' validate filenames' '
44
+ (cd ${dir_with_prefix}a && find .) | sort >$listfile &&
45
+ test_cmp a.lst $listfile
46
+ '
47
+
48
+ test_expect_success ' validate file contents' '
49
+ diff -r a ${dir_with_prefix}a
50
+ '
51
+}
52
+
53
test_expect_success \
54
'populate workdir' \
55
'mkdir a &&
@@ -81,6 +101,8 @@ test_expect_success \
101
'git archive' \
102
'git archive HEAD >b.tar'
103
104
+check_tar b
105
+
106
test_expect_success \
107
'git tar-tree' \
108
'git tar-tree HEAD >b2.tar'
@@ -124,19 +146,6 @@ test_expect_success \
146
'git get-tar-commit-id <b.tar >b.commitid &&
147
test_cmp .git/$(git symbolic-ref HEAD) b.commitid'
148
127
-test_expect_success \
128
- 'extract tar archive' \
129
- '(mkdir b && cd b && "$TAR" xf -) <b.tar'
130
-
131
-test_expect_success \
132
- 'validate filenames' \
133
- '(cd b/a && find .) | sort >b.lst &&
134
- test_cmp a.lst b.lst'
135
-
136
-test_expect_success \
137
- 'validate file contents' \
138
- 'diff -r a b/a'
139
-
149
test_expect_success \
150
'git tar-tree with prefix' \
151
'git tar-tree HEAD prefix >c.tar'