Skip to content

Commit deb9c8e

Browse files
René Scharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1355241 commit deb9c8e

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

t/t5000-tar-tree.sh

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,26 @@ GUNZIP=${GUNZIP:-gzip -d}
3030

3131
SUBSTFORMAT=%H%n
3232

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+
3353
test_expect_success \
3454
'populate workdir' \
3555
'mkdir a &&
@@ -81,6 +101,8 @@ test_expect_success \
81101
'git archive' \
82102
'git archive HEAD >b.tar'
83103

104+
check_tar b
105+
84106
test_expect_success \
85107
'git tar-tree' \
86108
'git tar-tree HEAD >b2.tar'
@@ -124,19 +146,6 @@ test_expect_success \
124146
'git get-tar-commit-id <b.tar >b.commitid &&
125147
test_cmp .git/$(git symbolic-ref HEAD) b.commitid'
126148

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-
140149
test_expect_success \
141150
'git tar-tree with prefix' \
142151
'git tar-tree HEAD prefix >c.tar'

0 commit comments

Comments
 (0)