summaryrefslogtreecommitdiff
path: root/test/test-lib.sh
AgeCommit message (Collapse)Author
2016-04-12configure: add test for default xapian backendDavid Bremner
This is mainly for the test suite. We already expect the tests to be run in the same environment as configure was run, at least to get the name of the python interpreter. So we are not really imposing a new restriction.
2016-01-29test: add broken S/MIME signature verification test for notmuch CLIDavid Bremner
The test is pretty much cut and paste from the PGP/MIME version, with obvious updates taken from notmuch output. This also requires setting up gpgsm infrastucture.
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.
2016-01-26test: refactor directory name sanitizationDavid Bremner
test_C and notmuch_search_files_sanitize were giving different output on the same path, which is not technically wrong, but slightly confusing.
2015-12-30test: Unset ALTERNATE_EDITOR before running emacsclientMichal Sojka
ALTERNATE_EDITOR causes emacsclient to run an alternate editor if the emacs server is not ready. This can collide with intended functionality in test-lib.sh. If the ALTERNATE_EDITOR is set but empty, emacsclient runs emacs daemon and tries to connect to it. When this happens the emacs run by test-lib.sh fails to start the server and the subsequent attempts to use the server fail because the daemon started by emacsclient does not know about notmuch-test-progn. This leads to test suite failure due to time out on any emacs test.
2015-08-13lib: API to retrieve database revision and UUIDAustin Clements
This exposes the committed database revision to library users along with a UUID that can be used to detect when revision numbers are no longer comparable (e.g., because the database has been replaced).
2015-08-07test: make script exit (1) if it "fails" to source (.) a fileTomi Ollila
The files (test) scripts source (with builtin command `.`) provides information which the scripts depend, and without the `source` to succeed allowing script to continue may lead to dangerous situations (e.g. rm -rf "${undefined_variable}"/*). At the end of all source (.) lines construct ' || exit 1' was added; In our case the script script will exit if it cannot find (or read) the file to be sourced. Additionally script would also exits if the last command of the sourced file exited nonzero.
2015-08-07emacs: make modifications to message Fcc vars buffer-localDavid Bremner
Previously we globally modified these variables, which tended to cause problems for people using message-mode, but not notmuch-mua-mail, to send mail. User visible changes: - Calling notmuch-fcc-header-setup is no longer optional. OTOH, it seems to do the right thing if notmuch-fcc-dirs is set to nil. - The Fcc header is visible during message composition - The name in the mode line is changed, and no longer matches exactly the menu label. - Previously notmuch-mua-send-and-exit was never called. Either we misunderstood define-mail-user-agent, or it had a bug. So there was no difference if the user called message-send-and-exit directly. Now there will be. - User bindings to C-c C-c and C-c C-s in message-mode-map are overridden. The user can override them in notmuch-message-mode-map, but then they're on their own for Fcc handling.
2015-08-04test: use the python interpreter in sh.configDavid Bremner
The configure script chooses "python" if both python and python{2,3} exist exists, so this could change the version of python used to run the test suite. The checking for ${NOTMUCH_PYTHON} in the test suite is arguably over-engineering, since the configure step will fail if it can't find it.
2015-06-14test: add initial ruby testsDavid Bremner
This is pretty much a line by line translation of the existing python tests, with two new tests for the count API.
2015-05-31cli: change "setup" to "set up" where used as a verbJ. Lewis Muir
The word "setup" is a noun, not a verb. Change occurrences of "setup" where used as a verb to "set up".
2015-03-29test: add support for compiling and running C snippetsDavid Bremner
This is to limit the copy-pasta involved in running C tests. I decided to keep things simple and not try to provide an actual C skeleton. The setting of LD_LIBRARY_PATH is to force using the built libnotmuch rather than any potential system one.
2015-01-19test: prepare test-lib.sh for possible test system debug sessionTomi Ollila
When something in tests fails one possibility to test is to run the test script as `bash -x TXXX-testname.sh`. As stderr (fd 2) was redirected to separate file during test execution also this set -x (xtrace) output would also go there. test-lib.sh saves the stderr to fd 7 from where it can be restored, and bash has BASH_XTRACEFD variable, which is now given the same value 7, making bash to output all xtrade information (consistently) there. This lib file used to save fd's 1 & 2 to 6 & 7 (respectively) in test_begin_subtest(), but as those needs to be set *before* XTRACEFD variable is set those are now saved at the beginning of the lib (once). This is safe and simple thing to do. To make xtrace output more verbose PS4 variable was set to contain the source file, line number and if execution is in function, that function name. Setting this variable has no effect when not xtracing. As it is known that fd 6 is redirected stdout, printing status can now use that fd, instead of saving stdout to fd 5 and use it.
2015-01-17test-lib: Add dummy subject to force empty subjectJesse Rosenthal
At the moment, the test-lib fills in any missing headers. This makes it impossible to test our handling of empty subjects. This will allow us to use a special dummy subject -- `@FORCE_EMPTY` -- to force the subject to remain empty.
2014-10-25Merge tag '0.18.2_rc1'David Bremner
notmuch 0.18.2~rc1 release Conflicts: NEWS debian/changelog
2014-10-25test: kill '"filename": "signature.asc"' from json outputDavid Bremner
This starts to appear with emacs24.4, so we can't easily have it in our expected output.
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-06-13test: use --quick when starting emacs.David Bremner
At least in emacs24, this removes the "site-lisp" directories from the load path in addition to enforcing --no-site-lisp --no-init-file. This works around a slightly mysterious bug on Debian that causes test-lib.el not to load when there is cl-lib.el(c) in some site-lisp directory. It should be harmless in general since we really don't want to load any files from addon packages to emacs.
2014-03-11test: add notmuch_search_files_sanitize and use itJani Nikula
We do this in a lot of places, so make it a helper in the test-lib.
2014-03-11test: add utility function to sort a json listDavid Bremner
So far we only need this one place, but it's a bit messy to inline
2014-03-09support for generating decreasing dates in bash 4.0 and 4.1Tomi Ollila
The printf builtin "%(fmt)T" specifier (which allows time values to use strftime-like formatting) is introduced in bash 4.2. Trying to execute this in pre-4.2 bash will fail -- and if this happens execute the fallback piece of perl code to do the same thing.
2014-03-09test: NOTMUCH_SKIP_TESTS accepts test names with or without Tddd- prefixTomi Ollila
The test names assigned to NOTMUCH_SKIP_TESTS variable can now be given with or without the Tddd- prefix for tester convenience: The test name without Tddd -prefix stays constant even when test filenames are renumbered. The test name with Tddd -prefix is printed out when tests run.
2014-03-06test: Print the number of the test along with its nameAustin Clements
Previously, we stripped the "Tnnn-" part from the test name when printing its description at the beginning of each test. However, this makes it difficult to find the source script for a test (e.g., when a test fails). Put this prefix back.
2014-01-18test: leave T\d\d\d- in variable $this_test and introduce $this_test_bareTomi Ollila
Script `notmuch-test` expects the results file have T\d\d\d- part intact so the results files (and some test output files) are now name as such. Without this change `notmuch-test` will exit in case the test script it was executing exited with nonzero value. The T\d\d\d- part is dropped in new variable $this_test_bare which is used in progress informational messages and when loading .el files in emacs tests (whenever $this_test_bare.el exists).
2014-01-13test: renamed test scripts to format T\d\d\d-name.shTomi Ollila
All test scripts to be executed are now named as T\d\d\d-name.sh, numers in increments of 10. This eases adding new tests and developers to see which are test scripts that are executed by test suite and in which order.
2013-12-28Merge tag '0.17_rc4'David Bremner
notmuch 0.17~rc4 release
2013-12-22test: remove call to notmuch-hello from emacs_deliver_messageDavid Bremner
There is an obscure bug in notmuch-hello that very occasionally causes emacs_deliver_message to fail. Since it it doesn't serve any actual purpose in the function we delete it, and leave tracking down the the bug for another day.
2013-12-22test: add emacs_fcc_message that does not use smtp-dummyDavid Bremner
Most of the tests previously using emacs_deliver_message do not use the actual transmitted message, so we replace it with a simpler (and presumably more reliable function) that only saves (and indexes) an fcc copy of the message.
2013-12-09test: implement and document NOTMUCH_TEST_QUIET variable usageTomi Ollila
When NOTMUCH_TEST_QUIET environment variable is set to non-null value messages when new test script starts and when test PASSes are disabled. This eases picking the cases when tests FAIL (as those are still printed).
2013-12-09test: print empty line at the beginning of test script, not at endTomi Ollila
In preparation for quiet mode print empty line before writing the test description. This is done now in function designed for it -- it will also be called when test fails.
2013-12-09test: resolve `basename "$0" .sh` once for all in test-lib.shTomi Ollila
test-lib.sh sometimes did equivalent of `basename "$0" .sh`, sometimes skipping the basename part and sometimes .sh part. This worked as we never had path components in $0 (more than ./) nor .sh ending. Now the equivalent of `basename "$0" .sh` is done once and used everywhere. In the future we may have .sh suffix in test names -- removing those is a good idea.
2013-12-09test: give unique timestamps to messagesDavid Bremner
The choice of decreasing timestamps is a hack which reduces the number of existing tests which fail. This can be changed to increasing if/when somebody wants update another 47 tests.
2013-12-09test: sanitize dates in emacs, raw, and text outputDavid Bremner
add a new function notmuch_date_sanitize for rfc822-ish things. Add date sanitization to notmuch_show_sanitize_all and use it more places. This is all in aid of a transition to unique timestamps on messages.
2013-12-09test: sanitize Date and timestamp fields in jsonDavid Bremner
Eventually we want test messages to have distinct dates to avoid reproducability problems. This sanitization will prevent some test failures when that change is made. Replace the use of a local function in maildir-sync with notmuch_json_show_sanitize
2013-11-23test: replace $PWD with YYY in emacs & emacs-show testsDavid Bremner
When executed command line is written to *Notmuch errors* buffer, shell-quote-argument will backslash-escape any char that is not in "POSIX filename characters" (i.e. matching "[^-0-9a-zA-Z_./\n]"). Currently in two emacs tests shell has expanded $PWD as part of emacs variable, which will later be fed to #'shell-quote-argument and finally written to ERROR file. If $PWD contained non-POSIX filename characters, data in ERROR file will not match $PWD when later comparing in shell. Therefore, in these two particular cases the escaped $PWD is replaced with YYY in ERROR file and expected content is adjusted accordingly.
2013-10-14test: set mail host in emacs_deliverMark Walters
One test (reply to encrypted message in the crypto test) recently started failing on some systems. The failure I saw were two extra lines of the form <87d2nbc5xg.fsf@host.i-did-not-set--mail-host-address--so-tickle-me> The test pipes the output through grep -v -e '^In-Reply-To:' -e '^References:' which would normally these two ids but it does not, in this case, because they are so long they get put on a separate line in the output. To fix this we set mail-host-address for emacs deliver. example.com seems a sensible address to use. This is short enough that we don't get the line breaks above and the tests then all pass.
2013-09-08test: unset 'xpg_echo' bash shell optionTomi Ollila
When 'xpg_echo' bash shell option is unset (usually the default) echo builtin does not expand backslash-escape sequences by default (i.e. '\n' is echoed as '\n' instead of newline). Not all bash installations have this feature we depend on activated by default. Note that the feature is bash (and GNU /bin/echo) specific. It is used as it is convenient. If portability is needed (elsewhere) use printf(1) (also often available as a shell builtin).
2013-02-18test/test-lib.sh: separate signaled exitTomi Ollila
When execution of tests is interrupted by signal coming outside of the test system itself, output just one line "interrupted by signal <num>" message to standard output. This distinguishes the case from internal exit and reduces noise.
2013-02-18test/test-lib.sh: use $test_subtest_name in all testsTomi Ollila
Set the variable '$test_subtest_name' in all functions which starts a new test and use that variable in all functions that output test results. Additionally output the latest '$test_subtest_name' in case of abnormal exit, to avoid confusion.
2013-01-24test/test-lib.sh: use vt100 as dtach terminal if TERM dumb or unset/emptyTomi Ollila
The TERM environment variable is set to 'dumb' when running tests, but the original value of it is stored for echoing colors and running emacs (somewhat interactively) in detached session. Emacs requires some terminal control sequences to be available for interactive operation. In case original TERM is (also) 'dumb' (or unset/empty) emacs cannot run interactively. To fix this problem dtach (and emacs as it's child process) is run with TERM=vt100 in case original TERM was unset, empty or 'dumb'. This way there is a chance to run emacs tests with different user terminals and potentially find problems there.
2012-12-17test: normalize only message filenames in show jsonPeter Wang
notmuch_json_show_sanitize replaced "filename" field values even in part structures, where the value is predictable. Make it only normalize the filename value if it is an absolute path (begins with slash), which is true of the Maildir filenames that were intended to be normalized away.
2012-12-08test: use perl instead of sed -r for portabilityJani Nikula
Our OS X users report -r is not a supported option for sed. Use perl instead.
2012-12-08test: Fix UTF-8 JSON tests in Python 3Austin Clements
test_expect_equal_json uses json.tool from the system Python. While Python 2 wasn't picky about the encoding of stdin, Python 3 decodes stdin strictly according to the environment. Since we set LC_ALL=C for the tests, Python 3's json.tool was assuming stdin would be in ASCII and aborting when it couldn't decode the UTF-8 characters from some of the JSON tests. This patch sets the PYTHONIOENCODING environment variable to utf-8 when invoking json.tool to override Python's default encoding choice.
2012-11-29test: Use associative arrays to track external prereqsAustin Clements
Previously, the test framework generated a variable name for each external prereq as a poor man's associative array. Unfortunately, prereqs names may not be legal variable names, leading to unintelligible bash errors like test_missing_external_prereq_emacsclient.emacs24_=t: command not found Using proper associative arrays to track prereqs, in addition to being much cleaner than generating variable names and using grep to carefully construct unique string lists, removes restrictions on prereq names.
2012-11-29test: Abort driver if a test script abortsAustin Clements
Previously, if a test script aborted (e.g., because it passed too few arguments to a test function), the test driver loop would simply continue on to the next test script and the final results would declare that everything passed (except that the test count would look suspiciously low, but maybe you just misremembered how many tests there were). Now, if a test script exits with a non-zero status and did not produce a final results file, we propagate that failure out of the driver loop immediately. To keep this simple, this patch removes the PID from the test-results file name. This PID was inherited from the git test system and seems unnecessary, since the file name already includes the name of the test script and the test-results directory is created anew for each run.
2012-11-29test: Make the emacsclient binary user-configurableAustin Clements
And require that if TEST_EMACS is specified, so is TEST_EMACSCLIENT. Previously, the test framework always used "emacsclient", even if the Emacs in use was overridden by TEST_EMACS. This causes problems if both Emacs 23 and Emacs 24 are installed, the Emacs 23 emacsclient is the system default, but TEST_EMACS is set to emacs24. Specifically, with an Emacs 24 server and an Emacs 23 client, emacs tests that run very quickly may produce no output from emacsclient, causing the test to fail. The Emacs server uses a very simple line-oriented protocol in which the client sends a request to evaluate an expression and the server sends a request to print the result of evaluation. Prior to Emacs bzr commit 107565 on March 11th, 2012 (released in Emacs 24.1), if multiple commands were sent to the emacsclient between when it sent the evaluation command and when it entered its receive loop, it would only process the first response command, ignoring the rest of the received buffer. This wasn't a problem with the Emacs 23 server because it sent only the command to print the evaluation result. However, the Emacs 24 server first sends an unprompted command specifying the PID of the Emacs server, then processes the evaluation request, then sends the command to print the result. If the evaluation is fast enough, it can send both of these commands before emacsclient enters the receive loop. Hence, if an Emacs 24 server is used with an Emacs 23 emacsclient, it may miss the response printing command, ultimately causing intermittent notmuch test failures.
2012-11-25test: factor out part of test-lib.sh into test-lib-common.shDavid Bremner
The idea is to use some of the simpler parts of the test suite infrastructure to help run performance tests.
2012-10-22notmuch-show: include Bcc header in json outputMichal Nazarewicz
With this change, emacs users can use notmuch-message-headers variable to configure notmuch-show display Bcc header.
2012-10-20test/test-lib.sh: take the --background feature in smtp-dummy into useTomi Ollila
The use of --background option (instead of shell '&') ensures that smtp-dummy is listening its server socket until execution of shell script can continue, thus the client will always have socket where to connect. smtp-dummy outputs smtp_dummy_pid variable in shell assignment format; eval'ing that output makes that variable available for the shell. As the smtp-dummy instance is no longer child process of the script the SIGKILL signal sent to it will ensure it is going away in case the mail sender fails to connect to smtp-dummy.
2012-10-20test-lib.sh: pass 'NOTMUCH_NEW's args down to 'notmuch new'Pieter Praet
Obviates the need to create a 'NOTMUCH_NEW' clone which runs 'notmuch new --debug'. This will be used in a later patch. Doesn't cause any issues for other tests.