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

[PATCH] cogito tutorial-script - more testsuite improvements

From
PRPavel Roskin <proski@gnu.org>
Date
Nov 14, 2005, 23:14 UTC
Message-ID
<1132010085.24084.32.camel@dv>

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
Message 1 of 1 in “cogito tutorial-script - more testsuite improvements”
  1. cogito tutorial-script - more testsuite improvementsPavel Roskin, Nov 14, 2005

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.