git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] push test: rely on &&-chaining instead of 'if bad; then echo Oops; fi'

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Mar 18, 2013, 23:14 UTC
Message-ID
<20130318231426.GG5062@elie.Belkin>
In-Reply-To
<20130318231043.GD5062@elie.Belkin>

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>
---
 t/t5516-fetch-push.sh | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 2f1255d4..0695d570 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -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
 
 '
 
-- 
1.8.2.rc3
Previous: Jonathan NiederNext: Junio C Hamano
Message 5 of 11 in “push: Alias pushurl from push rewrites”
  1. push: Alias pushurl from push rewritesRob Hoelz, Mar 18, 2013
  2. Jonathan NiederMar 18, 2013
  3. 1/3 push test: use test_config when appropriateJonathan Nieder, Mar 18, 2013
  4. 2/3 push test: simplify check of push resultJonathan Nieder, Mar 18, 2013
  5. 3/3 push test: rely on &&-chaining instead of 'if bad; then echo Oops; fi'Jonathan Nieder, Mar 18, 2013
  6. Junio C HamanoMar 19, 2013
  7. Jonathan NiederMar 19, 2013
  8. Junio C HamanoMar 19, 2013
  9. Rob HoelzMar 20, 2013
  10. Junio C HamanoMar 20, 2013
  11. Rob HoelzMar 27, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.