Commit graph

850 commits

Author SHA1 Message Date
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
71f1228a51 Merge branch 'release'
Merge changes for notmuch-insert error handling, debian bugfix release
2016-12-07 07:30:12 -04:00
David Bremner
d74c534570 cli/insert: return EX_TEMPFAIL for some errors
Attempt to distinguish between errors indicating misconfiguration or
programmer error, which we consider "permanent", in the sense that
automatic retries are unlikely to be useful, and those indicating
transient error conditions. We consider XAPIAN_EXCEPTION transient
because it covers the important special case of locking failure.
2016-12-07 07:00:40 -04:00
Tomi Ollila
27e293f653 test: gdb insert: redirect input inside gdb script
Running `gdb command < input` is not as reliable way to give input
to the command (some installations of gdb consume it). Use "set args"
gdb command to have input redirected at gdb 'run' time.
2016-12-07 07:00:39 -04:00
Jani Nikula
e682c8f8f8 test: check the handling of files vanishing between scandir and indexing
Add a file for scandir to find, but use gdb to remove it before it
gets indexed.
2016-12-03 07:18:49 -04:00
David Bremner
f781b7e7d2 test: clean up corpora.email
When we renamed corpus to corpora, we missed a spot.
2016-12-03 07:16:12 -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
Mark Walters
70c6ac377b Test: fix draft test for emacs23
emacs24 and emacs23 have different secure tag defaults: in particular,
mml-secure-message-sign only signs the part on emacs23 but the whole
message on emacs24. This difference makes one of the draft tests fail
(which causes a cascade of later failures) on emacs23. It seems that
travis uses emacs23 so it is useful to fix this.

We do this by forcing the whole message to be signed in either case --
the code snippet is extracted from mml-secure-message-sign on emacs24.
2016-11-14 18:01:36 -04:00
David Bremner
2dd96d6bd6 emacs: resume messages
Provide functionality to resume editing a message previously saved with
notmuch-draft-save, including decoding the X-Notmuch-Emacs-Secure
header.

Resume gets the raw file from notmuch and using the emacs function
mime-to-mml reconstructs the message (including attachments).

'e' is bound to resume a draft from show or tree mode.
2016-11-13 13:15:31 -04:00
David Bremner
90248f862b emacs: check drafts for encryption tags before saving
In general the user may not want to save plaintext copies of messages
that they are sending encrypted, so give them a chance to abort.
2016-11-13 13:15:31 -04:00
Mark Walters
d820b97477 emacs: postpone a message
This provides initial support for postponing in the emacs frontend;
resuming will follow in a later commit. On saving/postponing it uses
notmuch insert to put the message in the notmuch database

Current bindings are C-x C-s to save a draft, C-c C-p to postpone a
draft (save and exit compose buffer).

Previous drafts get tagged deleted on subsequent saves, or on the
message being sent.

Each draft gets its own message-id, and we use the namespace
draft-.... for draft message ids (so, at least for most people, drafts
are easily distinguisable).
2016-11-13 12:55:24 -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
David Bremner
d93e9cee13 Merge in test-suite, docstring fixes, release prep 2016-10-22 12:44:39 -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
David Bremner
169e29d431 test: add known broken test for nondestructiveness of count
Thanks to Lucas (id:147263183913.27784.12274024193186585889@mbp) for the
bug report and the test case.

I decided to use the python version because the python bindings could
use more exercise.
2016-10-15 10:22:40 -03:00
Tomi Ollila
6a3ce94aaf test/T000-basic: replaced use of which(1) with shell builtin command -v
Some minimal chroot/container environments don't have which(1) installed.
2016-10-11 22:43:17 -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
David Bremner
5292e9b1ae test/emacs: add broken test for message replying to msg to self
This is a strange corner case where the removing of the user's address
from the To: header does the wrong thing. If we think it is
worth (eventually) fixing, this test can serve as a reminder.
2016-09-24 10:05:04 -03:00
David Bremner
1d4812fd61 test: fix printf format
notmuch_status_t is an integer type, printing it as a string is a very
bad idea.
2016-09-22 08:11:42 -03:00
Daniel Kahn Gillmor
693ca8d8a8 add property: query prefix to search for specific properties
We want to be able to query the properties directly, like:

   notmuch count property:foo=bar

