Merge branch 'rs/zip-tests' into maint
* 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
This commit is contained in:
commit
1bc7a2b38f
@ -3,7 +3,12 @@
|
|||||||
test_description='respect crlf in git archive'
|
test_description='respect crlf in git archive'
|
||||||
|
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
UNZIP=${UNZIP:-unzip}
|
GIT_UNZIP=${GIT_UNZIP:-unzip}
|
||||||
|
|
||||||
|
test_lazy_prereq UNZIP '
|
||||||
|
"$GIT_UNZIP" -v
|
||||||
|
test $? -ne 127
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success setup '
|
test_expect_success setup '
|
||||||
|
|
||||||
@ -26,18 +31,11 @@ test_expect_success 'tar archive' '
|
|||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
"$UNZIP" -v >/dev/null 2>&1
|
|
||||||
if [ $? -eq 127 ]; then
|
|
||||||
say "Skipping ZIP test, because unzip was not found"
|
|
||||||
else
|
|
||||||
test_set_prereq UNZIP
|
|
||||||
fi
|
|
||||||
|
|
||||||
test_expect_success UNZIP 'zip archive' '
|
test_expect_success UNZIP 'zip archive' '
|
||||||
|
|
||||||
git archive --format=zip HEAD >test.zip &&
|
git archive --format=zip HEAD >test.zip &&
|
||||||
|
|
||||||
( mkdir unzipped && cd unzipped && unzip ../test.zip ) &&
|
( mkdir unzipped && cd unzipped && "$GIT_UNZIP" ../test.zip ) &&
|
||||||
|
|
||||||
test_cmp sample unzipped/sample
|
test_cmp sample unzipped/sample
|
||||||
|
|
||||||
|
@ -25,32 +25,11 @@ commit id embedding:
|
|||||||
'
|
'
|
||||||
|
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
UNZIP=${UNZIP:-unzip}
|
|
||||||
GZIP=${GZIP:-gzip}
|
GZIP=${GZIP:-gzip}
|
||||||
GUNZIP=${GUNZIP:-gzip -d}
|
GUNZIP=${GUNZIP:-gzip -d}
|
||||||
|
|
||||||
SUBSTFORMAT=%H%n
|
SUBSTFORMAT=%H%n
|
||||||
|
|
||||||
check_zip() {
|
|
||||||
zipfile=$1.zip
|
|
||||||
listfile=$1.lst
|
|
||||||
dir=$1
|
|
||||||
dir_with_prefix=$dir/$2
|
|
||||||
|
|
||||||
test_expect_success UNZIP " extract ZIP archive" "
|
|
||||||
(mkdir $dir && cd $dir && $UNZIP ../$zipfile)
|
|
||||||
"
|
|
||||||
|
|
||||||
test_expect_success UNZIP " validate filenames" "
|
|
||||||
(cd ${dir_with_prefix}a && find .) | sort >$listfile &&
|
|
||||||
test_cmp a.lst $listfile
|
|
||||||
"
|
|
||||||
|
|
||||||
test_expect_success UNZIP " validate file contents" "
|
|
||||||
diff -r a ${dir_with_prefix}a
|
|
||||||
"
|
|
||||||
}
|
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'populate workdir' \
|
'populate workdir' \
|
||||||
'mkdir a b c &&
|
'mkdir a b c &&
|
||||||
@ -201,61 +180,11 @@ test_expect_success \
|
|||||||
test_cmp a/substfile2 g/prefix/a/substfile2
|
test_cmp a/substfile2 g/prefix/a/substfile2
|
||||||
'
|
'
|
||||||
|
|
||||||
$UNZIP -v >/dev/null 2>&1
|
|
||||||
if [ $? -eq 127 ]; then
|
|
||||||
say "Skipping ZIP tests, because unzip was not found"
|
|
||||||
else
|
|
||||||
test_set_prereq UNZIP
|
|
||||||
fi
|
|
||||||
|
|
||||||
test_expect_success \
|
|
||||||
'git archive --format=zip' \
|
|
||||||
'git archive --format=zip HEAD >d.zip'
|
|
||||||
|
|
||||||
check_zip d
|
|
||||||
|
|
||||||
test_expect_success \
|
|
||||||
'git archive --format=zip in a bare repo' \
|
|
||||||
'(cd bare.git && git archive --format=zip HEAD) >d1.zip'
|
|
||||||
|
|
||||||
test_expect_success \
|
|
||||||
'git archive --format=zip vs. the same in a bare repo' \
|
|
||||||
'test_cmp d.zip d1.zip'
|
|
||||||
|
|
||||||
test_expect_success 'git archive --format=zip with --output' \
|
|
||||||
'git archive --format=zip --output=d2.zip HEAD &&
|
|
||||||
test_cmp d.zip d2.zip'
|
|
||||||
|
|
||||||
test_expect_success 'git archive with --output, inferring format' '
|
|
||||||
git archive --output=d3.zip HEAD &&
|
|
||||||
test_cmp d.zip d3.zip
|
|
||||||
'
|
|
||||||
|
|
||||||
test_expect_success 'git archive with --output, override inferred format' '
|
test_expect_success 'git archive with --output, override inferred format' '
|
||||||
git archive --format=tar --output=d4.zip HEAD &&
|
git archive --format=tar --output=d4.zip HEAD &&
|
||||||
test_cmp b.tar d4.zip
|
test_cmp b.tar d4.zip
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success \
|
|
||||||
'git archive --format=zip with prefix' \
|
|
||||||
'git archive --format=zip --prefix=prefix/ HEAD >e.zip'
|
|
||||||
|
|
||||||
check_zip e prefix/
|
|
||||||
|
|
||||||
test_expect_success 'git archive -0 --format=zip on large files' '
|
|
||||||
test_config core.bigfilethreshold 1 &&
|
|
||||||
git archive -0 --format=zip HEAD >large.zip
|
|
||||||
'
|
|
||||||
|
|
||||||
check_zip large
|
|
||||||
|
|
||||||
test_expect_success 'git archive --format=zip on large files' '
|
|
||||||
test_config core.bigfilethreshold 1 &&
|
|
||||||
git archive --format=zip HEAD >large-compressed.zip
|
|
||||||
'
|
|
||||||
|
|
||||||
check_zip large-compressed
|
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'git archive --list outside of a git repo' \
|
'git archive --list outside of a git repo' \
|
||||||
'GIT_DIR=some/non-existing/directory git archive --list'
|
'GIT_DIR=some/non-existing/directory git archive --list'
|
||||||
|
131
t/t5003-archive-zip.sh
Executable file
131
t/t5003-archive-zip.sh
Executable file
@ -0,0 +1,131 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
test_description='git archive --format=zip test'
|
||||||
|
|
||||||
|
. ./test-lib.sh
|
||||||
|
GIT_UNZIP=${GIT_UNZIP:-unzip}
|
||||||
|
|
||||||
|
SUBSTFORMAT=%H%n
|
||||||
|
|
||||||
|
test_lazy_prereq UNZIP '
|
||||||
|
"$GIT_UNZIP" -v
|
||||||
|
test $? -ne 127
|
||||||
|
'
|
||||||
|
|
||||||
|
test_lazy_prereq UNZIP_SYMLINKS '
|
||||||
|
(
|
||||||
|
mkdir unzip-symlinks &&
|
||||||
|
cd unzip-symlinks &&
|
||||||
|
"$GIT_UNZIP" "$TEST_DIRECTORY"/t5003/infozip-symlinks.zip &&
|
||||||
|
test -h symlink
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
check_zip() {
|
||||||
|
zipfile=$1.zip
|
||||||
|
listfile=$1.lst
|
||||||
|
dir=$1
|
||||||
|
dir_with_prefix=$dir/$2
|
||||||
|
|
||||||
|
test_expect_success UNZIP " extract ZIP archive" '
|
||||||
|
(mkdir $dir && cd $dir && "$GIT_UNZIP" ../$zipfile)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success UNZIP " validate filenames" "
|
||||||
|
(cd ${dir_with_prefix}a && find .) | sort >$listfile &&
|
||||||
|
test_cmp a.lst $listfile
|
||||||
|
"
|
||||||
|
|
||||||
|
test_expect_success UNZIP " validate file contents" "
|
||||||
|
diff -r a ${dir_with_prefix}a
|
||||||
|
"
|
||||||
|
}
|
||||||
|
|
||||||
|
test_expect_success \
|
||||||
|
'populate workdir' \
|
||||||
|
'mkdir a b c &&
|
||||||
|
echo simple textfile >a/a &&
|
||||||
|
mkdir a/bin &&
|
||||||
|
cp /bin/sh a/bin &&
|
||||||
|
printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 &&
|
||||||
|
printf "A not substituted O" >a/substfile2 &&
|
||||||
|
(p=long_path_to_a_file && cd a &&
|
||||||
|
for depth in 1 2 3 4 5; do mkdir $p && cd $p; done &&
|
||||||
|
echo text >file_with_long_path)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success SYMLINKS,UNZIP_SYMLINKS 'add symlink' '
|
||||||
|
ln -s a a/symlink_to_a
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'prepare file list' '
|
||||||
|
(cd a && find .) | sort >a.lst
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success \
|
||||||
|
'add ignored file' \
|
||||||
|
'echo ignore me >a/ignored &&
|
||||||
|
echo ignored export-ignore >.git/info/attributes'
|
||||||
|
|
||||||
|
test_expect_success \
|
||||||
|
'add files to repository' \
|
||||||
|
'find a -type f | xargs git update-index --add &&
|
||||||
|
find a -type l | xargs git update-index --add &&
|
||||||
|
treeid=`git write-tree` &&
|
||||||
|
echo $treeid >treeid &&
|
||||||
|
git update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
|
||||||
|
git commit-tree $treeid </dev/null)'
|
||||||
|
|
||||||
|
test_expect_success \
|
||||||
|
'create bare clone' \
|
||||||
|
'git clone --bare . bare.git &&
|
||||||
|
cp .git/info/attributes bare.git/info/attributes'
|
||||||
|
|
||||||
|
test_expect_success \
|
||||||
|
'remove ignored file' \
|
||||||
|
'rm a/ignored'
|
||||||
|
|
||||||
|
test_expect_success \
|
||||||
|
'git archive --format=zip' \
|
||||||
|
'git archive --format=zip HEAD >d.zip'
|
||||||
|
|
||||||
|
check_zip d
|
||||||
|
|
||||||
|
test_expect_success \
|
||||||
|
'git archive --format=zip in a bare repo' \
|
||||||
|
'(cd bare.git && git archive --format=zip HEAD) >d1.zip'
|
||||||
|
|
||||||
|
test_expect_success \
|
||||||
|
'git archive --format=zip vs. the same in a bare repo' \
|
||||||
|
'test_cmp d.zip d1.zip'
|
||||||
|
|
||||||
|
test_expect_success 'git archive --format=zip with --output' \
|
||||||
|
'git archive --format=zip --output=d2.zip HEAD &&
|
||||||
|
test_cmp d.zip d2.zip'
|
||||||
|
|
||||||
|
test_expect_success 'git archive with --output, inferring format' '
|
||||||
|
git archive --output=d3.zip HEAD &&
|
||||||
|
test_cmp d.zip d3.zip
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success \
|
||||||
|
'git archive --format=zip with prefix' \
|
||||||
|
'git archive --format=zip --prefix=prefix/ HEAD >e.zip'
|
||||||
|
|
||||||
|
check_zip e prefix/
|
||||||
|
|
||||||
|
test_expect_success 'git archive -0 --format=zip on large files' '
|
||||||
|
test_config core.bigfilethreshold 1 &&
|
||||||
|
git archive -0 --format=zip HEAD >large.zip
|
||||||
|
'
|
||||||
|
|
||||||
|
check_zip large
|
||||||
|
|
||||||
|
test_expect_success 'git archive --format=zip on large files' '
|
||||||
|
test_config core.bigfilethreshold 1 &&
|
||||||
|
git archive --format=zip HEAD >large-compressed.zip
|
||||||
|
'
|
||||||
|
|
||||||
|
check_zip large-compressed
|
||||||
|
|
||||||
|
test_done
|
BIN
t/t5003/infozip-symlinks.zip
Normal file
BIN
t/t5003/infozip-symlinks.zip
Normal file
Binary file not shown.
@ -85,6 +85,7 @@ unset VISUAL EMAIL LANGUAGE COLUMNS $("$PERL_PATH" -e '
|
|||||||
.*_TEST
|
.*_TEST
|
||||||
PROVE
|
PROVE
|
||||||
VALGRIND
|
VALGRIND
|
||||||
|
UNZIP
|
||||||
PERF_AGGREGATING_LATER
|
PERF_AGGREGATING_LATER
|
||||||
));
|
));
|
||||||
my @vars = grep(/^GIT_/ && !/^GIT_($ok)/o, @env);
|
my @vars = grep(/^GIT_/ && !/^GIT_($ok)/o, @env);
|
||||||
@ -128,6 +129,7 @@ fi
|
|||||||
unset CDPATH
|
unset CDPATH
|
||||||
|
|
||||||
unset GREP_OPTIONS
|
unset GREP_OPTIONS
|
||||||
|
unset UNZIP
|
||||||
|
|
||||||
case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in
|
case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in
|
||||||
1|2|true)
|
1|2|true)
|
||||||
|
Loading…
Reference in New Issue
Block a user