aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar David Edmondson <dme@dme.org>2012-01-24 16:14:06 +0000
committerGravatar David Bremner <bremner@debian.org>2012-01-25 07:26:47 -0400
commitf92d7dee8fcf399bda361df82187523598bb09b4 (patch)
tree8a9cbb62375f8a9cabe8b9889521373b185e5d2f /test
parent260975e8aff635b6b99db835ee8d40ec33ee916c (diff)
test: Add more helpers for emacs tests.
Diffstat (limited to 'test')
-rw-r--r--test/test-lib.el26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/test-lib.el b/test/test-lib.el
index 96752f0b..bc75f06e 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -20,6 +20,8 @@
;;
;; Authors: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
+(require 'cl) ;; This code is generally used uncompiled.
+
;; `read-file-name' by default uses `completing-read' function to read
;; user input. It does not respect `standard-input' variable which we
;; use in tests to provide user input. So replace it with a plain
@@ -92,3 +94,27 @@ nothing."
result
(prin1-to-string result)))
(test-output))))
+
+(defun notmuch-test-report-unexpected (output expected)
+ "Report that the OUTPUT does not match the EXPECTED result."
+ (concat "Expect:\t" (prin1-to-string expected) "\n"
+ "Output:\t" (prin1-to-string output) "\n"))
+
+(defun notmuch-test-expect-equal (output expected)
+ "Compare OUTPUT with EXPECTED. Report any discrepencies."
+ (if (equal output expected)
+ t
+ (cond
+ ((and (listp output)
+ (listp expected))
+ ;; Reporting the difference between two lists is done by
+ ;; reporting differing elements of OUTPUT and EXPECTED
+ ;; pairwise. This is expected to make analysis of failures
+ ;; simpler.
+ (apply #'concat (loop for o in output
+ for e in expected
+ if (not (equal o e))
+ collect (notmuch-test-report-unexpected o e))))
+
+ (t
+ (notmuch-test-report-unexpected output expected)))))