Skip to content

Commit bf3f167

Browse files
committed
Merge branch 'rs/zip-tests'
Update zip tests to skip some that cannot be handled on platform unzip. * rs/zip-tests: t5003: check if unzip supports symlinks t5000, t5003: move ZIP tests into their own script t0024, t5000: use test_lazy_prereq for UNZIP t0024, t5000: clear variable UNZIP, use GIT_UNZIP instead
2 parents 1eba20c + 55292ea commit bf3f167

File tree

5 files changed

+140
-80
lines changed

5 files changed

+140
-80
lines changed

t/t0024-crlf-archive.sh

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
test_description='respect crlf in git archive'
44

55
. ./test-lib.sh
6-
UNZIP=${UNZIP:-unzip}
6+
GIT_UNZIP=${GIT_UNZIP:-unzip}
7+
8+
test_lazy_prereq UNZIP '
9+
"$GIT_UNZIP" -v
10+
test $? -ne 127
11+
'
712

813
test_expect_success setup '
914
@@ -26,18 +31,11 @@ test_expect_success 'tar archive' '
2631
2732
'
2833

29-
"$UNZIP" -v >/dev/null 2>&1
30-
if [ $? -eq 127 ]; then
31-
say "Skipping ZIP test, because unzip was not found"
32-
else
33-
test_set_prereq UNZIP
34-
fi
35-
3634
test_expect_success UNZIP 'zip archive' '
3735
3836
git archive --format=zip HEAD >test.zip &&
3937
40-
( mkdir unzipped && cd unzipped && unzip ../test.zip ) &&
38+
( mkdir unzipped && cd unzipped && "$GIT_UNZIP" ../test.zip ) &&
4139
4240
test_cmp sample unzipped/sample
4341

t/t5000-tar-tree.sh

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,11 @@ commit id embedding:
2525
'
2626

2727
. ./test-lib.sh
28-
UNZIP=${UNZIP:-unzip}
2928
GZIP=${GZIP:-gzip}
3029
GUNZIP=${GUNZIP:-gzip -d}
3130

3231
SUBSTFORMAT=%H%n
3332

34-
check_zip() {
35-
zipfile=$1.zip
36-
listfile=$1.lst
37-
dir=$1
38-
dir_with_prefix=$dir/$2
39-
40-
test_expect_success UNZIP " extract ZIP archive" "
41-
(mkdir $dir && cd $dir && $UNZIP ../$zipfile)
42-
"
43-
44-
test_expect_success UNZIP " validate filenames" "
45-
(cd ${dir_with_prefix}a && find .) | sort >$listfile &&
46-
test_cmp a.lst $listfile
47-
"
48-
49-
test_expect_success UNZIP " validate file contents" "
50-
diff -r a ${dir_with_prefix}a
51-
"
52-
}
53-
5433
test_expect_success \
5534
'populate workdir' \
5635
'mkdir a b c &&
@@ -201,61 +180,11 @@ test_expect_success \
201180
test_cmp a/substfile2 g/prefix/a/substfile2
202181
'
203182

204-
$UNZIP -v >/dev/null 2>&1
205-
if [ $? -eq 127 ]; then
206-
say "Skipping ZIP tests, because unzip was not found"
207-
else
208-
test_set_prereq UNZIP
209-
fi
210-
211-
test_expect_success \
212-
'git archive --format=zip' \
213-
'git archive --format=zip HEAD >d.zip'
214-
215-
check_zip d
216-
217-
test_expect_success \
218-
'git archive --format=zip in a bare repo' \
219-
'(cd bare.git && git archive --format=zip HEAD) >d1.zip'
220-
221-
test_expect_success \
222-
'git archive --format=zip vs. the same in a bare repo' \
223-
'test_cmp d.zip d1.zip'
224-
225-
test_expect_success 'git archive --format=zip with --output' \
226-
'git archive --format=zip --output=d2.zip HEAD &&
227-
test_cmp d.zip d2.zip'
228-
229-
test_expect_success 'git archive with --output, inferring format' '
230-
git archive --output=d3.zip HEAD &&
231-
test_cmp d.zip d3.zip
232-
'
233-
234183
test_expect_success 'git archive with --output, override inferred format' '
235184
git archive --format=tar --output=d4.zip HEAD &&
236185
test_cmp b.tar d4.zip
237186
'
238187

239-
test_expect_success \
240-
'git archive --format=zip with prefix' \
241-
'git archive --format=zip --prefix=prefix/ HEAD >e.zip'
242-
243-
check_zip e prefix/
244-
245-
test_expect_success 'git archive -0 --format=zip on large files' '
246-
test_config core.bigfilethreshold 1 &&
247-
git archive -0 --format=zip HEAD >large.zip
248-
'
249-
250-
check_zip large
251-
252-
test_expect_success 'git archive --format=zip on large files' '
253-
test_config core.bigfilethreshold 1 &&
254-
git archive --format=zip HEAD >large-compressed.zip
255-
'
256-
257-
check_zip large-compressed
258-
259188
test_expect_success \
260189
'git archive --list outside of a git repo' \
261190
'GIT_DIR=some/non-existing/directory git archive --list'

