mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-22 17:34:54 +01:00
test: Deal with Emacs 27 switching to lexical scope by default
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. The numeric values of these variables get incremented by functions that we add to hooks that are run by many tests, not just the tests where we actually inspect the value and therefore take care to let- bind the values to 0 before we begin. The global values therefore have to be numeric values as well. I have chosen -100 instead of 0 as the default in case someone writes a test that inspects the value but forgets to let-bind the value. I hope that the unusual negative value that one is going to see in such a case will help debugging the issue.
This commit is contained in:
parent
a2e9eaadaf
commit
d5d8846c32
1 changed files with 12 additions and 0 deletions
|
@ -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,12 @@ nothing."
|
|||
(add-hook-counter 'notmuch-hello-mode-hook)
|
||||
(add-hook-counter 'notmuch-hello-refresh-hook)
|
||||
|
||||
(defvar notmuch-hello-mode-hook-counter -100
|
||||
"Tests that care about this counter must let-bind it to 0.")
|
||||
|
||||
(defvar notmuch-hello-refresh-hook-counter -100
|
||||
"Tests that care about this counter must let-bind it to 0.")
|
||||
|
||||
(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)))
|
||||
|
|
Loading…
Reference in a new issue