DORMANTno replies

[PATCH] cogito tutorial-script - more testsuite improvements

From: Pavel Roskin <hidden>
Date: 2016-06-15 22:42:11
Subsystem: documentation, the rest · Maintainers: Jonathan Corbet, Linus Torvalds

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 <redacted>
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help