emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 0155bd0: Fix bug in how ERT invokes its debugger.


From: Philipp Stephani
Subject: master 0155bd0: Fix bug in how ERT invokes its debugger.
Date: Mon, 7 Dec 2020 15:46:18 -0500 (EST)

branch: master
commit 0155bd0fdb166c97a2ce76cc5bc64fd195a676d3
Author: Philipp Stephani <phst@google.com>
Commit: Philipp Stephani <phst@google.com>

    Fix bug in how ERT invokes its debugger.
    
    The debugger needs to receive a list of the error symbol and data;
    cf. the documentation of the `debugger' variable.  This bug manifested
    itself in ERT forms such as (should (integerp (ert-fail "Boo"))),
    which resulted in an incorrect condition object.  Note that forms such
    as (should (ert-fail "Boo")) weren't affected because they wouldn't
    use the `ert--should-signal-hook'.
    
    * test/emacs-lisp/ert.el (ert--should-signal-hook): Call debugger with
    the right arguments.
    
    * test/lisp/emacs-lisp/ert-tests.el (ert-test-fail-inside-should): Add
    unit test.
---
 lisp/emacs-lisp/ert.el            |  2 +-
 test/lisp/emacs-lisp/ert-tests.el | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index 5f29c26..25237fe 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -274,7 +274,7 @@ DATA is displayed to the user and should state the reason 
for skipping."
 It should only be stopped when ran from inside ert--run-test-internal."
   (when (and (not (symbolp debugger))   ; only run on anonymous debugger
              (memq error-symbol '(ert-test-failed ert-test-skipped)))
-    (funcall debugger 'error data)))
+    (funcall debugger 'error (list error-symbol data))))
 
 (defun ert--special-operator-p (thing)
   "Return non-nil if THING is a symbol naming a special operator."
diff --git a/test/lisp/emacs-lisp/ert-tests.el 
b/test/lisp/emacs-lisp/ert-tests.el
index 1f54c8d..a0c56be 100644
--- a/test/lisp/emacs-lisp/ert-tests.el
+++ b/test/lisp/emacs-lisp/ert-tests.el
@@ -806,6 +806,16 @@ This macro is used to test if macroexpansion in `should' 
works."
   :expected-result :failed  ;; FIXME!  Bug#11218
   (should-not (with-demoted-errors (error "Foo"))))
 
+(ert-deftest ert-test-fail-inside-should ()
+  "Check that `ert-fail' inside `should' works correctly."
+  (let ((result (ert-run-test
+                 (make-ert-test
+                  :name 'test-1
+                  :body (lambda () (should (integerp (ert-fail "Boo"))))))))
+    (should (ert-test-failed-p result))
+    (should (equal (ert-test-failed-condition result)
+                   '(ert-test-failed ("Boo"))))))
+
 
 (provide 'ert-tests)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]