Merge branch 'cb/http-test'
* cb/http-test: http-push: add regression tests http-push: push <remote> :<branch> deletes remote branch
This commit is contained in:
17
http-push.c
17
http-push.c
@ -2133,6 +2133,8 @@ static int delete_remote_branch(char *pattern, int force)
|
|||||||
|
|
||||||
/* Send delete request */
|
/* Send delete request */
|
||||||
fprintf(stderr, "Removing remote branch '%s'\n", remote_ref->name);
|
fprintf(stderr, "Removing remote branch '%s'\n", remote_ref->name);
|
||||||
|
if (dry_run)
|
||||||
|
return 0;
|
||||||
url = xmalloc(strlen(remote->url) + strlen(remote_ref->name) + 1);
|
url = xmalloc(strlen(remote->url) + strlen(remote_ref->name) + 1);
|
||||||
sprintf(url, "%s%s", remote->url, remote_ref->name);
|
sprintf(url, "%s%s", remote->url, remote_ref->name);
|
||||||
slot = get_active_slot();
|
slot = get_active_slot();
|
||||||
@ -2306,6 +2308,16 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (!ref->peer_ref)
|
if (!ref->peer_ref)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (is_zero_sha1(ref->peer_ref->new_sha1)) {
|
||||||
|
if (delete_remote_branch(ref->name, 1) == -1) {
|
||||||
|
error("Could not remove %s", ref->name);
|
||||||
|
rc = -4;
|
||||||
|
}
|
||||||
|
new_refs++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!hashcmp(ref->old_sha1, ref->peer_ref->new_sha1)) {
|
if (!hashcmp(ref->old_sha1, ref->peer_ref->new_sha1)) {
|
||||||
if (push_verbosely || 1)
|
if (push_verbosely || 1)
|
||||||
fprintf(stderr, "'%s': up-to-date\n", ref->name);
|
fprintf(stderr, "'%s': up-to-date\n", ref->name);
|
||||||
@ -2337,11 +2349,6 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
|
hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
|
||||||
if (is_zero_sha1(ref->new_sha1)) {
|
|
||||||
error("cannot happen anymore");
|
|
||||||
rc = -3;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
new_refs++;
|
new_refs++;
|
||||||
strcpy(old_hex, sha1_to_hex(ref->old_sha1));
|
strcpy(old_hex, sha1_to_hex(ref->old_sha1));
|
||||||
new_hex = sha1_to_hex(ref->new_sha1);
|
new_hex = sha1_to_hex(ref->new_sha1);
|
||||||
|
96
t/lib-httpd.sh
Normal file
96
t/lib-httpd.sh
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
|
||||||
|
#
|
||||||
|
|
||||||
|
if test -z "$GIT_TEST_HTTPD"
|
||||||
|
then
|
||||||
|
say "skipping test, network testing disabled by default"
|
||||||
|
say "(define GIT_TEST_HTTPD to enable)"
|
||||||
|
test_done
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
LIB_HTTPD_PATH=${LIB_HTTPD_PATH-'/usr/sbin/apache2'}
|
||||||
|
LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'8111'}
|
||||||
|
|
||||||
|
TEST_PATH="$PWD"/../lib-httpd
|
||||||
|
HTTPD_ROOT_PATH="$PWD"/httpd
|
||||||
|
HTTPD_DOCUMENT_ROOT_PATH=$HTTPD_ROOT_PATH/www
|
||||||
|
|
||||||
|
if ! test -x "$LIB_HTTPD_PATH"
|
||||||
|
then
|
||||||
|
say "skipping test, no web server found at '$LIB_HTTPD_PATH'"
|
||||||
|
test_done
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
HTTPD_VERSION=`$LIB_HTTPD_PATH -v | \
|
||||||
|
sed -n 's/^Server version: Apache\/\([0-9]*\)\..*$/\1/p; q'`
|
||||||
|
|
||||||
|
if test -n "$HTTPD_VERSION"
|
||||||
|
then
|
||||||
|
if test -z "$LIB_HTTPD_MODULE_PATH"
|
||||||
|
then
|
||||||
|
if ! test $HTTPD_VERSION -ge 2
|
||||||
|
then
|
||||||
|
say "skipping test, at least Apache version 2 is required"
|
||||||
|
test_done
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
LIB_HTTPD_MODULE_PATH='/usr/lib/apache2/modules'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
error "Could not identify web server at '$LIB_HTTPD_PATH'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
HTTPD_PARA="-d $HTTPD_ROOT_PATH -f $TEST_PATH/apache.conf"
|
||||||
|
|
||||||
|
prepare_httpd() {
|
||||||
|
mkdir -p $HTTPD_DOCUMENT_ROOT_PATH
|
||||||
|
|
||||||
|
ln -s $LIB_HTTPD_MODULE_PATH $HTTPD_ROOT_PATH/modules
|
||||||
|
|
||||||
|
if test -n "$LIB_HTTPD_SSL"
|
||||||
|
then
|
||||||
|
HTTPD_URL=https://127.0.0.1:$LIB_HTTPD_PORT
|
||||||
|
|
||||||
|
RANDFILE_PATH="$HTTPD_ROOT_PATH"/.rnd openssl req \
|
||||||
|
-config $TEST_PATH/ssl.cnf \
|
||||||
|
-new -x509 -nodes \
|
||||||
|
-out $HTTPD_ROOT_PATH/httpd.pem \
|
||||||
|
-keyout $HTTPD_ROOT_PATH/httpd.pem
|
||||||
|
export GIT_SSL_NO_VERIFY=t
|
||||||
|
HTTPD_PARA="$HTTPD_PARA -DSSL"
|
||||||
|
else
|
||||||
|
HTTPD_URL=http://127.0.0.1:$LIB_HTTPD_PORT
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -n "$LIB_HTTPD_DAV" -o -n "$LIB_HTTPD_SVN"
|
||||||
|
then
|
||||||
|
HTTPD_PARA="$HTTPD_PARA -DDAV"
|
||||||
|
|
||||||
|
if test -n "$LIB_HTTPD_SVN"
|
||||||
|
then
|
||||||
|
HTTPD_PARA="$HTTPD_PARA -DSVN"
|
||||||
|
rawsvnrepo="$HTTPD_ROOT_PATH/svnrepo"
|
||||||
|
svnrepo="http://127.0.0.1:$LIB_HTTPD_PORT/svn"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
start_httpd() {
|
||||||
|
prepare_httpd
|
||||||
|
|
||||||
|
trap 'stop_httpd; die' exit
|
||||||
|
|
||||||
|
"$LIB_HTTPD_PATH" $HTTPD_PARA \
|
||||||
|
-c "Listen 127.0.0.1:$LIB_HTTPD_PORT" -k start
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_httpd() {
|
||||||
|
trap 'die' exit
|
||||||
|
|
||||||
|
"$LIB_HTTPD_PATH" $HTTPD_PARA -k stop
|
||||||
|
}
|
34
t/lib-httpd/apache.conf
Normal file
34
t/lib-httpd/apache.conf
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
PidFile httpd.pid
|
||||||
|
DocumentRoot www
|
||||||
|
ErrorLog error.log
|
||||||
|
|
||||||
|
<IfDefine SSL>
|
||||||
|
LoadModule ssl_module modules/mod_ssl.so
|
||||||
|
|
||||||
|
SSLCertificateFile httpd.pem
|
||||||
|
SSLCertificateKeyFile httpd.pem
|
||||||
|
SSLRandomSeed startup file:/dev/urandom 512
|
||||||
|
SSLRandomSeed connect file:/dev/urandom 512
|
||||||
|
SSLSessionCache none
|
||||||
|
SSLMutex file:ssl_mutex
|
||||||
|
SSLEngine On
|
||||||
|
</IfDefine>
|
||||||
|
|
||||||
|
<IfDefine DAV>
|
||||||
|
LoadModule dav_module modules/mod_dav.so
|
||||||
|
LoadModule dav_fs_module modules/mod_dav_fs.so
|
||||||
|
|
||||||
|
DAVLockDB DAVLock
|
||||||
|
<Location />
|
||||||
|
Dav on
|
||||||
|
</Location>
|
||||||
|
</IfDefine>
|
||||||
|
|
||||||
|
<IfDefine SVN>
|
||||||
|
LoadModule dav_svn_module modules/mod_dav_svn.so
|
||||||
|
|
||||||
|
<Location /svn>
|
||||||
|
DAV svn
|
||||||
|
SVNPath svnrepo
|
||||||
|
</Location>
|
||||||
|
</IfDefine>
|
8
t/lib-httpd/ssl.cnf
Normal file
8
t/lib-httpd/ssl.cnf
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
RANDFILE = $ENV::RANDFILE_PATH
|
||||||
|
|
||||||
|
[ req ]
|
||||||
|
default_bits = 1024
|
||||||
|
distinguished_name = req_distinguished_name
|
||||||
|
prompt = no
|
||||||
|
[ req_distinguished_name ]
|
||||||
|
commonName = 127.0.0.1
|
73
t/t5540-http-push.sh
Executable file
73
t/t5540-http-push.sh
Executable file
@ -0,0 +1,73 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
|
||||||
|
#
|
||||||
|
|
||||||
|
test_description='test http-push
|
||||||
|
|
||||||
|
This test runs various sanity checks on http-push.'
|
||||||
|
|
||||||
|
. ./test-lib.sh
|
||||||
|
|
||||||
|
ROOT_PATH="$PWD"
|
||||||
|
LIB_HTTPD_DAV=t
|
||||||
|
|
||||||
|
. ../lib-httpd.sh
|
||||||
|
|
||||||
|
if ! start_httpd >&3 2>&4
|
||||||
|
then
|
||||||
|
say "skipping test, web server setup failed"
|
||||||
|
test_done
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
test_expect_success 'setup remote repository' '
|
||||||
|
cd "$ROOT_PATH" &&
|
||||||
|
mkdir test_repo &&
|
||||||
|
cd test_repo &&
|
||||||
|
git init &&
|
||||||
|
: >path1 &&
|
||||||
|
git add path1 &&
|
||||||
|
test_tick &&
|
||||||
|
git commit -m initial &&
|
||||||
|
cd - &&
|
||||||
|
git clone --bare test_repo test_repo.git &&
|
||||||
|
cd test_repo.git &&
|
||||||
|
git --bare update-server-info &&
|
||||||
|
chmod +x hooks/post-update &&
|
||||||
|
cd - &&
|
||||||
|
mv test_repo.git $HTTPD_DOCUMENT_ROOT_PATH
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'clone remote repository' '
|
||||||
|
cd "$ROOT_PATH" &&
|
||||||
|
git clone $HTTPD_URL/test_repo.git test_repo_clone
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'push to remote repository' '
|
||||||
|
cd "$ROOT_PATH"/test_repo_clone &&
|
||||||
|
: >path2 &&
|
||||||
|
git add path2 &&
|
||||||
|
test_tick &&
|
||||||
|
git commit -m path2 &&
|
||||||
|
git push
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'create and delete remote branch' '
|
||||||
|
cd "$ROOT_PATH"/test_repo_clone &&
|
||||||
|
git checkout -b dev &&
|
||||||
|
: >path3 &&
|
||||||
|
git add path3 &&
|
||||||
|
test_tick &&
|
||||||
|
git commit -m dev &&
|
||||||
|
git push origin dev &&
|
||||||
|
git fetch &&
|
||||||
|
git push origin :dev &&
|
||||||
|
git branch -d -r origin/dev &&
|
||||||
|
git fetch &&
|
||||||
|
! git show-ref --verify refs/remotes/origin/dev
|
||||||
|
'
|
||||||
|
|
||||||
|
stop_httpd
|
||||||
|
|
||||||
|
test_done
|
@ -80,7 +80,7 @@ do
|
|||||||
-q|--q|--qu|--qui|--quie|--quiet)
|
-q|--q|--qu|--qui|--quie|--quiet)
|
||||||
quiet=t; shift ;;
|
quiet=t; shift ;;
|
||||||
--no-color)
|
--no-color)
|
||||||
color=; shift ;;
|
color=; shift ;;
|
||||||
--no-python)
|
--no-python)
|
||||||
# noop now...
|
# noop now...
|
||||||
shift ;;
|
shift ;;
|
||||||
@ -142,7 +142,12 @@ test_count=0
|
|||||||
test_fixed=0
|
test_fixed=0
|
||||||
test_broken=0
|
test_broken=0
|
||||||
|
|
||||||
trap 'echo >&5 "FATAL: Unexpected exit with code $?"; exit 1' exit
|
die () {
|
||||||
|
echo >&5 "FATAL: Unexpected exit with code $?"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
trap 'die' exit
|
||||||
|
|
||||||
test_tick () {
|
test_tick () {
|
||||||
if test -z "${test_tick+set}"
|
if test -z "${test_tick+set}"
|
||||||
|
Reference in New Issue
Block a user