[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master d20a4a5: Improve failure reporting in test/lisp/electric-tests.el
From: |
Alan Mackenzie |
Subject: |
master d20a4a5: Improve failure reporting in test/lisp/electric-tests.el |
Date: |
Wed, 24 Mar 2021 15:04:32 -0400 (EDT) |
branch: master
commit d20a4a50d377f1c48299dc18008ab1a106f4f58e
Author: Alan Mackenzie <acm@muc.de>
Commit: Alan Mackenzie <acm@muc.de>
Improve failure reporting in test/lisp/electric-tests.el
In particular, on a failure, output the test's doc string to
electric-tests.log, along with all the other failure information.
Fixes bug #47320.
* electric-tests.el (electric-pair-test-for) New parameter doc-string. On a
test failure, output the doc-string parameter with message.
(electric-pair-define-test-form): Set the new variable doc-string to the
generated doc string, and pass this as argument to both ert-deftest and
electric-pair-test-for.
---
test/lisp/electric-tests.el | 34 +++++++++++++++++++++++-----------
1 file changed, 23 insertions(+), 11 deletions(-)
diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el
index 62a42b7..44b3d8b 100644
--- a/test/lisp/electric-tests.el
+++ b/test/lisp/electric-tests.el
@@ -50,7 +50,8 @@
`(call-with-saved-electric-modes #'(lambda () ,@body)))
(defun electric-pair-test-for (fixture where char expected-string
- expected-point mode bindings fixture-fn)
+ expected-point mode bindings
+ fixture-fn &optional doc-string)
(with-temp-buffer
(funcall mode)
(insert fixture)
@@ -63,6 +64,14 @@
(mapcar #'car bindings)
(mapcar #'cdr bindings)
(call-interactively (key-binding `[,last-command-event])))))
+ (when
+ (and doc-string
+ (not
+ (and
+ (equal (buffer-substring-no-properties (point-min) (point-max))
+ expected-string)
+ (equal (point) expected-point))))
+ (message "\n%s\n" doc-string))
(should (equal (buffer-substring-no-properties (point-min) (point-max))
expected-string))
(should (equal (point)
@@ -109,14 +118,9 @@
(fixture (format "%s%s%s" prefix fixture suffix))
(expected-string (format "%s%s%s" prefix expected-string suffix))
(expected-point (+ (length prefix) expected-point))
- (pos (+ (length prefix) pos)))
- `(ert-deftest ,(intern (format "electric-pair-%s-at-point-%s-in-%s%s"
- name
- (1+ pos)
- mode
- extra-desc))
- ()
- ,(format "Electricity test in a `%s' buffer.\n
+ (pos (+ (length prefix) pos))
+ (doc-string
+ (format "Electricity test in a `%s' buffer.\n
Start with point at %d in a %d-char-long buffer
like this one:
@@ -143,7 +147,14 @@ The buffer's contents should %s:
char
(if (string= fixture expected-string) "stay" "become")
(replace-regexp-in-string "\n" "\\\\n" expected-string)
- expected-point)
+ expected-point)))
+ `(ert-deftest ,(intern (format "electric-pair-%s-at-point-%s-in-%s%s"
+ name
+ (1+ pos)
+ mode
+ extra-desc))
+ ()
+ ,doc-string
(electric-pair-test-for ,fixture
,(1+ pos)
,char
@@ -151,7 +162,8 @@ The buffer's contents should %s:
,expected-point
',mode
,bindings
- ,fixture-fn)))))
+ ,fixture-fn
+ ,doc-string)))))
(cl-defmacro define-electric-pair-test
(name fixture
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master d20a4a5: Improve failure reporting in test/lisp/electric-tests.el,
Alan Mackenzie <=