@matheusbsbs / matheus-bagliano / commits / b2dc968e60
Fork 0

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>

Jeff King committed Nov 7, 2008 at 17:20 UTC b2dc968e60c94189805228f5d99786bd50189583
1 file changed +21 -29
t/t5516-fetch-push.sh
+21 -29
@@ -39,6 +39,11 @@ mk_test () {
39 )
40 }
41
42 +mk_child() {
43 + rm -rf "$1" &&
44 + git clone testrepo "$1"
45 +}
46 +
47 check_push_result () {
48 (
49 cd testrepo &&
@@ -425,13 +430,10 @@ test_expect_success 'push with dry-run' '
430
431 test_expect_success 'push updates local refs' '
432
428 - rm -rf parent child &&
429 - mkdir parent &&
430 - (cd parent && git init &&
431 - echo one >foo && git add foo && git commit -m one) &&
432 - git clone parent child &&
433 + mk_test heads/master &&
434 + mk_child child &&
435 (cd child &&
434 - echo two >foo && git commit -a -m two &&
436 + git pull .. master &&
437 git push &&
438 test $(git rev-parse master) = $(git rev-parse remotes/origin/master))
439
@@ -439,15 +441,10 @@ test_expect_success 'push updates local refs' '
441
442 test_expect_success 'push updates up-to-date local refs' '
443
442 - rm -rf parent child &&
443 - mkdir parent &&
444 - (cd parent && git init &&
445 - echo one >foo && git add foo && git commit -m one) &&
446 - git clone parent child1 &&
447 - git clone parent child2 &&
448 - (cd child1 &&
449 - echo two >foo && git commit -a -m two &&
450 - git push) &&
444 + mk_test heads/master &&
445 + mk_child child1 &&
446 + mk_child child2 &&
447 + (cd child1 && git pull .. master && git push) &&
448 (cd child2 &&
449 git pull ../child1 master &&
450 git push &&
@@ -457,11 +454,8 @@ test_expect_success 'push updates up-to-date local refs' '
454
455 test_expect_success 'push preserves up-to-date packed refs' '
456
460 - rm -rf parent child &&
461 - mkdir parent &&
462 - (cd parent && git init &&
463 - echo one >foo && git add foo && git commit -m one) &&
464 - git clone parent child &&
457 + mk_test heads/master &&
458 + mk_child child &&
459 (cd child &&
460 git push &&
461 ! test -f .git/refs/remotes/origin/master)
@@ -470,15 +464,13 @@ test_expect_success 'push preserves up-to-date packed refs' '
464
465 test_expect_success 'push does not update local refs on failure' '
466
473 - rm -rf parent child &&
474 - mkdir parent &&
475 - (cd parent && git init &&
476 - echo one >foo && git add foo && git commit -m one &&
477 - echo exit 1 >.git/hooks/pre-receive &&
478 - chmod +x .git/hooks/pre-receive) &&
479 - git clone parent child &&
467 + mk_test heads/master &&
468 + mk_child child &&
469 + mkdir testrepo/.git/hooks &&
470 + echo exit 1 >testrepo/.git/hooks/pre-receive &&
471 + chmod +x testrepo/.git/hooks/pre-receive &&
472 (cd child &&
481 - echo two >foo && git commit -a -m two &&
473 + git pull .. master
474 test_must_fail git push &&
475 test $(git rev-parse master) != \
476 $(git rev-parse remotes/origin/master))
@@ -487,7 +479,7 @@ test_expect_success 'push does not update local refs on failure' '
479
480 test_expect_success 'allow deleting an invalid remote ref' '
481
490 - pwd &&
482 + mk_test heads/master &&
483 rm -f testrepo/.git/objects/??/* &&
484 git push testrepo :refs/heads/master &&
485 (cd testrepo && test_must_fail git rev-parse --verify refs/heads/master)