Signed-off-by: Felipe Contreras <felipe.contre...@gmail.com>
---
 contrib/remote-helpers/test-hg.sh | 66 +++++++++++++++++++++++++++++----------
 1 file changed, 49 insertions(+), 17 deletions(-)

diff --git a/contrib/remote-helpers/test-hg.sh 
b/contrib/remote-helpers/test-hg.sh
index f594584..aeab48a 100755
--- a/contrib/remote-helpers/test-hg.sh
+++ b/contrib/remote-helpers/test-hg.sh
@@ -48,6 +48,38 @@ check_bookmark () {
        fi
 }
 
+check_push () {
+       local expected_ret=$1 ret=0 ref_ret=0 IFS=':'
+
+       shift
+       git push origin "$@" 2> error
+       ret=$?
+       cat error
+
+       while read branch kind
+       do
+               case "$kind" in
+               'new')
+                       grep "^ \* \[new branch\] *${branch} -> ${branch}$" 
error || ref_ret=1
+                       ;;
+               'non-fast-forward')
+                       grep "^ ! \[rejected\] *${branch} -> ${branch} 
(non-fast-forward)$" error || ref_ret=1
+                       ;;
+               '')
+                       grep "^   [a-f0-9]*\.\.[a-f0-9]* *${branch} -> 
${branch}$" error || ref_ret=1
+                       ;;
+               esac
+               let 'ref_ret' && echo "match for '$branch' failed" && break
+       done
+
+       if let 'expected_ret != ret || ref_ret'
+       then
+               return 1
+       fi
+
+       return 0
+}
+
 setup () {
        (
        echo "[ui]"
@@ -344,8 +376,9 @@ test_expect_success 'remote push diverged' '
        cd gitrepo &&
        echo diverge > content &&
        git commit -a -m diverged &&
-       test_expect_code 1 git push 2> error &&
-       grep "^ ! \[rejected\] *master -> master (non-fast-forward)$" error
+       check_push 1 <<-EOF
+       master:non-fast-forward
+       EOF
        ) &&
 
        check_branch hgrepo default bump
@@ -373,8 +406,9 @@ test_expect_success 'remote update bookmark diverge' '
        git checkout --quiet diverge &&
        echo diverge > content &&
        git commit -a -m diverge &&
-       test_expect_code 1 git push 2> error &&
-       grep "^ ! \[rejected\] *diverge -> diverge (non-fast-forward)$" error
+       check_push 1 <<-EOF
+       diverge:non-fast-forward
+       EOF
        ) &&
 
        check_bookmark hgrepo diverge "bump bookmark"
@@ -468,19 +502,17 @@ test_expect_success 'remote big push' '
 
        (
        cd gitrepo &&
-       test_expect_code 1 git push origin master \
-               good_bmark bad_bmark1 bad_bmark2 new_bmark \
-               branches/good_branch branches/bad_branch \
-               branches/new_branch 2> error &&
-
-       grep "^   [a-f0-9]*\.\.[a-f0-9]* *master -> master$" error &&
-       grep "^   [a-f0-9]*\.\.[a-f0-9]* *good_bmark -> good_bmark$" error &&
-       grep "^ \* \[new branch\] *new_bmark -> new_bmark$" error &&
-       grep "^ ! \[rejected\] *bad_bmark2 -> bad_bmark2 (non-fast-forward)$" 
error &&
-       grep "^ ! \[rejected\] *bad_bmark1 -> bad_bmark1 (non-fast-forward)$" 
error &&
-       grep "^   [a-f0-9]*\.\.[a-f0-9]* *branches/good_branch -> 
branches/good_branch$" error &&
-       grep "^ ! \[rejected\] *branches/bad_branch -> branches/bad_branch 
(non-fast-forward)$" error &&
-       grep "^ \* \[new branch\] *branches/new_branch -> branches/new_branch$" 
error
+
+       check_push 1 --all <<-EOF
+       master
+       good_bmark
+       branches/good_branch
+       new_bmark:new
+       branches/new_branch:new
+       bad_bmark1:non-fast-forward
+       bad_bmark2:non-fast-forward
+       branches/bad_branch:non-fast-forward
+       EOF
        ) &&
 
        check_branch hgrepo default one &&
-- 
1.8.3.rc3.312.g47657de

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to