Commit graph

265 commits

Author SHA1 Message Date
Tomi Ollila
2c5eed16b3 test: replaced use of python with $NOTMUCH_PYTHON (twice)
$NOTMUCH_PYTHON is sourced from sh.config, configured by
./configure and stated to be used as:

"Name of python command to use in configure and the test suite."
2017-02-23 08:55:24 -04:00
David Bremner
9951598d11 Merge branch 'release'
Merge changes to use gpgconf --create-socketdir
2017-02-21 08:16:07 -04:00
David Bremner
e7b88e8b0a test: use gpgconf --create-socketdir if available
This enables the shortened socket pathes in /run or equivalent. The
explicit call to gpgconf is needed for nonstandard GNUPGHOME settings.

(amended according to id:m2fujatr4k.fsf@guru.guru-group.fi)
2017-02-21 07:45:40 -04:00
Tomi Ollila
95efe2d484 test: allow user to choose which gdb to run tests with
The variable used for selecting gdb is TEST_GDB, consistent with
TEST_CC and TEST_EMACS{,CLIENT}.
2017-01-08 10:50:28 -04:00
David Bremner
d35c2c15f6 Merge branch 'release'
Initial set of changes for 0.23.3
2016-11-24 21:21:16 -04:00
Daniel Kahn Gillmor
d31161c212 tests: account for varying-size cryptographic signatures
GnuPG 2.1.16 is now injecting the full issuer fingerprint in its
signatures, which makes them about 32 octets larger when
ascii-armored.

This change in size means that the size of the MIME parts will vary
depending on the version of gpg that the user has installed.  at any
rate, the signature part should be non-zero (this is true for
basically any MIME part), so we just test for that instead of an exact
size.
2016-11-24 20:22:12 -04:00
Tomi Ollila
8a82ad716f test/test-lib.sh: execute basename(1)s lazier in test_expect_equal_file ()
Moved the 2 basename(1) executions to the test failure branch in
test_expect_equal_file ().

The output of basename(1) executions in function test_expect_equal_file ()
are only used when tests fails -- when all tests pass these 2 basename(1)
executions are no longer done at all.
2016-10-25 18:13:29 -03:00
Tomi Ollila
c008dd1352 test: use vt100 as "smart" terminal for known dumb/unknown terminals
Otherwise use whatever user environment has set for TERM so
that there is more chance to test on users' actual environments.
2016-10-22 12:18:43 -03:00
Tomi Ollila
a3ee732c52 test-lib.sh: rename $DTACH_TERM to $SMART_TERM 2016-10-22 12:13:55 -03:00
Tomi Ollila
b57426a435 test: test-lib.sh: use $BASH instead of ${SHELL-sh} to relaunch
In case of the test script is to be relaunced under valgrind, or --tee
is requested, use the $BASH shell variable to locate the command
interpreter. The $SHELL variable is re-set by non-interactive shells
so in case the shell uses some other shell (e.g. zsh) for interactive
use these bash scripts continue to work.
2016-09-24 10:10:40 -03:00
Jani Nikula
971cdc72cd test: make it possible to have multiple corpora
We largely use the corpus under test/corpus for
testing. Unfortunately, many of our tests have grown to depend on
having exactly this set of messages, making it hard to add new message
files for testing specific cases.

We do use a lot of add_message from within the tests, but it's not
possible to use that for adding broken messages, and adding several
messages at once can get unwieldy.

Move the basic corpus under tests/corpora/default, and make it
possible to add new, independent corpora along its side. This means
tons of renames with a few tweaks to add_email_corpus function in
test-lib.sh to let tests specify which corpus to use.
2016-09-17 08:39:34 -03:00
David Bremner
cc1a6d2a94 test: factor out some boilerplate from C tests
The trick of having a common header file doesn't work to share between
test scripts, so make an include file in the test directory.

The use of #include <notmuch-test.h> looks slightly pretentious, but
the include file is not actually in the current (temporary) directory.
2016-06-13 21:52:33 -03:00
Tomi Ollila
2333a44ab7 test: test_python: set PYTHONPATH to the python execution environment
Place PYTHONPATH to the environment when python is executed in a way
that current shell environment is not affected. This also allows adding
the old value of PYTHONPATH to the end of the new value (otherwise it
would have been appended again and again when test_python is called).

