]> git.notmuchmail.org Git - notmuch/log
notmuch
3 years agoFix typos
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:55 +0000 (13:49 +0200)]
Fix typos

3 years agoemacs: Increase consistency of library headers
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:54 +0000 (13:49 +0200)]
emacs: Increase consistency of library headers

3 years agoemacs: Various cosmetic changes
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:53 +0000 (13:49 +0200)]
emacs: Various cosmetic changes

3 years agoemacs: Autoload notmuch-jump using an autoload cookie
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:52 +0000 (13:49 +0200)]
emacs: Autoload notmuch-jump using an autoload cookie

Doing that is better than using an `autoload' form because the latter
may result in dependencies getting hidden and indeed it turns out we
have to declare `notmuch-jump' in "notmuch-tag.el".

3 years agoemacs: Autoload notmuch-jump-search only once
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:51 +0000 (13:49 +0200)]
emacs: Autoload notmuch-jump-search only once

This function is being autoloaded using an autoload cookie, so it
shouldn't additionally be autoloaded using an `autoload' form.

When building libraries we don't actually load the autoloads file and
dropping the `autoload' form results in an error, which reveals a so
far unspecified dependency: `notmuch-tree' needs `notmuch-jump'.

Before this commit compiling (or even just loading) `notmuch-tree'
resulted in `notmuch-jump' being loaded because the former requires
`notmuch-lib', which autoloaded `notmuch-jump-search'.

The bug was that this dependency was not explicitly specified, which
we fix by adding the respective `require' form.

3 years agoemacs: Improve doc-strings
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:50 +0000 (13:49 +0200)]
emacs: Improve doc-strings

- The first sentence should fit on the first line in full.  This is
  even the case when that causes the line to get a bit long.  If it
  gets very long, then it should be made shorter.

- Even even the second sentence would fit on the first line, if it
  just provides some details, then it shouldn't be done.

- Symbols are quoted like `so'.

- There is no clear rule on how to (not) quote non-atomic
  s-expressions, but quoting like '(this) is definitely weird.

- It is a good idea to remember that \" becomes " and to take
  that in mind when adjusting the automatic filling by hand.

- Use the imperative form.

- Arguments are written in all uppercase.

3 years agoemacs: Use makefile-gmake-mode in Makefile*s
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:49 +0000 (13:49 +0200)]
emacs: Use makefile-gmake-mode in Makefile*s

Use `makefile-gmake-mode' instead of `makefile-mode' because the
former also highlights ifdef et al. while the latter does not.

"./Makefile.global" and one "Makefile.local" failed to specify any
major mode at all but doing so is necessary because Emacs does not
automatically figure out that these are Makefiles (of any flavor).

3 years agoemacs: notmuch-poll: Let the user know we are polling
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:48 +0000 (13:49 +0200)]
emacs: notmuch-poll: Let the user know we are polling

It is done synchronously and it can take a while,
so we should let the user know what is going on.

3 years agoemacs: No longer define notmuch-hello-mode-map as a function
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:47 +0000 (13:49 +0200)]
emacs: No longer define notmuch-hello-mode-map as a function

It was defined as such for a decade; ever since
a56010ac8b89a2489eee5c78469f05cee85ec858 but there
wasn't a reason to do that then nor is there now.

3 years agoemacs: Fix some function declarations
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:46 +0000 (13:49 +0200)]
emacs: Fix some function declarations

3 years agoemacs: Extend face to window edge again
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:45 +0000 (13:49 +0200)]
emacs: Extend face to window edge again

Since Emacs 27 each face has to be explicitly configured to "extend
to the edge of the window".  Without doing that the face used for
the newline character only has an effect that spans "one character"
(i.e. it looks like there is a single trailing space character).

We don't want that so extend the face in Emacs 27, so that it looks
the same as it did in older Emacs releases.  We have to do this
conditionally, otherwise older Emacsen would choke on it.

3 years agoemacs: Use one or three lines for 'if' forms
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:44 +0000 (13:49 +0200)]
emacs: Use one or three lines for 'if' forms

Putting the COND and THEN parts on the same line but ELSE on a
separate line makes it harder to determine if there actually is
an ELSE part.

3 years agoemacs: Use 'when' instead of 'if' when there is no ELSE part
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:43 +0000 (13:49 +0200)]
emacs: Use 'when' instead of 'if' when there is no ELSE part

3 years agoemacs: Use 'unless' instead of 'when' and 'not'
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:42 +0000 (13:49 +0200)]
emacs: Use 'unless' instead of 'when' and 'not'

Also use 'unless' in a few cases where previously 'if' was used with
'not' but without an ELSE part.

3 years agoemacs: Use 'and' instead of 'when' when the return value matters
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:41 +0000 (13:49 +0200)]
emacs: Use 'and' instead of 'when' when the return value matters

Also do so for some 'if' forms that lack an ELSE part.
Even go as far as using 'and' and 'not' instead of 'unless'.

3 years agoemacs: Only set one variable per setq form
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:40 +0000 (13:49 +0200)]
emacs: Only set one variable per setq form

It's a bit weird to avoid having to write the "(setq ... )" more than
once, just because we can.  In a language that uses '=' for the same
purpose we also happily use that once per assignment.

While there are no benefit to using just one 'setq' there are some
drawbacks.  It is not always clear on first what is a key and what a
value and as a result it is easy to make a mistake.  Also it becomes
harder to comment out just one assignment.

3 years agoemacs: Closing parenthesis go on the same line
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:39 +0000 (13:49 +0200)]
emacs: Closing parenthesis go on the same line

3 years agoemacs: Fix indentation
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:38 +0000 (13:49 +0200)]
emacs: Fix indentation

3 years agoemacs: Remove excess empty lines
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:37 +0000 (13:49 +0200)]
emacs: Remove excess empty lines

Most people who write lots of lisp tend to only sparsely use empty
"separator" lines within forms.  In lisp they feel unnecessary and
since most files stick to this convention we get a bit confused
when there are extra empty lines.  It feels like the s-expressions
are falling into pieces.

All of this is especially true between a function's doc-string and
body because the doc-string is colored differently, which visually
already separates it quite sufficiently from the code that follows.

3 years agoemacs: Shorten long lines
Jonas Bernoulli [Sat, 8 Aug 2020 11:49:36 +0000 (13:49 +0200)]
emacs: Shorten long lines

3 years agoEmacs: Ensure left-to-right display for message headers
Teemu Likonen [Fri, 7 Aug 2020 04:46:41 +0000 (07:46 +0300)]
Emacs: Ensure left-to-right display for message headers

In notmuch-show buffer insert invisible U+200E LEFT-TO-RIGHT MARK
character at the beginning of message header paragraph if the From
header contains a right-to-left character. This ensures that the
header paragraph is always rendered in left-to-right mode.

See Emacs Lisp reference manual section "(elisp) Bidirectional
Display" for more info.

3 years agoT355: specify hash algorithm explicitly
Đoàn Trần Công Danh [Mon, 3 Aug 2020 15:40:57 +0000 (22:40 +0700)]
T355: specify hash algorithm explicitly

On some systems (notably, the one shipped with LibreSSL),
default fingerprint digest algorithm is SHA256.

On other systems, users can change default digest algorithm by changing
default_md in /etc/ssl/default_md.

Let's ask openssl to provide us specific algorithm to make the test
more deterministic.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
3 years agoconfigure: drop check for default xapian backend
Đoàn Trần Công Danh [Mon, 3 Aug 2020 15:40:56 +0000 (22:40 +0700)]
configure: drop check for default xapian backend

Starting from xapian 1.3.5, xapian switched default backend to glass.

From 00cdfe10 (build: drop support for xapian versions less than 1.4,
2020-04-22), we only support xapian 1.4.0+. Effectively, we don't need
to check for default xapian backend anymore.

Further more, from 99a7aac8 (test: drop use of db_ending, 2020-07-29),
our test framework has become independence from default xapian.

Let's drop it.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
3 years agoconfigure: check for pytest with python -m pytest
Đoàn Trần Công Danh [Mon, 3 Aug 2020 15:40:55 +0000 (22:40 +0700)]
configure: check for pytest with python -m pytest

On different distro, pytest is suffixed with different patterns.

On the other hand, `python3-pytest' could be invoked correctly,
via `python3 -m pytest', the latter is used by our tests, now.

Switch to `$python -m pytest` to fix address all incompatible naming.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
3 years agotest: regression tests for n_indexopts_{get,set}_decrypt_policy
David Bremner [Sat, 1 Aug 2020 12:26:03 +0000 (09:26 -0300)]
test: regression tests for n_indexopts_{get,set}_decrypt_policy

The main criteria is that they don't crash. Working with a closed
database is a bonus.

3 years agotest: regression test for traversing config list with closed db
David Bremner [Sat, 1 Aug 2020 12:26:02 +0000 (09:26 -0300)]
test: regression test for traversing config list with closed db

Also mention error return in API docs

3 years agotest: regression test for n_d_get_config_list on closed db.
David Bremner [Sat, 1 Aug 2020 12:26:01 +0000 (09:26 -0300)]
test: regression test for n_d_get_config_list on closed db.

Exception is caught.

3 years agotest: regression test for n_directory_{get,set}_mtime
David Bremner [Sat, 1 Aug 2020 12:26:00 +0000 (09:26 -0300)]
test: regression test for n_directory_{get,set}_mtime

The mtime is cached, so closing the db is not a problem. Writing the
mtime throws an exception, which is caught.

3 years agolib: fix return value for n_directory_delete
David Bremner [Sat, 1 Aug 2020 12:25:59 +0000 (09:25 -0300)]
lib: fix return value for n_directory_delete

Falling out of the catch meant the error return was lost

3 years agotest: known broken test for n_directory_delete with closed db.
David Bremner [Sat, 1 Aug 2020 12:25:58 +0000 (09:25 -0300)]
test: known broken test for n_directory_delete with closed db.

There is a return value bug in notmuch_directory_delete that is hiding
the exception.

3 years agolib: catch exceptions in n_directory_get_child_files
David Bremner [Sat, 1 Aug 2020 12:25:57 +0000 (09:25 -0300)]
lib: catch exceptions in n_directory_get_child_files

Also clarify API in error case.

3 years agotest: add known broken test for n_directory_get_child_files
David Bremner [Sat, 1 Aug 2020 12:25:56 +0000 (09:25 -0300)]
test: add known broken test for n_directory_get_child_files

This is a clone of the one for get_child_directories

3 years agolib: catch exceptions in n_directory_get_child_directories
David Bremner [Sat, 1 Aug 2020 12:25:55 +0000 (09:25 -0300)]
lib: catch exceptions in n_directory_get_child_directories

Also clarify API in error case.

3 years agotest: add known broken test for n_directory_get_child_directories
David Bremner [Sat, 1 Aug 2020 12:25:54 +0000 (09:25 -0300)]
test: add known broken test for n_directory_get_child_directories

Start a new test file (for the notmuch_directory_* API group) to hold
this test.

3 years agotest: regression test for n_m_get_filenames
David Bremner [Sat, 1 Aug 2020 12:25:53 +0000 (09:25 -0300)]
test: regression test for n_m_get_filenames

Closing the database after the iterator is created is not a problem.

3 years agotest: split header for lib-message tests.
David Bremner [Sat, 1 Aug 2020 12:25:52 +0000 (09:25 -0300)]
test: split header for lib-message tests.

This allows finer control over when to close the database.

3 years agotest: add regression test for n_messages_collect_tags
David Bremner [Sat, 1 Aug 2020 12:25:51 +0000 (09:25 -0300)]
test: add regression test for n_messages_collect_tags

Also test n_messages_destroy.

3 years agolib: return NULL from n_d_get_default_indexopts on error
David Bremner [Sat, 1 Aug 2020 12:25:50 +0000 (09:25 -0300)]
lib: return NULL from n_d_get_default_indexopts on error

This is a rare and probably serious programming error, so better not
to silently return a default value.

3 years agobuild: upload html docs as part of release process
David Bremner [Thu, 16 Jul 2020 11:11:26 +0000 (08:11 -0300)]
build: upload html docs as part of release process

Use a URL https://notmuchmail.org/doc/latest to leave room for a
future more ambitious scheme deploying multiple versions.

This also forces the html docs to built as part of the release
process. In the future this should be updated to tolerate generating a
release without sphinx installed. This needs a new target analogous to
build-info and build-man that does nothing if sphinx is not installed.

3 years agotest: drop use of db_ending
David Bremner [Thu, 30 Jul 2020 00:01:30 +0000 (21:01 -0300)]
test: drop use of db_ending

This will allow the dropping of the test for the default ending from
configure.

3 years agotest: drop NOTMUCH_DEFAULT_XAPIAN_BACKEND from T360-symbol-test
David Bremner [Thu, 30 Jul 2020 00:01:29 +0000 (21:01 -0300)]
test: drop NOTMUCH_DEFAULT_XAPIAN_BACKEND from T360-symbol-test

Inspired by the suggestion of

         id:20200727154108.16269-3-congdanhqx@gmail.com

to drop the configuration test for the default backend. This version
is hopefully robust against backend changes.

3 years agotest: destroy thread from closed database
David Bremner [Fri, 24 Jul 2020 11:14:06 +0000 (08:14 -0300)]
test: destroy thread from closed database

Check for (non)-crash.

3 years agotest: regression test for n_thread_get_tags
David Bremner [Fri, 24 Jul 2020 11:14:05 +0000 (08:14 -0300)]
test: regression test for n_thread_get_tags

Code is taken from the API docs, with the twist that the underlying
database is closed. Not crashing is the main point.

3 years agotest: add regression tests for oldest and newest dates
David Bremner [Fri, 24 Jul 2020 11:14:04 +0000 (08:14 -0300)]
test: add regression tests for oldest and newest dates

These are strictly to watch for crashes, so don't be too fussy about
the actual timestamps.

3 years agotest: add regression tests for n_t_get_{authors, subject}
David Bremner [Fri, 24 Jul 2020 11:14:03 +0000 (08:14 -0300)]
test: add regression tests for n_t_get_{authors, subject}

This is returning explicitely cached data, so no database access is needed.

3 years agotest: add regression test for n_t_get_messages
David Bremner [Fri, 24 Jul 2020 11:14:02 +0000 (08:14 -0300)]
test: add regression test for n_t_get_messages

This is similar to the case of toplevel messages. Currently everything
is cached, so no database access is necessary. This might change in
the future, but it should not crash in either case.

3 years agotest: add regression tests for n_thread_get_toplevel_messages
David Bremner [Fri, 24 Jul 2020 11:14:01 +0000 (08:14 -0300)]
test: add regression tests for n_thread_get_toplevel_messages

Include a test for the previously omitted non-trivial code path for
notmuch_thread_get_replies.

3 years agotest: add regression test for n_thread_get_total_{messages,files}
David Bremner [Fri, 24 Jul 2020 11:14:00 +0000 (08:14 -0300)]
test: add regression test for n_thread_get_total_{messages,files}

This is returning cached info, so does not need to access the (closed)
database.

3 years agotest: regression test for n_t_get_thread_id
David Bremner [Fri, 24 Jul 2020 11:13:59 +0000 (08:13 -0300)]
test: regression test for n_t_get_thread_id

This is just cached data, so as long as we don't prematurely free
anything, it should be fine.

3 years agotest: regression test for notmuch_query_destroy
David Bremner [Wed, 22 Jul 2020 10:51:27 +0000 (07:51 -0300)]
test: regression test for notmuch_query_destroy

As with other void API entries, not crashing counts as success.

3 years agotest: regression tests for n_q_count_{messages, threads}
David Bremner [Wed, 22 Jul 2020 10:51:26 +0000 (07:51 -0300)]
test: regression tests for n_q_count_{messages, threads}

At least these exceptions are caught.

3 years agotest: regression test for n_q_search_messages
David Bremner [Wed, 22 Jul 2020 10:51:25 +0000 (07:51 -0300)]
test: regression test for n_q_search_messages

Exception handling matches notmuch_query_search_threads, at least for
this case.

3 years agotest: regression test for n_q_search_threads
David Bremner [Wed, 22 Jul 2020 10:51:24 +0000 (07:51 -0300)]
test: regression test for n_q_search_threads

At least this exception is caught.

3 years agotest: add regression test for n_q_add_tag_exclude
David Bremner [Wed, 22 Jul 2020 10:51:23 +0000 (07:51 -0300)]
test: add regression test for n_q_add_tag_exclude

This relies on the change to not tear down the auxilary Xapian
objects, in particular the query parser, when the database is closed.

3 years agotest: regression test for n_q_{set, get}_sort
David Bremner [Wed, 22 Jul 2020 10:51:22 +0000 (07:51 -0300)]
test: regression test for n_q_{set, get}_sort

We just want to make sure accessing the query owned by a closed db
does not cause a crash.

3 years agotest: regression test for set_omit_excluded
David Bremner [Wed, 22 Jul 2020 10:51:21 +0000 (07:51 -0300)]
test: regression test for set_omit_excluded

3 years agotest: regression test for notmuch_query_get_database
David Bremner [Wed, 22 Jul 2020 10:51:20 +0000 (07:51 -0300)]
test: regression test for notmuch_query_get_database

Current functionality is too trivial to really justify a test, but
it's simpler just to test the complete API.

3 years agotest: add regression test for n_q_{create,_get_query_string}
David Bremner [Wed, 22 Jul 2020 10:51:19 +0000 (07:51 -0300)]
test: add regression test for n_q_{create,_get_query_string}

Start a new file of tests, to keep to the (emerging) scheme of one
notmuch_foo group per file

3 years agotest: move notmuch_message_* tests to their own file
David Bremner [Wed, 22 Jul 2020 10:51:18 +0000 (07:51 -0300)]
test: move notmuch_message_* tests to their own file

This is for consistency with the recently added tests for
notmuch_database_*.

3 years agolib: replace use of static_cast for writable databases
David Bremner [Sun, 26 Jul 2020 23:31:36 +0000 (20:31 -0300)]
lib: replace use of static_cast for writable databases

static_cast is a bit tricky to understand and error prone, so add a
second pointer to (potentially the same) Xapian database object that
we know has the right subclass.

3 years agolib: encapsulate the use of notmuch_database_t field 'mode'
David Bremner [Sun, 26 Jul 2020 23:31:35 +0000 (20:31 -0300)]
lib: encapsulate the use of notmuch_database_t field 'mode'

The plan is to change the underlying representation.

3 years agolib: drop two gratuitous assignments to database mode
David Bremner [Sun, 26 Jul 2020 23:31:34 +0000 (20:31 -0300)]
lib: drop two gratuitous assignments to database mode

I'm not sure what the point of modifying that right before destroying
the object is. In a future commit I want to remove that element of the
object, so simplify that task.

3 years agotest: Explicitly state that we want to sign with sender
Jonas Bernoulli [Mon, 27 Jul 2020 15:25:03 +0000 (17:25 +0200)]
test: Explicitly state that we want to sign with sender

Since Emacs 27 'mml-secure-epg-sign' errors out if we don't opt-in to
signing as the sender using 'mml-secure-openpgp-sign-with-sender'.

3 years agotest: Remove misguided emacs testing utilities
Jonas Bernoulli [Mon, 27 Jul 2020 15:25:02 +0000 (17:25 +0200)]
test: Remove misguided emacs testing utilities

The goal of this abstraction was to save space.  But that failed as
the result actually was that four trivial lines got replace with 15
fairly complicated lines.  The opposite of what it was supposed to
do.

