push test: rely on &&-chaining instead of 'if bad; then echo Oops; fi'
authorJonathan Nieder <jrnieder@gmail.com>
Mon, 18 Mar 2013 23:14:26 +0000 (16:14 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 Mar 2013 18:07:27 +0000 (11:07 -0700)
When it is unclear which command from a test has failed, usual
practice these days is to debug by running the test again with "sh -x"
instead of relying on debugging 'echo' statements.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t5516-fetch-push.sh
index 2f1255d467192eb4e54dd065bf9ce956b842eab9..0695d570f217e3ef94490470f61bc45d539cccee 100755 (executable)
@@ -22,10 +22,8 @@ mk_test () {
        (
                for ref in "$@"
                do
-                       git push testrepo $the_first_commit:refs/$ref || {
-                               echo "Oops, push refs/$ref failure"
-                               exit 1
-                       }
+                       git push testrepo $the_first_commit:refs/$ref ||
+                       exit
                done &&
                cd testrepo &&
                for ref in "$@"
@@ -328,13 +326,8 @@ test_expect_success 'push with weak ambiguity (2)' '
 test_expect_success 'push with ambiguity' '
 
        mk_test heads/frotz tags/frotz &&
-       if git push testrepo master:frotz
-       then
-               echo "Oops, should have failed"
-               false
-       else
-               check_push_result $the_first_commit heads/frotz tags/frotz
-       fi
+       test_must_fail git push testrepo master:frotz &&
+       check_push_result $the_first_commit heads/frotz tags/frotz
 
 '