At the same time, use -B option to avoid writing .pyc files to
bindings/python/* (which are not cleared out by distclean).

Drop the (unused) prefix code which preserved the original stdout of the
python program and opened sys.stdout to OUTPUT. In place of that there
is now note how (debug) information can be printed to original stdout.
2016-06-11 13:12:08 -03:00
Tomi Ollila
f0e5317bcd test: set LD_LIBRARY_PATH early and keep its old contents
Previously LD_LIBRARY_PATH was exported (and environment changed)
in the middle of test case execution, when a function setting it
was called.

Previously the old contents of LD_LIBRARY_PATH was lost (if any)
when it was re-set and exported. In some systems the old contents of
LD_LIBRARY_PATH was needed to e.g. locate suitable gmime library.
2016-06-11 13:11:49 -03:00
Tomi Ollila
d53b417d1f test: add function die () and have use of it in add_email_corpus ()
Added die() function to test-lib.sh with the following first use of it:

If notmuch new fails during email corpus addition the database is
most probably inexistent or broken and the added corpus would be
unusable while running single tests, giving misleading failures
("only" full 'make test' cleans out old corpus).
2016-06-11 13:03:09 -03:00
Tomi Ollila
1ca752fa36 test-lib.sh: renamed die...()s to trap...()s and exit...()
Now the function names more accurately describes what the functions do.
2016-06-11 13:03:00 -03:00
Daniel Kahn Gillmor
6a833a6e83 Use https instead of http where possible
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-06-05 08:32:17 -03:00
David Bremner
2d2a13966c CLI: add notmuch-config support for named queries
Most of the infrastructure here is general, only the validation/dispatch
is hardcoded to a particular prefix.

A notable change in behaviour is that notmuch-config now opens the
database e.g. on every call to list, which fails with an error message
if the database doesn't exit yet.
2016-05-25 07:40:44 -03:00
David Bremner
e042a25a3f CLI: add optional config data to dump output.
Note that it changes the default dump output format, but doesn't break
existing notmuch-restore. It might break user scripts though.
2016-05-25 07:07:56 -03:00
Tomi Ollila
b183f2635e test: copyright information updates
Files in test directories had only copyright of a single individual,
of which code was adapted here as a base of the test system.
Since then many Notmuch Developers have contributed to the test
system, which is now acknowledged with a constant string in some
of the test files.

The README file in test directory instructed new files contain a
copyright notice, but that has never been done (and it is also not
needed). To simplify things a bit (and lessen confusion) this
instruction is now removed.

As a side enchangement, all of the 3 entries in the whole source
tree cd'ing to `dirname` of "$0" now uses syntax cd "$(dirname "$0")".
This makes these particular lines work when current working directory
is e.g. /c/Program Files/notmuch/test/.
(Probably it would fail elsewhere, though.)
2016-05-19 07:56:58 -03:00
David Bremner
792bea5aff lib/cli: add library API / CLI for compile time options
This is intentionally low tech; if we have more than two options it may
make sense to build up what infrastructure is provided.
2016-05-13 07:29:12 -03:00
David Bremner
deb4e5567c configure: add test for default xapian backend
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-04-12 20:14:43 -03:00
David Bremner
a530a1706a test: add broken S/MIME signature verification test for notmuch CLI
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-29 17:45:46 -04:00
David Bremner
ef30770dfa test: initial tests for S/MIME and notmuch-emacs
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-29 17:45:46 -04:00
David Bremner
12534d5c4b test: refactor directory name sanitization
test_C and notmuch_search_files_sanitize were giving different output on
the same path, which is not technically wrong, but slightly
confusing.
2016-01-26 22:50:58 -04:00
Michal Sojka
a9fec12a08 test: Unset ALTERNATE_EDITOR before running emacsclient
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-12-30 11:28:30 -04:00
Austin Clements
98ee460eaa lib: API to retrieve database revision and UUID
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-13 23:52:51 +02:00
Tomi Ollila
02a2eeb427 test: make script exit (1) if it "fails" to source (.) a file
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-07 21:56:39 +02:00
David Bremner
d0553ad524 emacs: make modifications to message Fcc vars buffer-local
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-07 21:18:59 +02:00
David Bremner
23d86773b9 test: use the python interpreter in sh.config
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-08-04 09:19:18 +02:00
David Bremner
d9567dd5b5 test: add initial ruby tests
This is pretty much a line by line translation of the existing python
tests, with two new tests for the count API.
2015-06-14 18:00:52 +02:00
J. Lewis Muir
d08af93c65 cli: change "setup" to "set up" where used as a verb
The word "setup" is a noun, not a verb.  Change occurrences of "setup"
where used as a verb to "set up".
2015-05-31 19:14:42 +02:00
David Bremner
1e69afe8af test: add support for compiling and running C snippets
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-03-29 00:33:56 +01:00
Tomi Ollila
7fcd100a2f test: prepare test-lib.sh for possible test system debug session
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-19 08:15:39 +01:00
Jesse Rosenthal
c0c007dd7f test-lib: Add dummy subject to force empty subject
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.
2015-01-17 13:49:05 +01:00
David Bremner
ce44657c9e notmuch 0.18.2~rc1 release
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQGcBAABCAAGBQJUS2vpAAoJEPIClx2kp54svhoL/1kCYjeONhccqb1cyjCVPsC7
 NBGZ48JZNqmDnxrjjz4PgrA9R7h/4R4ViWboCNGFJEbQaPqh89klLa+XiOpaNoyZ
 Y2oP/GrZNXg2TtThehywwWY2w/Q2+bfpyI8C1RnXDuLzvtS6fTpSfGX9+yr7KfUE
 fT56r2V68HHTaTUSFvywKpnRMNnExoa1HT/0EdDRV3v3LqlqALZwgyJAv7hb7EfX
 0a7Q5JChVhQyq+BRq4tKJA2g/n3s54dy3cIBXmSjo8CvOar+GVgrceZ5i1al7Z7x
 D2BDpMfr2qV4fJYapsH+n3fsUhr0LmG651A5A2GdaGUNhLtP28hGPUZpT+ejzTAW
 GOWdlF+PzDCMhdZzqjYQUqN3ROgQsDUcGrwXv+tVv2AoZepSbxyhIeIzU71dD/vx
 5JEP3EVJMwgWbDHKeOzv1+nwzQpMWk8/vxSA9SPN9MBUMkNjaKyrY1YBrX6xtUn0
 l3iglBOdTcqr0uZSVSTU4sODcKtd/w2TlSOSWWnRNA==
 =KuiR
 -----END PGP SIGNATURE-----

Merge tag '0.18.2_rc1'

notmuch 0.18.2~rc1 release

Conflicts:
	NEWS
	debian/changelog
2014-10-25 11:38:18 +02:00
David Bremner
e32bb20099 test: kill '"filename": "signature.asc"' from json output
This starts to appear with emacs24.4, so we can't easily have it in
our expected output.
2014-10-25 10:39:07 +02:00
David Bremner
eed6c75556 test: make test_emacs call post-command-hook
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-07-13 12:33:53 -03:00
David Bremner
2d722bf032 test: use --quick when starting emacs.
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-06-13 22:55:14 -03:00
Jani Nikula
7630f300ba test: add notmuch_search_files_sanitize and use it
We do this in a lot of places, so make it a helper in the test-lib.
2014-03-11 19:22:52 -03:00
David Bremner
8c37821a0d test: add utility function to sort a json list
So far we only need this one place, but it's a bit messy to inline
2014-03-11 19:22:52 -03:00
Tomi Ollila
e79d2fc993 support for generating decreasing dates in bash 4.0 and 4.1
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-09 10:09:51 -03:00
Tomi Ollila
d8ba7bee7d test: NOTMUCH_SKIP_TESTS accepts test names with or without Tddd- prefix
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-09 10:09:26 -03:00
Austin Clements
81ede90597 test: Print the number of the test along with its name
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-03-06 07:46:48 -04:00
Tomi Ollila
86e24eab8a test: leave T\d\d\d- in variable $this_test and introduce $this_test_bare
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-18 14:40:11 -04:00
Tomi Ollila
a755c9d6a9 test: renamed test scripts to format T\d\d\d-name.sh
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.
2014-01-13 14:16:46 -04:00
David Bremner
47b9314eee notmuch 0.17~rc4 release
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.15 (GNU/Linux)
 
 iQGcBAABCAAGBQJSv30MAAoJEPIClx2kp54s5KcL+wX3z4NjIOKcTUVEUI0A97JK
 RaGpm+TNSJjfiJSwzDPLm93S7Q+DGfPPTuAWUL69fJlDYvGRRlZfsVSLTq/YLPOz
 cfz9laTp+gqEF9aDGCa/1vZdfmP6ojXOvm24LiRo/LGS9t6OQUts4Ia1zzsNzFJT
 hBblll2sk21c//biD8wLfBj6vKwXNmQAiNiPl1sYbhGjTSPe1pnvPoe4DuhJHk5A
 +V6bq8xRGMGRDayOCsYDoKlYT89IlcHAFQLQiaxNJQ+diopNsK2w4rWJhQr9xkvV
 Ps9wySt48Smlw4wkDUswiBy8K9xrnVZ/pKPzCl4M/ObLBgYXD2Z6m8el+3KKXVk3
 i9PUyrjtaUURvtZJphTdCPX8qr4DMWPhf0hmOH8AO7BpVG9DAXkB3GBEI9Gy/9yR
 RaeuJEYIO8EbQ3cX8bQexU+ZzQTohZyBVSj5BuRgHzFrySGhRSxzb4W1ESqieEiS
 b6/71t/8WH1K3WPol2HeId38BGC6X8J6mnVINfbGeA==
 =z/ep
 -----END PGP SIGNATURE-----

Merge tag '0.17_rc4'

notmuch 0.17~rc4 release
2013-12-28 21:45:19 -04:00
David Bremner
30cde97ba8 test: remove call to notmuch-hello from emacs_deliver_message
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-22 20:44:45 +08:00
David Bremner
513a36d105 test: add emacs_fcc_message that does not use smtp-dummy
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-22 20:44:44 +08:00
Tomi Ollila
88e6a2995a test: implement and document NOTMUCH_TEST_QUIET variable usage
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-09 23:29:11 +08:00
Tomi Ollila
f05e7f3ce5 test: print empty line at the beginning of test script, not at end
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-09 23:25:41 +08:00
Tomi Ollila
5985438e05 test: resolve basename "$0" .sh once for all in test-lib.sh
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-09 23:25:28 +08:00
David Bremner
b421f00a05 test: give unique timestamps to messages
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-09 21:20:28 +08:00
David Bremner
72ff135ac3 test: sanitize dates in emacs, raw, and text output
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-09 21:20:27 +08:00
David Bremner
18921be2e9 test: sanitize Date and timestamp fields in json
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-12-09 21:20:27 +08:00
David Bremner
2560996b7e test: replace $PWD with YYY in emacs & emacs-show tests
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-11-23 20:25:29 -04:00
Mark Walters
48231337b7 test: set mail host in emacs_deliver
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-10-14 08:23:07 -03:00
Tomi Ollila
fae15296ec test: unset 'xpg_echo' bash shell option
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-09-08 22:42:12 -03:00
Tomi Ollila
0d8d11d338 test/test-lib.sh: separate signaled exit
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-18 20:17:17 -04:00
Tomi Ollila
3a15602d8e test/test-lib.sh: use $test_subtest_name in all tests
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-02-18 20:17:05 -04:00
Tomi Ollila
a12f810a00 test/test-lib.sh: use vt100 as dtach terminal if TERM dumb or unset/empty
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.
2013-01-24 06:59:21 -04:00
Peter Wang
ee425ae2ad test: normalize only message filenames in show json
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-17 09:08:04 -04:00
Jani Nikula
540a34d096 test: use perl instead of sed -r for portability
Our OS X users report -r is not a supported option for sed. Use perl
instead.
2012-12-08 09:19:34 -04:00
Austin Clements
21326a1e6b test: Fix UTF-8 JSON tests in Python 3
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-12-08 09:19:34 -04:00
Austin Clements
7a0813b72a test: Use associative arrays to track external prereqs
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-29 09:24:12 -04:00
Austin Clements
ec59896de0 test: Abort driver if a test script aborts
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-29 09:24:12 -04:00
Austin Clements
d59d9c8152 test: Make the emacsclient binary user-configurable
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-29 09:24:12 -04:00
David Bremner
20b7e0ff2f test: factor out part of test-lib.sh into test-lib-common.sh
The idea is to use some of the simpler parts of the test suite
infrastructure to help run performance tests.
2012-11-25 21:11:59 -04:00
Michal Nazarewicz
ffb629cc5d notmuch-show: include Bcc header in json output
With this change, emacs users can use notmuch-message-headers
variable to configure notmuch-show display Bcc header.
2012-10-22 20:06:21 -03:00
Tomi Ollila
b7f7b573e4 test/test-lib.sh: take the --background feature in smtp-dummy into use
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-20 17:46:11 -03:00
Pieter Praet
f96ddb15f8 test-lib.sh: pass 'NOTMUCH_NEW's args down to 'notmuch new'
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.
2012-10-20 17:28:34 -03:00
Ethan Glasser-Camp
b52ee879d8 test: handle filenames that have directories in them
Since $TEST_DIRECTORY is an absolute path, any filenames generated
with it will be complete paths. Only use the basename to generate
suffixes for filenames.

Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>
2012-10-18 08:44:37 -03:00
Austin Clements
61a9448b58 test: Clear test-output output file before running Emacs tests
Most Emacs tests end with a call to (test-output), which saves the
buffer to a filed called OUTPUT.  Previously, if the test code failed
with an exception before this call, the test framework would then
compare against the OUTPUT file from the last Emacs test, resulting in
confusing diffs.

This requires one tweak to an emacs test that made two calls to
test_emacs and expected an OUTPUT file from the first call.  We simply
reverse the order of the test_emacs calls.
2012-09-30 11:40:22 -03:00
Mike Kelly
d29ff5699d tests: Test against source man pages.
Without this, help-test tests against the installed man pages, rather
than the default ones.
2012-09-01 23:16:39 -03:00
Dmitry Kurochkin
1ffb382961 test: make test_expect_equal_file() arguments flexible
Before the change, test_expect_equal_file() function treated the first
argument as "actual output file" and the second argument as "expected
output file".  When the test fails, the files are copied for later
inspection.  The first files was copied to "$testname.output" and the
second file to "$testname.expected".  The argument order for
test_expect_equal_file() is often wrong which results in confusing
diff output and incorrectly named files.

The patch solves the issue by changing test_expect_equal_file() to
treat arguments just as two files, without any special properties
(like "actual" and "expected").  The file names for copying is now
based on the given file name: "$testname.$file1" and
"$testname.$file2".  E.g. if test_expect_equal_file() is called with
"OUTPUT" and "EXPECTED", the copied files can be named
"emacs.1.OUTPUT" and "emacs.1.EXPECTED".

The down side of this approach is that diff argument order depends on
test_expect_equal_file() argument order.  So sometimes we get diff
from expected to actual results, and sometimes the other way around.
But the files are always named correctly.
2012-09-01 23:09:26 -03:00
Austin Clements
a34bb1f9fa test: Uniformly canonicalize actual and expected JSON
Previously, we used a variety of ad-hoc canonicalizations for JSON
output in the test suite, but were ultimately very sensitive to JSON
irrelevancies such as whitespace.  This introduces a new test
comparison function, test_expect_equal_json, that first pretty-prints
*both* the actual and expected JSON and the compares the result.

The current implementation of this simply uses Python's json.tool to
perform pretty-printing (with a fallback to the identity function if
parsing fails).  However, since the interface it introduces is
semantically high-level, we could swap in other mechanisms in the
future, such as another pretty-printer or something that does not
re-order object keys (if we decide that we care about that).

In general, this patch does not remove the existing ad-hoc
canonicalization because it does no harm.  We do have to remove the
newline-after-comma rule from notmuch_json_show_sanitize and
filter_show_json because it results in invalid JSON that cannot be
pretty-printed.

Most of this patch simply replaces test_expect_equal and
test_expect_equal_file with test_expect_equal_json.  It changes the
expected JSON in a few places where sanitizers had placed newlines
after commas inside strings.
2012-08-03 20:14:47 -03:00
Dmitry Kurochkin
db97cb5b65 test: use subtest name for generated message subject by default
Before the change, messages generated by generate_message() used "Test
message #N" for default subject where N is the generated messages
counter.  Since message subject is commonly present in expected
results, there is a chance of breaking other tests when a new
generate_message() call is added.  The patch changes default subject
value for generated messages to subtest name if it is available.  If
subtest name is not available (i.e. message is generated during test
initialization), the old default value is used (in this case it is
fine to have the counter in the subject).

Another benefit of this change is a sane default value for subject in
generated messages, which would allow to simplify code like:

  test_begin_subtest "test for a cool feature"
  add_message [subject]="message for test for a cool feature"
2012-03-18 09:14:22 -03:00
Michal Sojka
74f8f15adc test: Add test for searching of uncommonly encoded messages
Emails that are encoded differently than as ASCII or UTF-8 are not
indexed properly by notmuch. It is not possible to search for non-ASCII
words within those messages.
2012-02-29 07:34:54 -04:00
Pieter Praet
e3fb62f59b test: always report missing prereqs, independent of `--verbose' option
When tests are skipped due to missing prereqs, those prereqs are only
displayed when running with the `--verbose' option.  This is essential
information when troubleshooting, so always send to stdout.
2012-02-20 23:24:20 -04:00
Dmitry Kurochkin
754ddbb578 test: auto load elisp tests file in test_emacs if available
This allows us to simplify shell part of tests written in elisp.
2012-02-12 11:58:20 -05:00
David Edmondson
260975e8af test: Add `test_emacs_expect_t'.
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-25 07:25:44 -04:00
David Edmondson
2903b32f79 test: Don't return the result of checking for running emacs to the tester.
When checking for a running emacs, test_emacs evaluates the empty list
'()'. This returns 'nil' when emacs is running, which is then
prepended to the actual test result. Given that it is not part of the
actual test output the test harness can incorrectly report test
failure (or success).
2012-01-25 07:25:25 -04:00
Tomi Ollila
da9f392165 test: whitespace-cleanup for most test/* files
Used emacs (whitespace-cleanup) function to "cleanup blank problems"
in test files where that could be done without breaking tests;
test/emacs was partially, and test/multipart was fully reverted.
2012-01-22 09:12:12 -04:00
Pieter Praet
42e8f66edf test: don't bail out of `run_emacs' too early when missing prereqs
When running the Emacs tests in verbose mode, only the first missing
prereq is reported because the `run_emacs' function is short-circuited
early:

  #+begin_example
    emacs: Testing emacs interface
     missing prerequisites: [0]  emacs(1)
     skipping test: [0]  Basic notmuch-hello view in emacs
     SKIP   [0]  Basic notmuch-hello view in emacs
  #+end_example

This can lead to situations reminiscent of "dependency hell", so instead
of returning based on each individual `test_require_external_prereq's exit
status, we now do so only after checking all the prereqs:

  #+begin_example
    emacs: Testing emacs interface
     missing prerequisites: [0]  dtach(1) emacs(1) emacsclient(1)
     skipping test: [0]  Basic notmuch-hello view in emacs
     SKIP   [0]  Basic notmuch-hello view in emacs
  #+end_example

Also added missing prereq for dtach(1).
2012-01-15 22:37:07 -04:00
Austin Clements
f4996c3f04 test: Remove #! line from test-lib.sh
It makes no sense to run test-lib.sh, so it makes no sense to give it
an interpreter.  This is particularly annoying for Emacs users who
have executable-insert set, since the presence of the #! line will
cause Emacs to mark test-lib.sh executable when saving it, which will
in turn case the 'basic' test to fail.
2011-12-29 18:03:00 -04:00
Austin Clements
66ecd9063f test: Make generated message date a real date
January 5, 2001 was a Tuesday, not a Friday.  Jameson fixed this exact
problem for the multipart test in ec2b0a98cc, but not for
generate_message itself.

As Jameson pointed out in ec2b0a98cc, if we want to test date parsing,
we should do it separately.
2011-12-29 17:47:21 -04:00
David Bremner
bed6022ed1 test: allow user to choose which emacs to run tests with.
As we start to pay more attention to emacs24, it helps to be able to
select a different version of emacs to run the tests with to verify
version specific bugs.

A separate variable TEST_EMACS is needed to avoid being overwritten by the
make variable EMACS in Makefile.config

For what it's worth, the value of emacs is chosen at the time
tmp.emacs/run_emacs is created, so is fixed for all subtests.
2011-12-28 15:50:04 -04:00
David Bremner
451c57d19a test: optionally print subtest number
The idea is that $test_count could be used in tests to label
intermediate files. The output enabled by this patch (and --debug)
helps figure out which OUTPUT.nn file belongs to which test in case
several subtests write to OUTPUT.$test_count
2011-12-18 06:33:27 -04:00
Thomas Jost
ae13d612c1 test: use python2 instead of python if available
Some distros (Arch Linux) ship Python as python2 and Python 3 as python.
Checking for python2 is necessary for the Python tests to work on these
platforms.
2011-12-11 10:43:16 -04:00
Thomas Jost
2621f6cef1 test: add a function to run Python tests
The new test_python() function makes writing Python tests a little easier:
- it sets the environment variables as needed
- it redirects stdout to the OUTPUT file (like test_emacs()).

This commit also declares python as an external prereq.

The stdout redirection is required to avoid trouble when running commands like
"python 'script' | sort > OUTPUT": in such a case, any error due to a missing
external prereq would be "swallowed" by sort, resulting to a failed test instead
of a skipped one.
2011-12-11 10:40:14 -04:00
Dmitry Kurochkin
e994bb28df test: add functions to count how much times notmuch was called
The patch adds two auxiliary functions and a variable:

  notmuch_counter_reset
  $notmuch_counter_command
  notmuch_counter_value

They allow to count how many times notmuch binary is called.
notmuch_counter_reset() function generates a script that counts how
many times it is called and resets the counter to zero.  The function
sets $notmuch_counter_command variable to the path to the generated
script that should be called instead of notmuch to do the counting.
The notmuch_counter_value() function returns the current counter
value.
2011-12-07 20:03:00 -04:00
Dmitry Kurochkin
de3d46e93c test: fix error messages for missing binary dependencies
The fake missing binary functions check if the binary has already be
added to the diagnostic message to avoid duplicates.  Unfortunately,
this check was buggy because the message string does not have the
trailing space.
2011-11-30 17:26:10 -08:00
Dmitry Kurochkin
5635977543 test: fix spurious output from missing external binaries functions
The grep(1) command used in the fake binary functions was missing the
quiet option.
2011-11-30 17:25:24 -08:00
Dmitry Kurochkin
571810f717 test: add missing escape backslash in test_declare_external_prereq() 2011-11-30 17:23:00 -08:00
Dmitry Kurochkin
716e9a45b9 test: fix test_require_external_prereq()
test_missing_external_prereq_${binary}_ variable indicates that the
binary is missing.  It must be set in test_declare_external_prereq()
outside of the fake $binary() function.
2011-11-30 17:22:28 -08:00
Dmitry Kurochkin
5af65f65e8 test: check if emacs is available in the beginning of test_emacs
Unfortunately, this is needed to avoid the emacs waiting loop.
2011-11-27 11:33:13 -08:00
Dmitry Kurochkin
f0fbdad04b test: add function to explicitly check for external dependencies
Useful when binary is called indirectly (e.g. from emacs).
2011-11-27 11:32:52 -08:00
Dmitry Kurochkin
d095902266 test: declare external dependencies for the tests
That are: dtach(1), emacs(1), emacsclient(1), gdb(1) and gpg(1).
2011-11-27 11:32:26 -08:00
Dmitry Kurochkin
f325466728 test: skip all subtests if external dependencies are missing during init
Some tests (e.g. crypto) do a common initialization required for all
subtests.  The patch adds a check for missing external dependencies
during this initialization.  If any prerequisites are missing, all
subtests are skipped.

The check is run on the first call of test_reset_state_ function, so
no changes for the tests are needed.
2011-11-27 11:32:11 -08:00
Dmitry Kurochkin
5b37fb1e25 test: fix "skipping test" verbose output 2011-11-27 11:31:46 -08:00
Dmitry Kurochkin
66158d5e40 test: add support for external executable dependencies
There is existing support for general prerequisites in the test suite.
But it is not very convenient to use: every test case has to keep
track for it's dependencies and they have to be explicitly listed.

The patch aims to add better support for a particular type of external
dependencies: external executables.  The main idea is to replace
missing external binaries with shell functions that have the same
name.  These functions always fail and keep track of missing
dependencies for a subtest.  The result reporting functions later can
check that an external binaries are missing and correctly report SKIP
result instead of FAIL.  The primary benefit is that the test cases do
not need to declare their dependencies or be changed in any way.
2011-11-27 11:31:17 -08:00
Dmitry Kurochkin
5aeca8182f test: add test state reset to test_expect_* functions that did not have it 2011-11-27 08:13:52 -08:00
Dmitry Kurochkin
9d5b521472 test: set EMACS_SERVER variable only after dtach(1) was successfully started
Otherwise, we can set the EMACS_SERVER and return with an error.  And
subsequent calls to test_emacs would assume that emacs server is running.
2011-11-27 08:13:07 -08:00
Dmitry Kurochkin
1660ca5e61 test: move subtest variables reset into a dedicated function
Currently, there is only one such variable test_subtest_known_broken_.
But more will be added in the future.
2011-11-27 08:12:41 -08:00
Dmitry Kurochkin
bad712e20f test: remove executable permissions from test-lib.sh
It is not supposed to be run, only sourced.
2011-11-26 09:12:14 -08:00
Tomi Ollila
c832dad322 test: attempt to send QUIT to smtp-dummy in case mail send failed
If mail sending from emacs fails before it has chance to connect
to the smtp-dummy mail server, the opportunistic QUIT message
sending makes smtp-dummy to exit.
2011-11-18 10:49:53 -04:00
Tomi Ollila
8efdc0518d test: create dtach's session socket in $TEST_TMPDIR
Due to 108-character limit in unix domain socket path this change
is required; it is more probable that length of ${TMPDIR:-/tmp} is
shorter than length of path to the current directory of notmuch test
source directory. One can expect to create reasonable-length unix
domain sockets wherever $TMPDIR points to.
2011-11-17 19:35:32 -04:00
Tomi Ollila
a0ec104f13 test: create TEST_TMPDIR for holding temporary files
The TEST_TMPDIR if first needed to hold dtach's socket (due
to 108-character limit in socket file names). Later it can be
used to hold other temporary files; directory deleted at exit.
2011-11-17 19:35:32 -04:00
Dmitry Kurochkin
5964a760a5 test: do not hide test_emacs errors
Do not redirect test_emacs stderr to /dev/null.  Test_emacs uses
emacsclient(1) now and it does not print unwanted messages (like
those from `message') to stderr.  But it does print useful
errors, e.g. when emacs server connection fails, given expression
is not valid or undefined function is called.
2011-11-13 09:44:36 -04:00
Tomi Ollila
085d45e389 exec emacs at the end of run_emacs script
In the last line of run_emacs, exec the emacs process.
With one fork less the process list is (also) neater.
2011-11-12 23:21:44 -04:00
Tomi Ollila
2f2ea8a49a test: use dtach(1) instead of screen(1) in emacs tests
dtach is simpler than screen and is not setuid/setgid program so
TMPDIR does not get cleared by dynamic loader when executed
2011-11-11 18:24:53 -05:00
Dmitry Kurochkin
746a13e6f4 test: avoid using screen(1) configuration files
Set SCREENRC and SYSSCREENRC environment variables to "/dev/null"
as suggested by Jim Paris to avoid potential problems with
screen(1) configuration files.
2011-11-05 21:54:40 -03:00
Dmitry Kurochkin
a1ea4e914f test: run emacs inside screen
Before the change, emacs run in daemon mode without any visible
buffers.  Turns out that this affects emacs behavior in some
cases.  In particular, `window-end' function returns `point-max'
instead of the last visible position.  That makes it hard or
impossible to implement some tests.  The patch runs emacs in a
detached screen(1) session.  So that it works exactly as if it
has a visible window.

Note: screen terminates when emacs exits.  So the patch does not
introduce new "running processes left behind" issues.
2011-11-05 20:49:27 -03:00
David Bremner
f4148e9d21 test/test-lib.sh: update comments
- explain test_expect_equal_file
- remove mention of test_expect_failure, since that function was removed.

Based on id:"1317317811-29540-1-git-send-email-thomas@schwinge.name"
2011-10-22 19:43:02 -03:00
Austin Clements
003e718020 test: Report test failures from test_expect_*
This makes test_expect_* return non-zero if the test fails, so the
caller can make decisions based on this, such as setting test
prerequisites.
2011-09-12 23:36:00 -03:00
Austin Clements
5ae1b9c328 test: Fix message when skipping test_expect_equal* tests
For these types of tests, the test name is previously recorded in a
variable, not passed to the test function, so pass this variable to
test_skip.
2011-09-12 23:35:59 -03:00
David Bremner
22af786838 test: reset test_subtest_known_broken_ after each success/failure.
This means that test_subtest_known_broken needs to be called before
every known broken subtest, which is no different than what is
documented for the test_begin_subtest case.

The assumption is that every test ends up calling either skipping,
calling test_ok_ or test_failure_ and and the latter in turn delegate
to the known_broken versions in the case where
test_subtest_known_broken_ is set.
2011-09-12 23:35:21 -03:00
Dmitry Kurochkin
4cc6727688 test: improve known broken tests support
There is existing support for broken tests.  But it is not convenient
to use.  The primary issue is that we have to maintain a set of
test_expect_*_failure functions which are equivalent to the normal
test_expect_* counterparts except for what functions are called for
result reporting.  The patch adds test_subtest_known_broken function
which marks a subset as broken, making the normal test_expect_*
functions behave as test_expect_*_failure.  All test_expect_*_failure
functions are removed.  Test_known_broken_failure_ is changed to
format details the same way as test_failure_ does.

Another benefit of this change is that the diff when a broken test is
fixed would be small and nice.

Documentation is updated accordingly.
2011-09-10 10:13:27 -03:00
Austin Clements
47afbdfb79 test: Nix increment_mtime.
With the fix for the mtime race, this workaround is no longer
necessary.
2011-06-29 15:26:45 -07:00
Dmitry Kurochkin
a854d06e92 test: use emacsclient(1) for Emacs tests
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-28 17:10:55 -07:00
Carl Worth
6ea26cfb81 test: Increment mtime when delivering a message with emacs_deliver_message
Without this, mail messages delivered by emacs_deliver_message might
not be seen by the next invocation of "notmuch new", (which can lead
to test-suite failures if emacs_deliver_message is fast enough).
2011-06-28 17:10:55 -07:00
Mark Anderson
eb4cf465a5 test:Improve test behaviors when --root is used
Change add_email_corpus, emacs_deliver_message and tests to use
$TEST_DIRECTORY instead of '..'.

This improves the behavior of the usage of --root=<dir>, as the
assumption of what '..' means will usually be incorrect.

Document -root option in README and update valgrind to work with
-root.
2011-06-28 16:01:56 -07:00
Dmitry Kurochkin
273d896097 test: generate run_emacs script once on test startup
Instead of generating auxiliary run_emacs script every time
test_emacs is run, do it once in the beginning of the test.

Also, use absolute paths in the script to make it more robust.
2011-06-28 15:06:47 -07:00
Dmitry Kurochkin
0cc5483a9c test: set variables using let' instead of setq' in Emacs tests
Using `setq' for setting variables in Emacs tests affect other
tests that may run in the same Emacs environment.  Currently it
works because each test is run in a separate Emacs instance.  But
in the future multiple tests will run in a single Emacs instance.
The patch changes all variables to use `let', so the scope of the
change is limited to a single test.
2011-06-28 15:06:47 -07:00
Dmitry Kurochkin
caeb05493d test: wrap and indent test_emacs calls
Most test_emacs calls have long arguments that consist of many
expressions.  Putting them on a single line makes it hard to read
and produces poor diff when they are changed.  The patch puts
every expression in test_emacs calls on a separate line.
2011-06-28 15:06:47 -07:00
Dmitry Kurochkin
dd75723921 test: cleanup test_emacs
Move auxiliary function definition and configuration from command
line to test-lib.el.
2011-06-28 15:06:47 -07:00
Dmitry Kurochkin
5806c471de test: do not set `message-signature' in test_emacs
It is no longer needed since tests are run in a temporary home
directory instead of the user's one.
2011-06-28 15:06:47 -07:00
Pieter Praet
8bb6f7869c fix sum moar typos [comments in source code]
Various typo fixes in comments within the source code.

Signed-off-by: Pieter Praet <pieter@praet.org>

Edited-by: Carl Worth <cworth@cworth.org> Restricted to just
source-code comments, (and fixed fix of "descriptios" to "descriptors"
rather than "descriptions").
2011-06-23 15:58:39 -07:00
Florian Friesdorf
e584c64c5b test: Create and set temporary home directory
In the master branch in test/emacs two tests access the build users home
directory, so does emacs_deliver_message in the crypto branch.

The tests should not touch the build user's home directory. The patch
creates a directory in the temporary test directory and sets home
accordingly.

In case of a non-existent home directory, the tests are failing without
this patch.

Signed-off-by: Jameson Graef Rollins <jrollins@finestructure.net>
2011-06-01 17:46:51 -07:00
Dmitry Kurochkin
59a9c36316 test: copy files in test_expect_equal_file instead of moving them
Before the change, test_expect_equal_file moved files it compared
in case of failure.  The patch changes it to copy the files
instead.  This allows testing non-temporary files which are
stored in git.

Note: the change should not result in new temporary files left
after the tests.  Test_expect_equal_file used to move files only
on failure, so callers had to cleanup them anyway.
2011-05-31 15:10:23 -07:00
Jameson Graef Rollins
627d752501 test: add crypto tests for signature verification and decryption
This adds a new "crypto" test script to the test suite to test
PGP/MIME signature verification and message decryption.  Included here
is a test GNUPGHOME with a test secret key (passwordless), and test
for:

  * signing/verification
  * signing/verification with full owner trust
  * verification with signer key unavailable
  * encryption/decryption
  * decryption failure with missing key
  * encryption/decryption + signing/verfifying
  * reply to encrypted message
  * verification of signature from revoked key

These tests are not expected to pass now, but will as crypto
functionality is included.
2011-05-27 16:22:00 -07:00
Jameson Graef Rollins
18967ef750 test: add notmuch_show_sanitize_all function that is a little more aggressive.
The old notmuch_show_sanitize function only scrubed part of the
filename.  This one scrubs the full filename, as well as the message
id.
2011-05-27 16:18:57 -07:00
Jameson Graef Rollins
b596fbbcd3 test: new test-lib function to test for equality between files
We need to be able to test for the presence of a newline at the end of
output.  There's no good way to capture trailing newlines in bash, so
redirecting output to a file is the next best thing.  This new
function should be used when testing for output that is expected to
have trailing newlines.

The next commit will demonstrate the use of this.
2011-05-27 16:18:57 -07:00
Joel Borggrén-Franck
3fa843216c test: change "#!/bin/bash" to "#!/usr/bin/env bash" enhances portability
Change #!/bin/bash at start of tests to "#!/usr/bin/env bash". That way
systems running on bash < 4 can prepend bash >= 4 to path before
running the tests.
2011-05-27 14:03:28 -07:00
Dmitry Kurochkin
5297b361d1 test: add test-lib.el file with `visible-buffer-string' function
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.
2011-05-26 14:13:48 -07:00
Thomas Schwinge
21e97c50d4 Clarify usage of `additional_headers' in test/test-lib.sh:generate_message.
Signed-off-by: Thomas Schwinge <thomas@schwinge.name>
2011-01-28 15:19:19 +10:00
Carl Worth
ac1ba43666 Fix misspelling in a comment.
Just a simple change I noticed in passing.
2011-01-15 15:37:43 -08:00
Carl Worth
b41aab78f2 test: Leave tmp.<testname> for broken tests
Previously, this directory was only preserved for failing tests. But
it's important to be able to easily debug known-broken tests, so
preserve the actual vs. expected output for those as well.
2010-12-07 16:23:20 -08:00
Austin Clements
04d633c285 Fix handling of broken tests.
Make sure to close the subtest for test_expect_equal_failure, just
like in test_expect_equal.
2010-12-07 16:21:23 -08:00
Michal Sojka
556986511c test: Detect unfinished subsets
When test_begin_subtest is not followed by corresponding test_expect_equal,
the output of the rest of the test script is errornously suppressed. Add
code to detect these bugs in test scripts.
2010-11-16 11:28:06 -08:00
Michal Sojka
c8d51e2912 test: Add trailing newline to error messages
The newline was removed from say_color in commit 222926ab to allow
printing test status in the beginning of the line. Error messages are
never followed by other text so we add the newline to error function.
2010-11-16 11:28:06 -08:00
Michal Sojka
ac9dbb47de test: Better handling of stdout and stderr
Git-style tests (test_expect_success etc.) suppress stdout and stderr
unless -v is given. Notmuch-style tests (created by test_begin_subtest
and test_expect_equal) do not have this behavior so implement it the
same.

Additionally, for both test styles, the test-lib.sh is changed so that
the content of suppressed stdout and stderr is shown in case of failed
test.

Finally a test for this functionality is added to basic tests.
2010-11-16 11:28:06 -08:00
Michal Sojka
736ac42c45 Tests for maildir synchronization
Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
2010-11-10 13:09:32 -08:00
Carl Worth
08c735c58e test: Don't strip portions of test name after '-' for temporary files.
We have test names like maildir-sync now, so it's cleaner if the
temporary files created are named things like maildir-sync-10.out
rather than maildir-10.out. Presumably the extra stripping here came
from naming conventions in git's test suite.
2010-11-10 13:09:31 -08:00
Carl Worth
fd16b37dc1 test: Don't mess with user's HOME directory
This was too rude of a thing to do and could easily introduce
problems, (as reported by Rob Browning whose environment required some
HOME-specific things for shell startup).

Instead, implement more focused changes to ensure that particular file
in $HOME don't cause problems. Specifically, we fix known problems
with ~/.signature and ~/.mailrc here.
2010-11-05 17:43:27 -07:00
Carl Worth
a09921bdfb test: Generate a little run_emacs script to help debug any failures.
After any emacs test failure, the tmp.emacs directory will have this
run_emacs script in it which the user can use to run emacs within the
test suite environment, (pointing at the test suite's notmuch
database, using the local notmuch command-line program, and the local
notmuch emacs lisp code).
2010-11-05 17:19:51 -07:00
Carl Worth
20018a0c09 test: Emit a friendly error message if run with bash < 4.0.
The bash code in the test suite is using associative arrays which were
only added to bash as of release 4.0.

If the test suite is run with an older bash, we now immediately error
out and explain the situation, (instead of emitting confusing error
messages and failing dozens of tests, which is what happened before
this change).
2010-10-28 12:07:42 -07:00
Carl Worth
f30200a429 test: Set alternate HOME during tests.
We set the HOME environment variable to the test directory to avoid
the tests relying on any configuration files from the test author's
own home directory, (such as ${HOME}/.emacs or similar).
2010-10-27 10:40:44 -07:00
Carl Worth
a8aa437bbc test: Add simple tests for navigating notmuch-hello and notmuch-search views
We simulate the act of selecting the "inbox" saved search from
notmuch-hello and the act of selecting a desired thread from the
notmuch-search results.

The test for the navigation of notmuch-hello is currently marked as
BROKEN since its output is in the opposite order compared to the
'(notmuch-search "tag:inbox")' test. This question of ordering is a
currently open issue on the notmuch mailing list, so we'll let the
test suite reflect that for now.

Finally, this commit also abstracts some common emacs lisp code,
(waiting for the current buffer's process to complete), into a new
notmuch-test-wait function that is made available to anything calling
test_emacs.
2010-10-22 17:02:07 -07:00
Carl Worth
6307f306fd test: Add a new test_expect_equal_failure
Which allows us to have a known-broken test that would otherwise use
test_expect_equal.
2010-10-22 17:01:34 -07:00