Also it made it harder to come up with the fix in the previous commit;
simply grepping for the relevant symbols did not work because they get
constructed at run-time instead of appearing in the source file.

3 years agotest: Deal with Emacs 27 switching to lexical scope by default
Jonas Bernoulli [Mon, 27 Jul 2020 15:25:01 +0000 (17:25 +0200)]
test: Deal with Emacs 27 switching to lexical scope by default

Starting with Emacs 27 undeclared variables in evaluated interactive
code uses lexical scope.  This includes code passed with '--eval' as
we do in the Emacs tests, which also happen to assume dynamic scope.

- This can affect variables defined by libraries that we use.  We
  let-bind such variables to change the behavior of functions which we
  then call with these bindings in effect.  If these libraries are not
  loaded beforehand, then the bindings are lexical and fail to have
  the effect we intended.

  At this time only 'smtpmail' has to be loaded explicitly (for the
  variables let-bound in emacs_deliver_message and emacs_fcc_message).

  'message' doesn't have to be loaded explicitly, because loading
  'notmuch' (in 'run_emacs') already takes care of that, indirectly.

- Our own testing-only variables also have to be declared explicitly.
  We should have done that anyway, but because of how and where these
  variables are used it was very easy to overlook that (i.e. it isn't
  something the byte-compiler ever looks at).  Not so in Emacs 27
  anymore; here this oversight caused four tests to fail.

  The numeric values of these variables get incremented by functions
  that we add to hooks that are run by many tests, not just the tests
  where we actually inspect the value and therefore take care to let-
  bind the values to 0 before we begin.  The global values therefore
  have to be numeric values as well.  I have chosen -100 instead of 0
  as the default in case someone writes a test that inspects the value
  but forgets to let-bind the value.  I hope that the unusual negative
  value that one is going to see in such a case will help debugging
  the issue.

3 years agogitignore: Ignore generated sphinx.config
Jonas Bernoulli [Mon, 27 Jul 2020 15:25:00 +0000 (17:25 +0200)]
gitignore: Ignore generated sphinx.config

3 years agotest: add known broken test for n_d_get_default_indexopts
David Bremner [Sun, 19 Jul 2020 13:11:13 +0000 (10:11 -0300)]
test: add known broken test for n_d_get_default_indexopts

Xapian exceptions are swallowed and turned into default return value.

3 years agolib: fix error return bug with n_d_set_config.
David Bremner [Sun, 19 Jul 2020 12:51:03 +0000 (09:51 -0300)]
lib: fix error return bug with n_d_set_config.

The catch block either needs to return, or the function needs to
return "status". Choose the latter for consistency with
n_d_get_config.

3 years agotest: add known broken test for n_d_set_config
David Bremner [Sun, 19 Jul 2020 12:44:05 +0000 (09:44 -0300)]
test: add known broken test for n_d_set_config

Error status is currently lost.

3 years agotest: add regression test for n_d_get_config
David Bremner [Sun, 19 Jul 2020 12:39:16 +0000 (09:39 -0300)]
test: add regression test for n_d_get_config

Xapian exceptions seem to handled OK, at least for this case.

3 years agolib: add regresion test for n_d_get_all_tags
David Bremner [Sun, 19 Jul 2020 10:57:39 +0000 (07:57 -0300)]
lib: add regresion test for n_d_get_all_tags

Existing error handling seems adequate, if not ideal.

3 years agolib: add regression test for n_d_find_message_by_filename
David Bremner [Sun, 19 Jul 2020 10:43:36 +0000 (07:43 -0300)]
lib: add regression test for n_d_find_message_by_filename

At least this Xapian exception is caught. Make sure it stays that way.

3 years agolib: rename _n_d_create to _n_d_find_or_create
David Bremner [Sun, 19 Jul 2020 10:36:47 +0000 (07:36 -0300)]
lib: rename _n_d_create to _n_d_find_or_create

The error message and name were confusing when called in some "read
only" context.

3 years agotest: add known broken test for notmuch_database_remove_message
David Bremner [Sun, 19 Jul 2020 10:13:06 +0000 (07:13 -0300)]
test: add known broken test for notmuch_database_remove_message

The current error message is a bit confusing; fix in next commit.

3 years agolib: convert relative filenames to absolute in n_d_index_file
David Bremner [Sun, 19 Jul 2020 00:11:28 +0000 (21:11 -0300)]
lib: convert relative filenames to absolute in n_d_index_file

The API docs promise to handle relative filenames, but the code did
not do it.

Also check for files outside the mail root, as implied by the API
description.

This fixes the bug reported at

     id:87sgdqo0rz.fsf@tethera.net

3 years agotest: add known broken test for indexing relative path
David Bremner [Fri, 17 Jul 2020 11:02:14 +0000 (08:02 -0300)]
test: add known broken test for indexing relative path

The current code seems to look for the path relative to the current
working directory, rather than the mail store root.

3 years agotest: regression test for n_d_index_file closed db
David Bremner [Fri, 17 Jul 2020 10:51:24 +0000 (07:51 -0300)]
test: regression test for n_d_index_file closed db

Current exception handling seems OK, at least for this case.

3 years agotest: add regression test for n_d_get_directory
David Bremner [Fri, 17 Jul 2020 10:38:09 +0000 (07:38 -0300)]
test: add regression test for n_d_get_directory

At least this exception is already handled correctly.

3 years agotest: regression test for n_d_get_revision
David Bremner [Thu, 16 Jul 2020 23:04:12 +0000 (20:04 -0300)]
test: regression test for n_d_get_revision

This function only accesses data cached by notmuch, so being closed is
not a problem.

3 years agotest: add regression test for n_d_{begin,end}_atomic
David Bremner [Thu, 16 Jul 2020 22:48:19 +0000 (19:48 -0300)]
test: add regression test for n_d_{begin,end}_atomic

Xapian currently succeeds to begin/end a transaction on a closed database,
or at least does not throw an exception. Make the test robust against
this changing.

3 years agotest: regression test for n_d_upgrade
David Bremner [Thu, 16 Jul 2020 22:34:02 +0000 (19:34 -0300)]
test: regression test for n_d_upgrade

The logic is that if it's acceptable to return SUCCESS for read only
database, it's acceptable for a closed one.

3 years agolib/n_d_needs_upgrade: handle error return from n_d_get_version
David Bremner [Thu, 16 Jul 2020 22:28:22 +0000 (19:28 -0300)]
lib/n_d_needs_upgrade: handle error return from n_d_get_version

Also clarify documentation of error return from n_d_needs_upgrade.

3 years agotest: add known broken test for n_d_needs_upgrade
David Bremner [Thu, 16 Jul 2020 22:22:05 +0000 (19:22 -0300)]
test: add known broken test for n_d_needs_upgrade

It's a bit arbitrary which value to return for errors, but the same
argument as for read only databases applies for errors.

3 years agotest: add regression tests for notmuch database destroy
David Bremner [Thu, 16 Jul 2020 02:05:54 +0000 (23:05 -0300)]
test: add regression tests for notmuch database destroy

Either an open or closed database should be ok to destroy

3 years agotest: regression test for closing a closed database
David Bremner [Thu, 16 Jul 2020 01:59:58 +0000 (22:59 -0300)]
test: regression test for closing a closed database

This does not currently throw an error, and it should stay that way.

3 years agolib/n_d_get_version: catch exceptions and clarify the API
David Bremner [Tue, 14 Jul 2020 22:31:10 +0000 (19:31 -0300)]
lib/n_d_get_version: catch exceptions and clarify the API

notmuch_database_get_version previously returned 0 on some errors, but
did not document this. Luckily 0 is not a valid database version.

3 years agolib: move deallocation of memory from n_d_close to n_d_destroy
David Bremner [Tue, 14 Jul 2020 11:25:28 +0000 (08:25 -0300)]
lib: move deallocation of memory from n_d_close to n_d_destroy

