On Mon, 23 Jan 2012 18:05:46 +0000, David Edmondson <d...@dme.org> wrote: > --- > > Split out from the tests and re-factored. > > test/test-lib.el | 22 ++++++++++++++++++++++ > 1 files changed, 22 insertions(+), 0 deletions(-) > > diff --git a/test/test-lib.el b/test/test-lib.el > index 96752f0..c4a5db4 100644 > --- a/test/test-lib.el > +++ b/test/test-lib.el > @@ -20,6 +20,8 @@ > ;; > ;; Authors: Dmitry Kurochkin <dmitry.kuroch...@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,23 @@ 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-compare (output expected) > + "Compare OUTPUT with EXPECTED. Report any discrepencies." > + (if (equal output expected) > + t > + (cond > + ((and (listp output) > + (listp expected)) > + (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)))))
As we discussed it on IRC, I have two comments on the above code: 1. rename notmuch-test-compare to notmuch-test-expect-equal 2. move the top level equal check to the non-list branch But both of these are subjective and minor, so I leave it to David to decide whether to change or ignore them. Otherwise, the patch looks good to me. While replying to this email, I noticed a trailing whitespace. I may have missed them in other patches. David, can you please check for trailing white spaces and clean them? Regards, Dmitry > -- > 1.7.8.3 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch _______________________________________________ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch