]> git.notmuchmail.org Git - notmuch/commit
test: Deal with Emacs 27 switching to lexical scope by default
authorJonas Bernoulli <jonas@bernoul.li>
Mon, 27 Jul 2020 15:25:01 +0000 (17:25 +0200)
committerDavid Bremner <david@tethera.net>
Tue, 28 Jul 2020 11:39:44 +0000 (08:39 -0300)
commitd5d8846c3286ec681c3d46b3fe30d50254224208
treeb88bbd49a475adb42ff96a8b4fea5ecf1c1b5deb
parenta2e9eaadaf2728bb09064b274744f930581e443e
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.
test/test-lib.el