aboutsummaryrefslogtreecommitdiffhomepage
path: root/generic/pg-autotest.el
diff options
context:
space:
mode:
authorGravatar David Aspinall <da@inf.ed.ac.uk>2011-01-26 17:43:12 +0000
committerGravatar David Aspinall <da@inf.ed.ac.uk>2011-01-26 17:43:12 +0000
commitce33cfa2f79fb1af84ebadec16bac2a53f38d6c9 (patch)
tree90f6295ee16537c8f98209a9ff4581611a64e44f /generic/pg-autotest.el
parent4d923ab403743c3c091ba3feec10757fae3b2fec (diff)
Add pg-autotest-start to allow debug startup, which doesn't catch errors.
Diffstat (limited to 'generic/pg-autotest.el')
-rw-r--r--generic/pg-autotest.el74
1 files changed, 40 insertions, 34 deletions
diff --git a/generic/pg-autotest.el b/generic/pg-autotest.el
index 22dead4e..8dfee09d 100644
--- a/generic/pg-autotest.el
+++ b/generic/pg-autotest.el
@@ -24,9 +24,6 @@
(require 'proof-shell)
(require 'proof-utils)
-(defconst pg-autotest-debug nil) ; run in debug mode or not
-
-
;;; Code:
(defvar pg-autotest-success t
@@ -35,15 +32,6 @@
(defvar pg-autotest-log t
"Value for 'standard-output' during tests.")
-(when pg-autotest-debug
- (setq debug-on-error t) ;; enable in case a test goes wrong
- (setq proof-general-debug t) ;; debug messages from PG
-
- (defadvice proof-debug (before proof-debug-to-log (msg &rest args))
- "Output the debug message to the test log."
- (apply 'pg-autotest-message msg args))
- (ad-activate 'proof-debug))
-
;;; Some utilities
(defun pg-autotest-find-file (file)
@@ -67,30 +55,34 @@
;;; Invoke a test
+(defmacro pg-autotest-apply (fn &rest args)
+ `(let ((scaffoldfn
+ (intern (concat "pg-autotest-"
+ (symbol-name (quote ,fn))))))
+ (if (fboundp scaffoldfn)
+ (apply scaffoldfn (list ,@args))
+ (pg-autotest-message
+ "TEST: %s"
+ (prin1-to-string (cons (quote ,fn)
+ (quote ,args))))
+ (apply (intern (concat "pg-autotest-test-"
+ (symbol-name (quote ,fn))))
+ (list ,@args)))))
+
(defmacro pg-autotest (fn &rest args)
- `(unwind-protect
- (progn
- (setq standard-output pg-autotest-log)
- (condition-case err
- (let ((scaffoldfn
- (intern (concat "pg-autotest-"
- (symbol-name (quote ,fn))))))
- (if (fboundp scaffoldfn)
- (apply scaffoldfn (list ,@args))
- (pg-autotest-message
- "TEST: %s"
- (prin1-to-string (cons (quote ,fn)
- (quote ,args))))
- (apply (intern (concat "pg-autotest-test-"
- (symbol-name (quote ,fn))))
- (list ,@args))))
- (error
+ `(if debug-on-error
+ (pg-autotest-apply ,fn ,@args)
+ (unwind-protect
(progn
- (setq pg-autotest-success nil)
- (pg-autotest-message
- "ERROR %s: %s" (quote ,fn) (prin1-to-string err))))))
- (setq standard-output t)))
-
+ (setq standard-output pg-autotest-log)
+ (condition-case err
+ (pg-autotest-apply ,fn ,@args)
+ (error
+ (progn
+ (setq pg-autotest-success nil)
+ (pg-autotest-message
+ "ERROR %s: %s" (quote ,fn) (prin1-to-string err))))))
+ (setq standard-output t))))
;;; Test output and timing
@@ -131,6 +123,20 @@
(if clockname (symbol-name clockname)
"this test"))))
+
+;;; Start up and exit
+
+(defun pg-autotest-start (&optional debug)
+ "Start a session of tests. DEBUG indicates to capture debug output."
+ (when debug
+ (setq debug-on-error t) ; enable in case a test goes wrong
+ (setq proof-general-debug t) ; debug messages from PG
+
+ (defadvice proof-debug (before proof-debug-to-log (msg &rest args))
+ "Output the debug message to the test log."
+ (apply 'pg-autotest-message msg args))
+ (ad-activate 'proof-debug)))
+
(defun pg-autotest-exit ()
"Exit Emacs returning Unix success 0 if all tests succeeded."
(pg-autotest-message (concat "\nTests completed "