In order to mimic the "best effort" API of Xapian to provide
information from a closed database when possible, do not
destroy the Xapian database object too early.

Because the pointer to a Xapian database is no longer nulled on close,
introduce a flag to track whether the notmuch database is open or not.

3 years agotest: add known broken test for n_d_get_version on closed db
David Bremner [Tue, 14 Jul 2020 00:30:52 +0000 (21:30 -0300)]
test: add known broken test for n_d_get_version on closed db

This should not crash, but it does currently.

3 years agotest: regression tests for n_d_status_string and n_d_get_path
David Bremner [Tue, 14 Jul 2020 00:21:03 +0000 (21:21 -0300)]
test: regression tests for n_d_status_string and n_d_get_path

These do not crash on a closed database, and we want to keep it that
way.

Start a new file of tests as T560-lib-error was starting to get unwieldy.

3 years agolib: fix exception messages for n_m_message_*
David Bremner [Wed, 22 Jul 2020 11:19:28 +0000 (08:19 -0300)]
lib: fix exception messages for n_m_message_*

The original generic handler had an extra '%s' in the format
string. Update tests that failed to catch this because the template to
print status strings checked 'stat', which was not set.

3 years agotest: sanitize line numbers in exception reports
David Bremner [Wed, 22 Jul 2020 11:35:42 +0000 (08:35 -0300)]
test: sanitize line numbers in exception reports

Prevent test suite churn when reported line numbers change.

3 years agoemacs: notmuch-search: avoid wiping out buffer-local variables
Sean Whitton [Wed, 22 Jul 2020 15:11:32 +0000 (08:11 -0700)]
emacs: notmuch-search: avoid wiping out buffer-local variables

3 years agolib: fix return value for n_m_reindex
David Bremner [Thu, 9 Jul 2020 00:17:09 +0000 (21:17 -0300)]
lib: fix return value for n_m_reindex

Also update the documentation for the behaviour of n_m_get_thread_id
that this fix relies on.

3 years agotest: add known broken test for n_m_reindex on closed db
David Bremner [Thu, 9 Jul 2020 00:17:08 +0000 (21:17 -0300)]
test: add known broken test for n_m_reindex on closed db

This is another case where the code should not call INTERNAL_ERROR.

3 years agotest: regression for retrieving closed db from message
David Bremner [Thu, 9 Jul 2020 00:17:07 +0000 (21:17 -0300)]
test: regression for retrieving closed db from message

This is actually one of the few potentially useful things you can do
with a message belonging to a closed database, since in principle you
could re-open the database.

3 years agotest: regression test for destroying message with closed db
David Bremner [Thu, 9 Jul 2020 00:17:06 +0000 (21:17 -0300)]
test: regression test for destroying message with closed db

This should be fine because the message belongs to the
database (talloc context wise).

3 years agotest: regression tests of n_m_freeze and n_m_thaw on closed db
David Bremner [Thu, 9 Jul 2020 00:17:05 +0000 (21:17 -0300)]
test: regression tests of n_m_freeze and n_m_thaw on closed db

Neither of these accesses the database, so should be safe. Add the
tests to catch any changes in exception throwing.

3 years agolib: handle xapian exception in n_m_remove_all_tags
David Bremner [Thu, 9 Jul 2020 00:17:04 +0000 (21:17 -0300)]
lib: handle xapian exception in n_m_remove_all_tags

At least the exception we already catch should be reported properly.

3 years agotest: add broken test for n_m_remove_all_tags
David Bremner [Thu, 9 Jul 2020 00:17:03 +0000 (21:17 -0300)]
test: add broken test for n_m_remove_all_tags

The Xapian exception is actually caught here, but the NULL return is
not dealt with properly.

3 years agotest: add regression test for n_m_maildir_flags_to_tags
David Bremner [Thu, 9 Jul 2020 00:17:02 +0000 (21:17 -0300)]
test: add regression test for n_m_maildir_flags_to_tags

This function currently catches at least the obvious Xapian exceptions
and we want to keep it that way.