From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id DcERM34lG18VZwAA0tVLHw (envelope-from ) for ; Fri, 24 Jul 2020 18:16:30 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id yB6QLn4lG1/7SQAAB5/wlQ (envelope-from ) for ; Fri, 24 Jul 2020 18:16:30 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 4877A94004E for ; Fri, 24 Jul 2020 18:16:30 +0000 (UTC) Received: from [144.217.243.247] (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 8D69527B51; Fri, 24 Jul 2020 14:16:11 -0400 (EDT) Received: from mail.hostpark.net (mail.hostpark.net [212.243.197.30]) by mail.notmuchmail.org (Postfix) with ESMTPS id 19C0A27B0A for ; Fri, 24 Jul 2020 14:16:01 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id F421C160DD for ; Fri, 24 Jul 2020 20:09:24 +0200 (CEST) X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail1.hostpark.net [127.0.0.1]) (amavisd-new, port 10124) with ESMTP id 8sjk5WTeDtYm for ; Fri, 24 Jul 2020 20:09:24 +0200 (CEST) Received: from customer (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.hostpark.net (Postfix) with ESMTPSA id C0E9C160DE for ; Fri, 24 Jul 2020 20:09:24 +0200 (CEST) From: Jonas Bernoulli To: notmuch@notmuchmail.org Subject: [PATCH 2/3] test: Deal with Emacs 27 switching to lexical scope by default Date: Fri, 24 Jul 2020 20:09:23 +0200 Message-Id: <20200724180924.21944-3-jonas@bernoul.li> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200724180924.21944-1-jonas@bernoul.li> References: <20200724180924.21944-1-jonas@bernoul.li> MIME-Version: 1.0 Message-ID-Hash: B7Z3C2CGFERWKGMYR4THQOM7SFOGWTGD X-Message-ID-Hash: B7Z3C2CGFERWKGMYR4THQOM7SFOGWTGD X-MailFrom: jonas@bernoul.li X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Spam-Score: 1.53 X-TUID: DGd/RFbE6kyw Starting with Emacs 27 undeclared variables in evaluated interactive code uses lexical scope. This includes code passed with '--eval' as we do in the Emacs tests, which also happen to assume dynamic scope. This can affect variables defined by libraries that we use. We let- bind such variables to change the behavior of functions which we then call with these bindings in effect. If these libraries are not loaded beforehand, then the bindings are lexical and fail to have the effect we intended. At this time only 'smtpmail' has to be loaded explicitly (for the variables let-bound in emacs_deliver_message and emacs_fcc_message). 'message' doesn't have to be loaded explicitly, because loading 'notmuch' (in 'run_emacs') already takes care of that, indirectly. Our own testing-only variables also have to be declared explicitly. We should have done that anyway, but because of how and where these variables are used it was very easy to overlook that (i.e. it isn't something the byte-compiler ever looks at). Not so in Emacs 27 anymore; here this oversight caused four tests to fail. --- test/test-lib.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/test-lib.el b/test/test-lib.el index b47b388e..579a20d5 100644 --- a/test/test-lib.el +++ b/test/test-lib.el @@ -22,6 +22,12 @@ (require 'cl-lib) +;; Ensure that the dynamic variables that are defined by this library +;; are defined by the time that we let-bind them. This is needed +;; because starting with Emacs 27 undeclared variables in evaluated +;; interactive code (such as our tests) use lexical scope. +(require 'smtpmail) + ;; `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 @@ -113,6 +119,9 @@ (defun add-hook-counter (hook) (add-hook-counter 'notmuch-hello-mode-hook) (add-hook-counter 'notmuch-hello-refresh-hook) +(defvar notmuch-hello-mode-hook-counter -100) +(defvar notmuch-hello-refresh-hook-counter -100) + (defadvice notmuch-search-process-filter (around pessimal activate disable) "Feed notmuch-search-process-filter one character at a time." (let ((string (ad-get-arg 1))) -- 2.26.0