which should return a count of messages where the property with key
"foo" has value equal to "bar".
2016-09-21 18:14:25 -03:00
David Bremner
651da30c09 cli: optionally restore message properties from dump file
This somewhat mimics the config line parsing, except there can be
arbitrarily many key value pairs, so one more level of looping is
required.
2016-09-21 18:14:25 -03:00
David Bremner
b7345d277e CLI: add properties to dump output
Part of providing extensibility via properties is to make sure that user
data is not lost. Thus we need to be able to dump and restore
properties.
2016-09-21 18:14:25 -03:00
David Bremner
58fe8fce1d lib: iterator API for message properties
This is a thin wrapper around the string map iterator API just introduced.
2016-09-21 18:14:25 -03:00
David Bremner
b8bb6d7964 lib: basic message-property API
Initially, support get, set and removal of single key/value pair, as
well as removing all properties.
2016-09-21 18:14:24 -03:00
Jani Nikula
a63e674b34 test: silence the output of notmuch new mid-test
Fix this during test run:

T470-missing-headers: Testing messages with missing headers
Added 2 new messages to the database.
2016-09-19 20:42:09 -03:00
Mark Walters
a448879e49 emacs: reply: remove wrong sig/enc status buttons
This stops the (usually incorrect) sigstatus and encstatus buttons
appearing when replying in emacs, and updates the test suite to match.

Overriding the status button functions is a little unusual but much
less intrusive than passing an argument all the way down the call
chain. It also makes it clear exactly what it does.

We also hide the application/pgp-encrypted part as it can only contain
"Version: 1". We do this in notmuch show, which means it also happens
when replying.
2016-09-18 10:57:27 -03:00
David Bremner
653c5ee221 test/crypto: test reply to encrypted message in emacs
This test considers the extra output about encryption/signature status
as a bug, to be fixed in the next commit
2016-09-18 10:56:54 -03:00
Jani Nikula
536b1f9df9 cli/reply: return internet address list from get header funcs
Pass in GMimeMessage to simplify To/Cc/Bcc headers. We'll eventually
remove the notmuch message passing altogether, but keep both for now
to not make too big changes at once.

Getting the headers from GMimeMessage using GMime functions fixes the
error on duplicate Cc headers reported by Daniel Kahn Gillmor
<dkg@fifthhorseman.net> in id:87d1ngv95p.fsf@alice.fifthhorseman.net.

Get rid of an intermediate function.

The small annoyance is the ownership differences in the address lists.
2016-09-17 09:11:07 -03:00
Jani Nikula
36416c74e0 test: add known broken test for reply to message with multiple Cc headers
As Daniel Kahn Gillmor <dkg@fifthhorseman.net> reports in
id:87d1ngv95p.fsf@alice.fifthhorseman.net, notmuch show combines
multiple Cc: fields into one, while notmuch reply does not. While such
messages are in violation of RFC 5322, it would be reasonable to
expect notmuch to be consistent. Add a known broken test to document
this expectation.

This also starts a new "broken" corpus for messages which are broken.

Details:

The original message is formatted using the message printing in
notmuch-show.c. For Cc:, it uses g_mime_message_get_recipients(),
which apparently combines all Cc: fields into one internally.

The addresses in the reply headers, OTOH, are based on headers queried
through libnotmuch. It boils down to g_mime_object_get_header() in
lib/message-file.c, which returns only the first occurence of header.
2016-09-17 08:41:29 -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
07dff49630 Merge branch 'release'
hand fixed conflicts with NEWS
2016-09-08 22:18:37 -03:00
David Bremner
7edded2740 test/crypto: hard code fingerprint
Originally the intent was to make the test more robust against changing
test keys. It turns out that (unscientifically) gpg --with-colons output
changes more often than our test key. Rather than making the script more
complex, just hard code the fingerprint.

