aboutsummaryrefslogtreecommitdiff
path: root/test/test-lib.el
AgeCommit message (Collapse)Author
2025-02-25test/emacs: add workaround for Emacs 30 pp changesDavid Bremner
This relies on the fact that setting pp-default-function has no effect for Emacs <30.
2023-08-26test: minimize impact of native compilation.David Bremner
Native compilation is kindof useless in the test suite because we throw away the cache after every subtest. The test suite could in principle share an eln cache within a given test file; for now try to minimize the amount of native-compilation. There is an intermittent bug where emacs loses track of its default-directory; I suspect (but have no proof) that bug is related to native compilation and/or race conditions. This patch seems to prevent that bug (or at least reduce its frequency).
2023-08-20test/emacs: adapt to breaking change in Gnus defaultsDavid Bremner
As of Emacs 29.1, In-Reply-To is in the default value for message-hidden-headers. We actually want to see that in the test suite, so remove it again. To future proof the tests, fix a default value for message-hidden-headers specifically for the test suite.
2022-02-25perf-test: allow running test_emacs from performance test suite.David Bremner
test_require_external prereq has to move to test-lib-common.sh, and the new shell functions print_emacs_header and time_emacs are provided. The somewhat indirect way of printing the output is to avoid the extra "" present on string values from emacsclient.
2021-09-11test/emacs: provide macro test-log-errorDavid Bremner
Because of the way emacs reports errors, a test form can crash and not change the main buffer. To work around this, capture both signalled errors and any other messages.
2021-09-08test/emacs: test for functions in notmuch-search-result-format.David Bremner
Based on the commit message in id:20210221151902.2301690-3-dme@dme.org Add the function notmuch-test-result-flags to test-lib.el to avoid repeating it in 3 T*.sh files.
2021-05-15test: add known broken tests for notuch-{before,after}-tag-hookDavid Bremner
These tests illustrate the bug reported in id:87v97ytd2s.fsf@fastmail.fm
2021-01-13emacs: make headings outline-minor-mode compatibleJonas Bernoulli
`outline-minor-mode' treats comments that begin with three or more semicolons as headings. That makes it very convenient to navigate code and to show/hide parts of a file. Elips libraries typically have four top-level sections, e.g.: ;;; notmuch.el --- run notmuch within emacs... ;;; Commentary:... ;;; Code:... ;;; notmuch.el ends here In this package many libraries lack a "Commentary:" section, which is not optimal but okay for most libraries, except major entry points. Depending on how one chooses to look at it, the "... ends here" line is not really a heading that begins a section, because it should never have a "section" body (after all it marks eof). If the file is rather short, then I left "Code:" as the only section that contains code. Otherwise I split the file into multiple sibling sections. The "Code:" section continues to contain `require' and `declare-function' forms and other such "front matter". If and only if I have split the code into multiple sections anyway, then I also added an additional section named just "_" before the `provide' form and shortly before the "...end here" line. This section could also be called "Back matter", but I feel it would be distracting to be that explicit about it. (The IMO unnecessary but unfortunately still obligatory "... ends here" line is already distracting enough as far as I am concerned.) Before this commit some libraries already uses section headings, some of them consistently. When a library already had some headings, then this commit often sticks to that style, even at the cost inconsistent styling across all libraries. A very limited number of variable and function definitions have to be moved around because they would otherwise end up in sections they do not belong into. Sections, including but not limited to their heading, can and should be further improved in the future.
2020-08-09emacs: Do not abuse advice to monkey patch while testingJonas Bernoulli
Use `cl-letf*' instead.
2020-08-09emacs: Drop old advices that were only need for Emacs 23Jonas Bernoulli
2020-08-09Fix typosJonas Bernoulli
2020-08-09emacs: Various cosmetic changesJonas Bernoulli
2020-08-09emacs: Use 'when' instead of 'if' when there is no ELSE partJonas Bernoulli
2020-08-09emacs: Use 'unless' instead of 'when' and 'not'Jonas Bernoulli
Also use 'unless' in a few cases where previously 'if' was used with 'not' but without an ELSE part.
2020-07-28test: Remove misguided emacs testing utilitiesJonas Bernoulli
The goal of this abstraction was to save space. But that failed as the result actually was that four trivial lines got replace with 15 fairly complicated lines. The opposite of what it was supposed to do. Also it made it harder to come up with the fix in the previous commit; simply grepping for the relevant symbols did not work because they get constructed at run-time instead of appearing in the source file.
2020-07-28test: Deal with Emacs 27 switching to lexical scope by defaultJonas Bernoulli
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.
2020-04-30tests/smime: Use gpgsm instead of openssl for mml creation of S/MIME msgsDaniel Kahn Gillmor
The documentation for message mode clearly states that EasyPG (which uses GnuPG) is the default and recommended way to use S/MIME with mml-secure: [0] https://www.gnu.org/software/emacs/manual/html_node/message/Using-S_002fMIME.html To ensure that this mode works, we just need to import the secret key in question into gpgsm in addition to the public key. gpgsm should be able pick the right keys+certificates to use based on To/From headers, so we don't have to specify anything manually in the #secure mml tag. The import process from the OpenSSL-preferred form (cert+secretkey) is rather ugly, because gpgsm wants to see a PKCS#12 object when importing secret keys. Note that EasyPG generates the more modern Content-Type: application/pkcs7-signature instead of application/x-pkcs7-signature for the detached signature. We are also obliged to manually set gpgsm's include-certs setting to 1 because gpgsm defaults to send "everything but the root cert". In our weird test case, the certificate we're using is self-signed, so it *is* the root cert, which means that gpgsm doesn't include it by default. Setting it to 1 forces inclusion of the signer's cert, which satisfies openssl's smime subcommand. See https://dev.gnupg.org/T4878 for more details. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2020-04-27emacs: Use `cl-lib' instead of deprecated `cl'Jonas Bernoulli
Starting with Emacs 27 the old `cl' implementation is finally considered obsolete. Previously its use was strongly discouraged at run-time but one was still allowed to use it at compile-time. For the most part the transition is very simple and boils down to adding the "cl-" prefix to some symbols. A few replacements do not follow that simple pattern; e.g. `first' is replaced with `car', even though the alias `cl-first' exists, because the latter is not idiomatic emacs-lisp. In a few cases we start using `pcase-let' or `pcase-lambda' instead of renaming e.g. `first' to `car'. That way we can remind the reader of the meaning of the various parts of the data that is being deconstructed. An obsolete `lexical-let' and a `lexical-let*' are replaced with their regular variants `let' and `let*' even though we do not at the same time enable `lexical-binding' for that file. That is the right thing to do because it does not actually make a difference in those cases whether lexical bindings are used or not, and because this should be enabled in a separate commit. We need to explicitly depend on the `cl-lib' package because Emacs 24.1 and 24.2 lack that library. When using these releases we end up using the backport from GNU Elpa. We need to explicitly require the `pcase' library because `pcase-dolist' was not autoloaded until Emacs 25.1.
2016-09-04emacs: maildir: add the actual insert codeMark Walters
With all the preparation it is now simple to add the actual insert code. Since insert can fail for many reasons we let the user decide interactively deal with it. We modify test-lib.el to set file fcc, so that all the old tests and emacs_fcc_message from test-lib.sh still work
2016-06-05Use https instead of http where possibleDaniel Kahn Gillmor
Many of the external links found in the notmuch source can be resolved using https instead of http. This changeset addresses as many as i could find, without touching the e-mail corpus or expected outputs found in tests.
2016-03-26test/test-lib.el: revert setting notmuch-mua-reply-insert-header-p-functionTomi Ollila
in d27d90875dfb1 (2016-02-20) notmuch-mua-reply-insert-header-p-function was set to notmuch-show-reply-insert-header-p-never as its default was changed to something else. Now that default is set back to *-never so this change done in d27d90875dfb1 is not needed anymore.
2016-02-21emacs/mua: Let user specify which parts get a header in citations.David Edmondson
Add a customizable function specifying which parts get a header when replying, and give some sensible possiblities. These are, 1) all parts except multipart/*. (Subparts of a multipart part do receive a header button.) 2) only included text/* parts. 3) Exactly as in the show buffer. 4) None at all. This means the reply contains a mish-mash of all the original message's parts. In the test suite we set the choice to option 4 to match the previous behaviour.
2016-01-29test: initial tests for S/MIME and notmuch-emacsDavid Bremner
Test the ability of notmuch-mua-mail to send S/MIME signed (and encrypted) messages; this really relies on existing functionality in message-mode. The generated keys and messages will later be useful for testing the notmuch CLI.
2014-09-21test: New tests for Emacs charset handlingAustin Clements
The test of viewing 8bit messages is known-broken. The rest pass, but for very fragile reasons. The next several commits will fix the known-broken test and make our charset handling robust.
2014-09-21test/emacs: globally force the html renderer to html2textDavid Bremner
Previously we did this for a single test, but some other proposed tests ( id:1398105468-14317-3-git-send-email-amdragon@mit.edu ) show similar breakage when switching renderers.
2014-07-13test: make test_emacs call post-command-hookDavid 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.
2014-03-24emacs: show: mark tags changed since buffer loadedMark Walters
This allows (and requires) the original-tags to be passed along with the current-tags to be passed to notmuch-tag-format-tags. This allows the tag formatting to show added and deleted tags.By default a removed tag is displayed with strike-through in red (if strike-through is not available, eg on a terminal, inverse video is used instead) and an added tag is displayed underlined in green. If the caller does not wish to use the new feature it can pass current-tags for both arguments and, at this point, we do exactly that in the three callers of this function. Note, we cannot tidily allow original-tags to be optional because we would need to distinguish nil meaning "we are not specifying original-tags" from nil meaning there were no original-tags (an empty list). We use this in subsequent patches to make it clear when a message was unread when you first loaded a show buffer (previously the unread tag could be removed before a user realised that it had been unread). The code adds into the existing tag formatting code. The user can specify exactly how a tag should be displayed normally, when deleted, or when added. Since the formatting code matches regexps a user can match all deleted tags with a ".*" in notmuch-tag-deleted-formats. For example setting notmuch-tag-deleted-formats to '((".*" nil)) tells notmuch not to show deleted tags at all. All the variables are customizable; however, more complicated cases like changing the face depending on the type of display will require custom lisp. Currently this overrides notmuch-tag-deleted-formats for the tests setting it to '((".*" nil)) so that they get removed from the display and, thus, all tests still pass.
2014-01-12test/emacs: replace the use of process-attributes with signal-processDavid Bremner
In some environments (at least Hurd), process-attributes is unimplimented and always returns nil. This ends up causing test failures (see e.g. id:87a9ffofsc.fsf@zancas.localnet). Historically and according to POSIX 1003.1-2001, a signal of 0 can be used to check the validity of a pid. This seems less heinous than parsing the output of ps(1).
2013-01-29test: delay watchdog checks in emacs.David Bremner
Instead of checking immediately for the watched process, delay a minute, or in the case that process-attributes returns nil, for two minutes. This is intended to cope with the case that process-attributes is unimplimented, and returns always returns nil. In this case, the watchdog check is the same as the two minute limit imposed by timeout.
2012-11-15test: Test buttonization of id: linksAustin Clements
This matches the current behavior of the buttonizer, so it passes, but many of these cases are not what you'd want (and some of them aren't even valid Xapian queries). The next patch will fix the handling of these cases and update the test.
2012-08-29test: emacs: run list-processes after accept-process-output in emacs 23.1Tomi Ollila
When running emacs tests using emacs 23.1.1 the tests block (until timeout) when emacs function (notmuch-test-wait) is called. There is an emacs bug #2930 titled: 23.0.92; `accept-process-output' and `sleep-for' do not run sentinel It seems this is present in emacs 23.1. Calling list-processes after accept-process-output seems work around this problem; in case Emacs version is 23.1 a defadvice is activated to do just that.
2012-08-29test: emacs: call accept-process-output in notmuch-test-waitTomi Ollila
notmuch-test-wait called sleep-for in a loop to wait unconditionally 0.1 seconds while waiting for process to exit. accept-process-output returns as soon as there is any data available from process, so using it avoids unnecessary fixed delays. Both of these functions run process sentinels.
2012-07-12test: New test for incremental search output parsingAustin Clements
This advises the search process filter to make it process one character at a time in order to test the pessimal case for incremental search output parsing. The text parser fails this test because it gets tricked into thinking a parenthetical remark in a subject is the tag list.
2012-01-26test: `notmuch-test-run' should protect against buffer switching.David Edmondson
The body of the test may cause the current buffer to change. Ensure that the output goes to the correct buffer by switching back before inserting it.
2012-01-26test: `visible-buffer-substring' should not return text properties.David Edmondson
When using `visible-buffer-substring' to examine a buffer, the text properties are not useful, so don't include them.
2012-01-25test: Add more helpers for emacs tests.David Edmondson
2012-01-25test: Add `test_emacs_expect_t'.David Edmondson
Add a new test function to allow simpler testing of emacs functionality. `test_emacs_expect_t' takes one argument - a lisp expression to evaluate. The test passes if the expression returns `t', otherwise it fails and the output is reported to the tester.
2012-01-22test: make (kill-emacs) from emacsclient work with emacs 23.(1|2)Tomi Ollila
emacsclient --eval '(kill-emacs)' makes emacs versions 23.1 and 23.2 ask user input from running emacs. Redefining yes-or-no-p function when kill-emacs is executed for these emacs versions in test-lib.el avoids this test problem.
2011-12-22test: add test for `notmuch-hello-refresh-hook'Dmitry Kurochkin
Test that `notmuch-hello-refresh-hook' is called once when `notmuch-hello' is called and twice when calling `notmuch-hello-update' after that. The tests are very similar to tests for `notmuch-hello-mode-hook'.
2011-12-22test: add general Emacs hook counterDmitry Kurochkin
Replace `notmuch-hello-mode-hook-counter' with general `hook-counter' and `add-hook-counter' functions to allow counting calls for any hook.
2011-12-20test: add `notmuch-hello-mode-hook-counter'Dmitry Kurochkin
Add `notmuch-hello-mode-hook-counter' hook to count how many times `notmuch-hello-mode-hook' was called. The counter function increments `notmuch-hello-mode-hook-counter' variable value if it is bount, otherwise it does nothing.
2011-11-05test: do not set frame width in emacsDmitry Kurochkin
No need for `set-frame-width' in emacs tests since it runs in screen now.
2011-06-28test: use emacsclient(1) for Emacs testsDmitry Kurochkin
Before the change, every Emacs test ran in a separate Emacs instance. Starting Emacs many times wastes considerable time and it gets worse as the test suite grows. The patch solves this by using a single Emacs server and emacsclient(1) to run multiple tests. Emacs server is started on the first test_emacs call and stopped when test_done is called. We take care not to leave orphan Emacs processes behind when test is terminated by whatever reason: Emacs server runs a watchdog that periodically checks that the test is still running. Some tests need to provide user input. Before the change, this was done using echo(1) to Emacs stdin. This no longer works and instead `standard-input' variable is set accordingly to make `read' return the appropriate string.
2011-06-28test: save buffer content to file instead of printing it in Emacs testsDmitry Kurochkin
Before the change, the common Emacs test scheme was to print buffer content to stdout and redirect it to a file or capture it in a shell variable. This does not work if we switch to using emacsclient(1) for running the tests, because you can not print to the stdout in this case. (Actually, you can print to stdout from Emacs server, but you can not capture the output on emacsclient(1)). The patch introduces new Emacs test auxiliary functions: `test-output' and `test-visible-output'. These functions are used to save buffer content to a file directly from Emacs. For most tests the changes are trivial, because Emacs stdout output was redirected to a file anyway. But some tests captured the output in a shell variable and compare it with the expected output using test_expect_equal. These tests are changed to use files and test_expect_equal_file instead. Note: even if we do not switch Emacs tests to emacsclient(1), the patch makes tests cleaner and is an improvement.
2011-06-28test: cleanup test_emacsDmitry Kurochkin
Move auxiliary function definition and configuration from command line to test-lib.el.
2011-05-26test: add test-lib.el file with `visible-buffer-string' functionDmitry Kurochkin
The patch adds test-lib.el file for Emacs tests auxiliary stuff. Currently, it implements two functions: `visible-buffer-string' and `visible-buffer-substring'. These are similar to standard counterparts without "visible-" prefix but exclude invisible text. The functions are not used anywhere at the moment but should be useful for testing hiding/showing in the Emacs interface. Edited-by: Carl Worth <cworth@cworth.org> Fixed "basic" test to ignore new test-lib.el file.