t/t5003-archive-zip.sh

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
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+
test_lazy_prereq UNZIP_SYMLINKS '
16+
(
17+
mkdir unzip-symlinks &&
18+
cd unzip-symlinks &&
19+
"$GIT_UNZIP" "$TEST_DIRECTORY"/t5003/infozip-symlinks.zip &&
20+
test -h symlink
21+
)
22+
'
23+
24+
check_zip() {
25+
zipfile=$1.zip
26+
listfile=$1.lst
27+
dir=$1
28+
dir_with_prefix=$dir/$2
29+
30+
test_expect_success UNZIP " extract ZIP archive" '
31+
(mkdir $dir && cd $dir && "$GIT_UNZIP" ../$zipfile)
32+
'
33+
34+
test_expect_success UNZIP " validate filenames" "
35+
(cd ${dir_with_prefix}a && find .) | sort >$listfile &&
36+
test_cmp a.lst $listfile
37+
"
38+
39+
test_expect_success UNZIP " validate file contents" "
40+
diff -r a ${dir_with_prefix}a
41+
"
42+
}
43+
44+
test_expect_success \
45+
'populate workdir' \
46+
'mkdir a b c &&
47+
echo simple textfile >a/a &&
48+
mkdir a/bin &&
49+
cp /bin/sh a/bin &&
50+
printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 &&
51+
printf "A not substituted O" >a/substfile2 &&
52+
(p=long_path_to_a_file && cd a &&
53+
for depth in 1 2 3 4 5; do mkdir $p && cd $p; done &&
54+
echo text >file_with_long_path)
55+
'
56+
57+
test_expect_success SYMLINKS,UNZIP_SYMLINKS 'add symlink' '
58+
ln -s a a/symlink_to_a
59+
'
60+
61+
test_expect_success 'prepare file list' '
62+
(cd a && find .) | sort >a.lst
63+
'
64+
65+
test_expect_success \
66+
'add ignored file' \
67+
'echo ignore me >a/ignored &&
68+
echo ignored export-ignore >.git/info/attributes'
69+
70+
test_expect_success \
71+
'add files to repository' \
72+
'find a -type f | xargs git update-index --add &&
73+
find a -type l | xargs git update-index --add &&
74+
treeid=`git write-tree` &&
75+
echo $treeid >treeid &&
76+
git update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
77+
git commit-tree $treeid </dev/null)'
78+
79+
test_expect_success \
80+
'create bare clone' \
81+
'git clone --bare . bare.git &&
82+
cp .git/info/attributes bare.git/info/attributes'
83+
84+
test_expect_success \
85+
'remove ignored file' \
86+
'rm a/ignored'
87+
88+
test_expect_success \
89+
'git archive --format=zip' \
90+
'git archive --format=zip HEAD >d.zip'
91+
92+
check_zip d
93+
94+
test_expect_success \
95+
'git archive --format=zip in a bare repo' \
96+
'(cd bare.git && git archive --format=zip HEAD) >d1.zip'
97+
98+
test_expect_success \
99+
'git archive --format=zip vs. the same in a bare repo' \
100+
'test_cmp d.zip d1.zip'
101+
102+
test_expect_success 'git archive --format=zip with --output' \
103+
'git archive --format=zip --output=d2.zip HEAD &&
104+
test_cmp d.zip d2.zip'
105+
106+
test_expect_success 'git archive with --output, inferring format' '
107+
git archive --output=d3.zip HEAD &&
108+
test_cmp d.zip d3.zip
109+
'
110+
111+
test_expect_success \
112+
'git archive --format=zip with prefix' \
113+
'git archive --format=zip --prefix=prefix/ HEAD >e.zip'
114+
115+
check_zip e prefix/
116+
117+
test_expect_success 'git archive -0 --format=zip on large files' '
118+
test_config core.bigfilethreshold 1 &&
119+
git archive -0 --format=zip HEAD >large.zip
120+
'
121+
122+
check_zip large
123+
124+
test_expect_success 'git archive --format=zip on large files' '
125+
test_config core.bigfilethreshold 1 &&
126+
git archive --format=zip HEAD >large-compressed.zip
127+
'
128+
129+
check_zip large-compressed
130+
131+
test_done

t/t5003/infozip-symlinks.zip

328 Bytes
Binary file not shown.

t/test-lib.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ unset VISUAL EMAIL LANGUAGE COLUMNS $("$PERL_PATH" -e '
8585
.*_TEST
8686
PROVE
8787
VALGRIND
88+
UNZIP
8889
PERF_AGGREGATING_LATER
8990
));
9091
my @vars = grep(/^GIT_/ && !/^GIT_($ok)/o, @env);
@@ -128,6 +129,7 @@ fi
128129
unset CDPATH
129130

130131
unset GREP_OPTIONS
132+
unset UNZIP
131133

132134
case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in
133135
1|2|true)

0 commit comments

Comments
 (0)