This fixes Debian bug #847013; I expect similar test failures as other
distros adopt gnupg 2.1.15
2016-09-08 09:08:09 -03:00
Mark Walters
fce8146a8b emacs: maildir: add the actual insert code
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-09-04 08:23:14 -03:00
David Bremner
cf8aabdd37 test: make gdb even quieter
gdb sometimes writes warnings to stdout, which we don't need/want, and
for some reason --batch-silent isn't enough to hide. So in this commit
we write them to a log file, which is probably better for debugging
anyway. To see an illustrative test failure before this change, run

% make
% touch notmuch-count.c
% cd test && ./T060-count.sh

(cherry picked from commit f45fa5bdd3)
2016-08-14 13:27:57 +09:00
Daniel Kahn Gillmor
1ba73d1437 Omit User-Agent: header by default
The User-Agent: header can be fun and interesting, but it also leaks
quite a bit of information about the user and their software stack.

This represents a potential security risk (attackers can target the
particular stack) and also an anonymity risk (a user trying to
preserve their anonymity by sending mail from a non-associated account
might reveal quite a lot of information if their choice of mail user
agent is exposed).

This change also avoids hiding the User-Agent header by default, so
that people who decide they want to send it will at least see it (and
can edit it if they want to) before sending.

It makes sense to have safer defaults.
2016-08-11 20:16:00 +09:00
Mark Walters
999d473299 emacs: wash: word-wrap bugfix
Previously notmuch-wash made the width of the text (approximately) the
window-width minus the depth in thread. This is correct for the
default indentation of 1 per message depth, but is incorrect for any
other setting of notmuch-show-indent-messages-width.

As notmuch-show-indent-messages-width is customisable, and notmuch-tree
sets it to zero to avoid indenting messages in the message pane, this
bug can show up in real use.

Two of the tests had to be updated: when
notmuch-show-indent-messages-width is 0, then the new (correct) word
wrapping happens later, when notmuch-show-indent-messages-width is 4,
then the new word wrapping happens sooner.
2016-08-09 09:34:25 +09:00
David Bremner
f45fa5bdd3 test: make gdb even quieter
gdb sometimes writes warnings to stdout, which we don't need/want, and
for some reason --batch-silent isn't enough to hide. So in this commit
we write them to a log file, which is probably better for debugging
anyway. To see an illustrative test failure before this change, run

% make
% touch notmuch-count.c
% cd test && ./T060-count.sh
2016-08-09 09:33:59 +09:00
David Bremner
48d33532bb test: don't use dump and restore in a pipeline
This has been wrong since bbbdf0478e, but the race condition was not
previously been (often?) triggered in the tests. With the DB_RETRY_LOCK
patches, it manifests itself as a deadlock.
2016-06-30 17:47:36 +02:00
David Bremner
3a45d29ed4 lib: add built_with handling for XAPIAN_DB_RETRY_LOCK
This support will be present only if the appropriate version of xapian
is available _and_ the user did not disable the feature when
building. So there really needs to be some way for the user to check.
2016-06-29 09:05:49 +02:00
David Bremner
6450813e8f test: initial tests for locking retry
Currently there's not much to test, so we simulate contention, and check
that the modifications to the database are serialized.
2016-06-29 09:05:28 +02:00
David Bremner
496dccf44f test: don't use dump and restore in a pipeline
This has been wrong since bbbdf0478e, but the race condition was not
previously been (often?) triggered in the tests. With the DB_RETRY_LOCK
patches, it manifests itself as a deadlock.
2016-06-29 09:03:14 +02:00
Tomi Ollila
be55acf4f0 test/notmuch-test: simple streamlining
A few simple things that applies well to test/notmuch-test.sh

- Shell does pathname expansion also without doing `echo ...` in subshell.

- Redirections >/dev/null 2>/dev/null hide (improbable but) potential
  serious errors; adding -f to rm instead.

- Inter-file capitalization consistency in comments.

- Unnecesary space removal.
2016-06-28 09:23:39 +02: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
36492f20a7 test: fix die() in test-lib-common.sh
In scripts that include test-lib-common.sh but not test-lib.sh
the die() implementation needs to be a bit different due to
fd redirection differences. test-lib-common.sh implements die()
only if it was not implemented already.
2016-06-11 13:03:44 -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