From 8236737a8df7653533c2ea378cb2e168fe38d86e Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Fri, 9 May 2014 01:20:07 +0100 Subject: [PATCH] [PATCH v4 1/2] test: make test_emacs call post-command-hook --- 39/64f4ef474e44ce5abf8e20f5e1ec41cf9b20fc | 131 ++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 39/64f4ef474e44ce5abf8e20f5e1ec41cf9b20fc diff --git a/39/64f4ef474e44ce5abf8e20f5e1ec41cf9b20fc b/39/64f4ef474e44ce5abf8e20f5e1ec41cf9b20fc new file mode 100644 index 000000000..ea08c37d2 --- /dev/null +++ b/39/64f4ef474e44ce5abf8e20f5e1ec41cf9b20fc @@ -0,0 +1,131 @@ +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 1BC7D431FCB + for ; Thu, 8 May 2014 17:20:26 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + 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 lQykC0YdfTig for ; + Thu, 8 May 2014 17:20:22 -0700 (PDT) +Received: from mail-we0-f173.google.com (mail-we0-f173.google.com + [74.125.82.173]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 4201F431FBF + for ; Thu, 8 May 2014 17:20:22 -0700 (PDT) +Received: by mail-we0-f173.google.com with SMTP id u57so3224423wes.18 + for ; Thu, 08 May 2014 17:20:21 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:in-reply-to:references; + bh=K2IF/+hfJBbwhIAhHdEDx1DdAEOD0dVeR/XD/W1urMQ=; + b=JP6GgOiAxOcDkKS8I+MwRxi7ZQ9kKUacUqdCHorjvrVOV7ITf3LCYwY2MaKuog9zL6 + Oleun60MHRoSQoie4odHHwWnUouGWbTf1e6l8k6XvGazkYbTanYx1w5qNZLF2DYgAA4J + ExD7Fyv5LZWn0jDg6+OoM3S/YsiXseaxYnjaAlhMCaDqFgndowAXfX1IigJWbNOQnqbu + k8sOIBdHL202G94k0cTRYrXbUSxH0QJlhn6Pv/BnfRSv3IsG8ZO5H7vJcJZwLMduHUfe + ognFOglKzAwUKPT0HeEMXkGsvQTycidKJDay+qpVyccF8N10z0cWq0OVT/gKlfXHhEgp + sgOA== +X-Received: by 10.194.91.175 with SMTP id cf15mr5628813wjb.5.1399594821162; + Thu, 08 May 2014 17:20:21 -0700 (PDT) +Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) + by mx.google.com with ESMTPSA id h19sm2023334wiw.17.2014.05.08.17.20.20 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Thu, 08 May 2014 17:20:20 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH v4 1/2] test: make test_emacs call post-command-hook +Date: Fri, 9 May 2014 01:20:07 +0100 +Message-Id: <1399594808-2815-2-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: <1399594808-2815-1-git-send-email-markwalters1009@gmail.com> +References: <1399594808-2815-1-git-send-email-markwalters1009@gmail.com> +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: Fri, 09 May 2014 00:20:26 -0000 + +From: David Bremner + +The unread/read changes will use the post-command-hook. test_emacs +does not call the post-command-hook. This adds a notmuch-test-progn +which takes a list of commands as argument and executes them in turn +but runs the post-command-hook after each one. + +The caller can batch operations (ie to stop post-command-hook from +being interleaved) by wrapping the batch of operations inside a progn. + +We also explicitly run the post-command-hook before getting the output +from a test; this makes sense as this will be a place the user would +be seeing the information. +--- + test/test-lib.el | 11 +++++++++++ + test/test-lib.sh | 2 +- + 2 files changed, 12 insertions(+), 1 deletion(-) + +diff --git a/test/test-lib.el b/test/test-lib.el +index 437f83f..36afe63 100644 +--- a/test/test-lib.el ++++ b/test/test-lib.el +@@ -52,11 +52,13 @@ (defun notmuch-test-wait () + + (defun test-output (&optional filename) + "Save current buffer to file FILENAME. Default FILENAME is OUTPUT." ++ (notmuch-post-command) + (write-region (point-min) (point-max) (or filename "OUTPUT"))) + + (defun test-visible-output (&optional filename) + "Save visible text in current buffer to file FILENAME. Default + FILENAME is OUTPUT." ++ (notmuch-post-command) + (let ((text (visible-buffer-string))) + (with-temp-file (or filename "OUTPUT") (insert text)))) + +@@ -166,6 +168,15 @@ (defun notmuch-test-expect-equal (output expected) + (t + (notmuch-test-report-unexpected output expected))))) + ++(defun notmuch-post-command () ++ (run-hooks 'post-command-hook)) ++ ++(defmacro notmuch-test-progn (&rest body) ++ (cons 'progn ++ (mapcar ++ (lambda (x) `(prog1 ,x (notmuch-post-command))) ++ body))) ++ + ;; For historical reasons, we hide deleted tags by default in the test + ;; suite + (setq notmuch-tag-deleted-formats +diff --git a/test/test-lib.sh b/test/test-lib.sh +index 8697d6a..e6403e5 100644 +--- a/test/test-lib.sh ++++ b/test/test-lib.sh +@@ -1139,7 +1139,7 @@ test_emacs () { + rm -f OUTPUT + touch OUTPUT + +- ${TEST_EMACSCLIENT} --socket-name="$EMACS_SERVER" --eval "(progn $@)" ++ ${TEST_EMACSCLIENT} --socket-name="$EMACS_SERVER" --eval "(notmuch-test-progn $@)" + } + + test_python() { +-- +1.7.10.4 + -- 2.26.2