From c38c94c6b29d53f4d4005f3a958879dc513b9500 Mon Sep 17 00:00:00 2001
From: "Robert P. Goldman" <rpgoldman@real-time.com>
Date: Thu, 4 Feb 2010 19:16:22 -0500
Subject: [PATCH] Signed-off-by: Francois-Rene Rideau <fare@tunes.org>

---
 test/run-tests.sh        | 40 +++++++++++++++++++++++++++++++++-------
 test/script-support.lisp | 12 +++++++++++-
 2 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/test/run-tests.sh b/test/run-tests.sh
index 1cb499ce..50df5aaf 100755
--- a/test/run-tests.sh
+++ b/test/run-tests.sh
@@ -6,15 +6,29 @@
 # - quit with exit status >0 if an unhandled error occurs
 
 export CL_SOURCE_REGISTRY="$PWD"
+export ASDF_DEBUG=
+
+while getopts "duh" OPTION
+do
+    case OPTION in
+        d)
+            ASDF_DEBUG = 1
+            ;;
+        u)
+            usage
+            exit 1
+            ;;
+        h)
+            usage
+            exit 1
+            ;;
+    esac
+done
+shift $(($OPTIND - 1))
 
 if [ x"$1" = "xhelp" ]; then
-    echo "$0 [lisp invocation] [scripts-regex]"
-    echo " - read lisp forms one at a time from matching scripts"
-    echo " - quit with exit status 0 on getting eof"
-    echo " - quit with exit status >0 if an unhandled error occurs"
-    echo " you need to supply the .script in the second argument"
-    echo " lisps include sbcl, clisp, allegro and allegromodern"
-    exit -1
+    usage
+    exit 1
 fi
 
 if [ -z "$2" ]; then
@@ -25,6 +39,18 @@ fi
 
 sok=1
 
+usage () {
+    echo "$0 [lisp invocation] [scripts-regex]"
+    echo " - read lisp forms one at a time from matching scripts"
+    echo " - quit with exit status 0 on getting eof"
+    echo " - quit with exit status >0 if an unhandled error occurs"
+    echo " you need to supply the .script in the second argument"
+    echo " lisps include sbcl, clisp, allegro and allegromodern"
+    echo "OPTIONS:"
+    echo "    -d -- debug mode"
+    echo "    -u -h -- show this message."
+}
+
 do_tests() {
   command=$1 eval=$2 fasl_ext=$3
   rm -f *.$fasl_ext ~/.cache/common-lisp/"`pwd`"/*.$fasl_ext || true
diff --git a/test/script-support.lisp b/test/script-support.lisp
index defb7e37..c0c23f5f 100644
--- a/test/script-support.lisp
+++ b/test/script-support.lisp
@@ -24,13 +24,23 @@
   (ccl::quit return)
   #+sbcl
   (sb-ext:quit :unix-status return)
-
   (error "Don't know how to quit Lisp; wanting to use exit code ~a" return))
 
+
+
+(defparameter *asdf-test-debug*
+              (test-getenv "ASDF_DEBUG")
+  "Global variable initialized from ASDF_DEBUG environment variable.
+Controls whether errors are muffled and dumped to the shell.")
+
 (defmacro quit-on-error (&body body)
   `(call-quitting-on-error (lambda () ,@body)))
 
 (defun call-quitting-on-error (thunk)
+  "Unless the global *asdf-test-debug* is true,
+write a message and exit on an error.  If
+*asdf-test-debug* is true, enter the debugger
+as normal."
   (handler-case
       (progn (funcall thunk)
              (leave-lisp "~&Script succeeded~%" 0))
-- 
GitLab