Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 1431F431FDE for ; Tue, 24 Jan 2012 08:14:31 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P0jThhjnY9bW for ; Tue, 24 Jan 2012 08:14:30 -0800 (PST) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 372DB431FD2 for ; Tue, 24 Jan 2012 08:14:30 -0800 (PST) Received: by mail-wi0-f181.google.com with SMTP id hi8so1696072wib.26 for ; Tue, 24 Jan 2012 08:14:29 -0800 (PST) MIME-Version: 1.0 Received: by 10.180.106.38 with SMTP id gr6mr4773279wib.0.1327421669918; Tue, 24 Jan 2012 08:14:29 -0800 (PST) Received: from hotblack-desiato.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25]) by mx.google.com with ESMTPS id t6sm19574812wid.1.2012.01.24.08.14.28 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 Jan 2012 08:14:28 -0800 (PST) Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) id 0DE409FD48; Tue, 24 Jan 2012 16:14:27 +0000 (GMT) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH 3/4 v43] test: Add more helpers for emacs tests. Date: Tue, 24 Jan 2012 16:14:06 +0000 Message-Id: <1327421647-30405-4-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.8.3 In-Reply-To: <1327421647-30405-1-git-send-email-dme@dme.org> References: <1326804748-8989-2-git-send-email-dme@dme.org> <1327421647-30405-1-git-send-email-dme@dme.org> X-Gm-Message-State: ALoCoQk3igtyv0ET+VFgvuad5NPAYXOoO38vhXvzo0CUupoyA23p6qvVPYS9l4t1pjwEvucBMf// X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Jan 2012 16:14:31 -0000 --- test/test-lib.el | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) diff --git a/test/test-lib.el b/test/test-lib.el index 96752f0..bc75f06 100644 --- a/test/test-lib.el +++ b/test/test-lib.el @@ -20,6 +20,8 @@ ;; ;; Authors: Dmitry Kurochkin +(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))))) -- 1.7.8.3