All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Roskin <proski@gnu.org>
To: git <git@vger.kernel.org>, Petr Baudis <pasky@suse.cz>
Subject: [PATCH] cogito tutorial-script - more testsuite improvements
Date: Mon, 14 Nov 2005 18:14:45 -0500	[thread overview]
Message-ID: <1132010085.24084.32.camel@dv> (raw)

Report line in should_fail().  Require bash, since reporting calling
line is bash specific.  Set "-e" flag in the script, so that e.g.
"bash -x script.sh" cannot cancel it accidentally.  Trap and report
unexpected errors.

Signed-off-by: Pavel Roskin <proski@gnu.org>

diff --git a/Documentation/tutorial-script/script.sh b/Documentation/tutorial-script/script.sh
index 8cdfe36..bc70b77 100755
--- a/Documentation/tutorial-script/script.sh
+++ b/Documentation/tutorial-script/script.sh
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/bin/bash
 #
 # FIXME: This script has many GITisms. Some of them are unnecessary, while
 # some stem from missing Cogito features (especially no support for pushing
@@ -10,10 +10,16 @@
 # for executing this script to make sure we did not break it with any
 # Cogito changes.
 should_fail () {
-	echo "Expected failure, got success - aborting" >&2
+	echo "Expected failure, got success on line ${BASH_LINENO[0]}" \
+	     "- aborting" >&2
+	trap - exit
 	exit 1
 }
 
+# Conversely, if something fails when it shouldn't, report it and exit.
+set -e
+trap 'echo >&2 "Unexpected error $? on line $LINENO"; exit 1' exit
+
 
 ### Set up playground
 sh 0000-playground.sh
@@ -309,4 +315,5 @@ cg-add stack.h
 cg-commit -m "Merge with 0.4"
 
 # Great, we are done.
+trap - exit
 echo "Script completed successfully!"



-- 
Regards,
Pavel Roskin

                 reply	other threads:[~2005-11-14 23:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1132010085.24084.32.camel@dv \
    --to=proski@gnu.org \
    --cc=git@vger.kernel.org \
    --cc=pasky@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.