From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id YPPVOgj1HV/yXQAA0tVLHw (envelope-from ) for ; Sun, 26 Jul 2020 21:26:32 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id ZqeCNgj1HV8MIgAAbx9fmQ (envelope-from ) for ; Sun, 26 Jul 2020 21:26:32 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (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 39A219403AA for ; Sun, 26 Jul 2020 21:26:32 +0000 (UTC) Received: from [144.217.243.247] (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 8FBDD20233; Sun, 26 Jul 2020 17:26:17 -0400 (EDT) Received: from mail.hostpark.net (mail.hostpark.net [212.243.197.30]) by mail.notmuchmail.org (Postfix) with ESMTPS id AABE61FA22 for ; Sun, 26 Jul 2020 17:26:13 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id 89933165E2 for ; Sun, 26 Jul 2020 23:26:10 +0200 (CEST) X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail0.hostpark.net [127.0.0.1]) (amavisd-new, port 10124) with ESMTP id GnEMp1E_USs7 for ; Sun, 26 Jul 2020 23:26:10 +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 54188165E8 for ; Sun, 26 Jul 2020 23:26:10 +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: Sun, 26 Jul 2020 23:26:09 +0200 Message-Id: <20200726212610.15893-3-jonas@bernoul.li> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200726212610.15893-1-jonas@bernoul.li> References: <20200724180924.21944-1-jonas@bernoul.li> <20200726212610.15893-1-jonas@bernoul.li> MIME-Version: 1.0 Message-ID-Hash: B7KH2H7VSRD3OJMMWMU6KWARK5EQOBMN X-Message-ID-Hash: B7KH2H7VSRD3OJMMWMU6KWARK5EQOBMN 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 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Spam-Score: 0.03 X-TUID: 3we4sPin9kEM 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