[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Add condition-case handler to ert test runner
From: |
Richard H Lee |
Subject: |
Add condition-case handler to ert test runner |
Date: |
Sun, 05 May 2013 23:02:22 +0100 |
User-agent: |
Mozilla/5.0 (Windows NT 6.0; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 |
A few weeks ago I came across a problem where ert would abort the
running of tests upon a failure if run from ielm .
The problem was caused by ielm's error handling mechanism, implemented
with condition-case's. If you execute an expression that signals an
error, ielm will catch it and display the error. The thing is that ert
uses signals to notify of the outcome of tests. So when ert signals
ert-test-failed , it gets trapped by the handler in ielm's
condition-case rather than ert's debugger which records the signal as
the test result.
My patch is to wrap a condition-case around the funcall of the actual
test in the function ert--run-test-internal with a handler that would
invoke the debugger upon any error. This condition-case would take
priority over the one in ielm.
P.S.
Would it be possible to improve emacs' documentation of condition-case?
There is only one or two sentences about the handler on the page. I had
to trawl through eval.c to figure out how to write the correct handler.
---
lisp/emacs-lisp/ert.el | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index 656cb0a..ef2185c 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -896,8 +896,10 @@ This mainly sets up debugger-related bindings."
;; and consider it in `ert--run-test-debugger'?
(debug-ignored-errors nil)
(ert--infos '()))
- (funcall (ert-test-body (ert--test-execution-info-test
- test-execution-info))))))
+ (condition-case nil
+ (funcall (ert-test-body (ert--test-execution-info-test
+ test-execution-info)))
+ ((error debug))))))
(ert-pass))
(setf (ert--test-execution-info-result test-execution-info)
(make-ert-test-passed))
--
1.7.9
- Add condition-case handler to ert test runner,
Richard H Lee <=