t5000, t5003: move ZIP tests into their own script

This makes ZIP specific tweaks easier. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Jan 6, 2013 at 18:51 UTC e9882c80cda6decc2381ecbdd1f99ad6e49b4662
2 files changed +119 -69
t/t5000-tar-tree.sh
-69
@@ -25,37 +25,11 @@ commit id embedding:
25 '
26
27 . ./test-lib.sh
28 -GIT_UNZIP=${GIT_UNZIP:-unzip}
28 GZIP=${GZIP:-gzip}
29 GUNZIP=${GUNZIP:-gzip -d}
30
31 SUBSTFORMAT=%H%n
32
34 -test_lazy_prereq UNZIP '
35 - "$GIT_UNZIP" -v
36 - test $? -ne 127
37 -'
38 -
39 -check_zip() {
40 - zipfile=$1.zip
41 - listfile=$1.lst
42 - dir=$1
43 - dir_with_prefix=$dir/$2
44 -
45 - test_expect_success UNZIP " extract ZIP archive" '
46 - (mkdir $dir && cd $dir && "$GIT_UNZIP" ../$zipfile)
47 - '
48 -
49 - test_expect_success UNZIP " validate filenames" "
50 - (cd ${dir_with_prefix}a && find .) | sort >$listfile &&
51 - test_cmp a.lst $listfile
52 - "
53 -
54 - test_expect_success UNZIP " validate file contents" "
55 - diff -r a ${dir_with_prefix}a
56 - "
57 -}
58 -
33 test_expect_success \
34 'populate workdir' \
35 'mkdir a b c &&
@@ -206,54 +180,11 @@ test_expect_success \
180 test_cmp a/substfile2 g/prefix/a/substfile2
181 '
182
209 -test_expect_success \
210 - 'git archive --format=zip' \
211 - 'git archive --format=zip HEAD >d.zip'
212 -
213 -check_zip d
214 -
215 -test_expect_success \
216 - 'git archive --format=zip in a bare repo' \
217 - '(cd bare.git && git archive --format=zip HEAD) >d1.zip'
218 -
219 -test_expect_success \
220 - 'git archive --format=zip vs. the same in a bare repo' \
221 - 'test_cmp d.zip d1.zip'
222 -
223 -test_expect_success 'git archive --format=zip with --output' \
224 - 'git archive --format=zip --output=d2.zip HEAD &&
225 - test_cmp d.zip d2.zip'
226 -
227 -test_expect_success 'git archive with --output, inferring format' '
228 - git archive --output=d3.zip HEAD &&
229 - test_cmp d.zip d3.zip
230 -'
231 -
183 test_expect_success 'git archive with --output, override inferred format' '
184 git archive --format=tar --output=d4.zip HEAD &&
185 test_cmp b.tar d4.zip
186 '
187
237 -test_expect_success \
238 - 'git archive --format=zip with prefix' \
239 - 'git archive --format=zip --prefix=prefix/ HEAD >e.zip'
240 -
241 -check_zip e prefix/
242 -
243 -test_expect_success 'git archive -0 --format=zip on large files' '
244 - test_config core.bigfilethreshold 1 &&
245 - git archive -0 --format=zip HEAD >large.zip
246 -'
247 -
248 -check_zip large
249 -
250 -test_expect_success 'git archive --format=zip on large files' '
251 - test_config core.bigfilethreshold 1 &&
252 - git archive --format=zip HEAD >large-compressed.zip
253 -'
254 -
255 -check_zip large-compressed
256 -
188 test_expect_success \
189 'git archive --list outside of a git repo' \
190 'GIT_DIR=some/non-existing/directory git archive --list'
t/t5003-archive-zip.sh new
+119
@@ -0,0 +1,119 @@
1 +#!/bin/sh
2 +
3 +test_description='git archive --format=zip test'
4 +
5 +. ./test-lib.sh
6 +GIT_UNZIP=${GIT_UNZIP:-unzip}
7 +
8 +SUBSTFORMAT=%H%n
9 +
10 +test_lazy_prereq UNZIP '
11 + "$GIT_UNZIP" -v
12 + test $? -ne 127
13 +'
14 +
15 +check_zip() {
16 + zipfile=$1.zip
17 + listfile=$1.lst
18 + dir=$1
19 + dir_with_prefix=$dir/$2
20 +
21 + test_expect_success UNZIP " extract ZIP archive" '
22 + (mkdir $dir && cd $dir && "$GIT_UNZIP" ../$zipfile)
23 + '
24 +
25 + test_expect_success UNZIP " validate filenames" "
26 + (cd ${dir_with_prefix}a && find .) | sort >$listfile &&
27 + test_cmp a.lst $listfile
28 + "
29 +
30 + test_expect_success UNZIP " validate file contents" "
31 + diff -r a ${dir_with_prefix}a
32 + "
33 +}
34 +
35 +test_expect_success \
36 + 'populate workdir' \
37 + 'mkdir a b c &&
38 + echo simple textfile >a/a &&
39 + mkdir a/bin &&
40 + cp /bin/sh a/bin &&
41 + printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 &&
42 + printf "A not substituted O" >a/substfile2 &&
43 + if test_have_prereq SYMLINKS; then
44 + ln -s a a/l1
45 + else
46 + printf %s a > a/l1
47 + fi &&
48 + (p=long_path_to_a_file && cd a &&
49 + for depth in 1 2 3 4 5; do mkdir $p && cd $p; done &&
50 + echo text >file_with_long_path) &&
51 + (cd a && find .) | sort >a.lst'
52 +
53 +test_expect_success \
54 + 'add ignored file' \
55 + 'echo ignore me >a/ignored &&
56 + echo ignored export-ignore >.git/info/attributes'
57 +
58 +test_expect_success \
59 + 'add files to repository' \
60 + 'find a -type f | xargs git update-index --add &&
61 + find a -type l | xargs git update-index --add &&
62 + treeid=`git write-tree` &&
63 + echo $treeid >treeid &&
64 + git update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
65 + git commit-tree $treeid </dev/null)'
66 +
67 +test_expect_success \
68 + 'create bare clone' \
69 + 'git clone --bare . bare.git &&
70 + cp .git/info/attributes bare.git/info/attributes'
71 +
72 +test_expect_success \
73 + 'remove ignored file' \
74 + 'rm a/ignored'
75 +
76 +test_expect_success \
77 + 'git archive --format=zip' \
78 + 'git archive --format=zip HEAD >d.zip'
79 +
80 +check_zip d
81 +
82 +test_expect_success \
83 + 'git archive --format=zip in a bare repo' \
84 + '(cd bare.git && git archive --format=zip HEAD) >d1.zip'
85 +
86 +test_expect_success \
87 + 'git archive --format=zip vs. the same in a bare repo' \
88 + 'test_cmp d.zip d1.zip'
89 +
90 +test_expect_success 'git archive --format=zip with --output' \
91 + 'git archive --format=zip --output=d2.zip HEAD &&
92 + test_cmp d.zip d2.zip'
93 +
94 +test_expect_success 'git archive with --output, inferring format' '
95 + git archive --output=d3.zip HEAD &&
96 + test_cmp d.zip d3.zip
97 +'
98 +
99 +test_expect_success \
100 + 'git archive --format=zip with prefix' \
101 + 'git archive --format=zip --prefix=prefix/ HEAD >e.zip'
102 +
103 +check_zip e prefix/
104 +
105 +test_expect_success 'git archive -0 --format=zip on large files' '
106 + test_config core.bigfilethreshold 1 &&
107 + git archive -0 --format=zip HEAD >large.zip
108 +'
109 +
110 +check_zip large
111 +
112 +test_expect_success 'git archive --format=zip on large files' '
113 + test_config core.bigfilethreshold 1 &&
114 + git archive --format=zip HEAD >large-compressed.zip
115 +'
116 +
117 +check_zip large-compressed
118 +
119 +test_done