t5516: refactor oddball tests

t5516 sets up some utility functions for starting each test
with a clean slate. However, there were a few tests added
that do not use these functions, but instead make their own
repositories.

Let's bring these in line with the rest of the tests. Not
only do we reduce the number of lines, but these tests will
benefit from any further enhancements to the utility
scripts.

The conversion is pretty straightforward. Most of the tests
created a parent/child clone relationship, for which we now
use 'testrepo' as the parent.  One test looked in testrepo,
but relied on previous tests to have set it up; it now sets
up testrepo explicitly, which makes it a bit more robust to
changes in the script, as well.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Jeff King 2008-11-07 17:20:33 -05:00 committed by Junio C Hamano
parent bc9c0248a5
commit b2dc968e60
1 changed files with 21 additions and 29 deletions

View File

@ -39,6 +39,11 @@ mk_test () {
) )
} }


mk_child() {
rm -rf "$1" &&
git clone testrepo "$1"
}

check_push_result () { check_push_result () {
( (
cd testrepo && cd testrepo &&
@ -425,13 +430,10 @@ test_expect_success 'push with dry-run' '


test_expect_success 'push updates local refs' ' test_expect_success 'push updates local refs' '


rm -rf parent child && mk_test heads/master &&
mkdir parent && mk_child child &&
(cd parent && git init &&
echo one >foo && git add foo && git commit -m one) &&
git clone parent child &&
(cd child && (cd child &&
echo two >foo && git commit -a -m two && git pull .. master &&
git push && git push &&
test $(git rev-parse master) = $(git rev-parse remotes/origin/master)) test $(git rev-parse master) = $(git rev-parse remotes/origin/master))


@ -439,15 +441,10 @@ test_expect_success 'push updates local refs' '


test_expect_success 'push updates up-to-date local refs' ' test_expect_success 'push updates up-to-date local refs' '


rm -rf parent child && mk_test heads/master &&
mkdir parent && mk_child child1 &&
(cd parent && git init && mk_child child2 &&
echo one >foo && git add foo && git commit -m one) && (cd child1 && git pull .. master && git push) &&
git clone parent child1 &&
git clone parent child2 &&
(cd child1 &&
echo two >foo && git commit -a -m two &&
git push) &&
(cd child2 && (cd child2 &&
git pull ../child1 master && git pull ../child1 master &&
git push && git push &&
@ -457,11 +454,8 @@ test_expect_success 'push updates up-to-date local refs' '


test_expect_success 'push preserves up-to-date packed refs' ' test_expect_success 'push preserves up-to-date packed refs' '


rm -rf parent child && mk_test heads/master &&
mkdir parent && mk_child child &&
(cd parent && git init &&
echo one >foo && git add foo && git commit -m one) &&
git clone parent child &&
(cd child && (cd child &&
git push && git push &&
! test -f .git/refs/remotes/origin/master) ! test -f .git/refs/remotes/origin/master)
@ -470,15 +464,13 @@ test_expect_success 'push preserves up-to-date packed refs' '


test_expect_success 'push does not update local refs on failure' ' test_expect_success 'push does not update local refs on failure' '


rm -rf parent child && mk_test heads/master &&
mkdir parent && mk_child child &&
(cd parent && git init && mkdir testrepo/.git/hooks &&
echo one >foo && git add foo && git commit -m one && echo exit 1 >testrepo/.git/hooks/pre-receive &&
echo exit 1 >.git/hooks/pre-receive && chmod +x testrepo/.git/hooks/pre-receive &&
chmod +x .git/hooks/pre-receive) &&
git clone parent child &&
(cd child && (cd child &&
echo two >foo && git commit -a -m two && git pull .. master
test_must_fail git push && test_must_fail git push &&
test $(git rev-parse master) != \ test $(git rev-parse master) != \
$(git rev-parse remotes/origin/master)) $(git rev-parse remotes/origin/master))
@ -487,7 +479,7 @@ test_expect_success 'push does not update local refs on failure' '


test_expect_success 'allow deleting an invalid remote ref' ' test_expect_success 'allow deleting an invalid remote ref' '


pwd && mk_test heads/master &&
rm -f testrepo/.git/objects/??/* && rm -f testrepo/.git/objects/??/* &&
git push testrepo :refs/heads/master && git push testrepo :refs/heads/master &&
(cd testrepo && test_must_fail git rev-parse --verify refs/heads/master) (cd testrepo && test_must_fail git rev-parse --verify refs/heads/master)