Jonas Bernoulli
c454135376
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).
2020-08-09 21:14:36 -03:00
Jonas Bernoulli
e1a700067a
emacs: Use 'when' instead of 'if' when there is no ELSE part
2020-08-09 20:52:34 -03:00
Jonas Bernoulli
09f6533c37
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.
2020-08-09 20:51:26 -03:00
Jonas Bernoulli
caaa108760
emacs: Fix indentation
2020-08-09 20:48:09 -03:00
Đoàn Trần Công Danh
f5ae8040b3
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>
2020-08-08 16:04:27 -03:00
David Bremner
0e4695abaa
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.
2020-08-03 21:05:29 -03:00
David Bremner
e3f88436b7
test: regression test for traversing config list with closed db
...
Also mention error return in API docs
2020-08-03 21:03:43 -03:00
David Bremner
a0b2a54aa7
test: regression test for n_d_get_config_list on closed db.
...
Exception is caught.
2020-08-03 21:01:53 -03:00
David Bremner
e8ffbf84ff
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.
2020-08-03 21:00:25 -03:00
David Bremner
f4f5db0f1a
lib: fix return value for n_directory_delete
...
Falling out of the catch meant the error return was lost
2020-08-03 20:59:06 -03:00
David Bremner
b03cc6cf90
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.
2020-08-03 20:57:43 -03:00
David Bremner
337665e26a
lib: catch exceptions in n_directory_get_child_files
...
Also clarify API in error case.
2020-08-03 20:56:09 -03:00
David Bremner
3890d98966
test: add known broken test for n_directory_get_child_files
...
This is a clone of the one for get_child_directories
2020-08-03 20:54:26 -03:00
David Bremner
9668583a49
lib: catch exceptions in n_directory_get_child_directories
...
Also clarify API in error case.
2020-08-03 20:53:04 -03:00
David Bremner
919b89156c
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.
2020-08-03 20:51:40 -03:00
David Bremner
c151506773
test: regression test for n_m_get_filenames
...
Closing the database after the iterator is created is not a problem.
2020-08-03 20:50:15 -03:00
David Bremner
2b6e73d895
test: split header for lib-message tests.
...
This allows finer control over when to close the database.
2020-08-03 20:48:51 -03:00
David Bremner
e5e17926db
test: add regression test for n_messages_collect_tags
...
Also test n_messages_destroy.
2020-08-03 20:47:18 -03:00
David Bremner
31dab9b1cd
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.
2020-08-03 20:45:58 -03:00
David Bremner
99a7aac8f2
test: drop use of db_ending
...
This will allow the dropping of the test for the default ending from
configure.
2020-08-01 20:27:30 -03:00
David Bremner
29a58ecf4a
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.
2020-07-31 21:30:06 -03:00
David Bremner
00f48f397a
test: destroy thread from closed database
...
Check for (non)-crash.
2020-07-31 07:41:00 -03:00
David Bremner
864f422f14
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.
2020-07-31 07:41:00 -03:00
David Bremner
43406e7d4c
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.
2020-07-31 07:41:00 -03:00
David Bremner
c5017c76d9
test: add regression tests for n_t_get_{authors, subject}
...
This is returning explicitely cached data, so no database access is needed.
2020-07-31 07:41:00 -03:00
David Bremner
70b30066f6
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.
2020-07-31 07:41:00 -03:00
David Bremner
6ccc4338a4
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.
2020-07-31 07:41:00 -03:00
David Bremner
02ab473115
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.
2020-07-31 07:41:00 -03:00
David Bremner
0baa581e6e
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.
2020-07-31 07:41:00 -03:00
David Bremner
46468baa5a
test: regression test for notmuch_query_destroy
...
As with other void API entries, not crashing counts as success.
2020-07-29 12:20:41 -03:00
David Bremner
451c0ce3fc
test: regression tests for n_q_count_{messages, threads}
...
At least these exceptions are caught.
2020-07-29 12:20:30 -03:00
David Bremner
0a4c6cdeb1
test: regression test for n_q_search_messages
...
Exception handling matches notmuch_query_search_threads, at least for
this case.
2020-07-29 12:20:22 -03:00
David Bremner
25fc8662ed
test: regression test for n_q_search_threads
...
At least this exception is caught.
2020-07-29 12:20:14 -03:00
David Bremner
4130b4e514
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.
2020-07-29 12:20:06 -03:00
David Bremner
d5c84c8289
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.
2020-07-29 12:19:57 -03:00
David Bremner
a292461e65
test: regression test for set_omit_excluded
2020-07-29 12:19:48 -03:00
David Bremner
768efe88d0
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.
2020-07-29 12:19:39 -03:00
David Bremner
cbf9f890aa
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
2020-07-29 12:19:09 -03:00
David Bremner
85da95e266
test: move notmuch_message_* tests to their own file
...
This is for consistency with the recently added tests for
notmuch_database_*.
2020-07-29 12:18:11 -03:00
Jonas Bernoulli
8b162b40f8
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'.
2020-07-28 08:40:30 -03:00
Jonas Bernoulli
7b752e9eb4
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.
2020-07-28 08:39:58 -03:00
Jonas Bernoulli
d5d8846c32
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.
2020-07-28 08:39:44 -03:00
David Bremner
24cf4381b8
test: add known broken test for n_d_get_default_indexopts
...
Xapian exceptions are swallowed and turned into default return value.
2020-07-22 19:52:55 -03:00
David Bremner
b268c8c071
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.
2020-07-22 19:52:55 -03:00
David Bremner
f6d74be840
test: add known broken test for n_d_set_config
...
Error status is currently lost.
2020-07-22 19:52:55 -03:00
David Bremner
a5e13d5218
test: add regression test for n_d_get_config
...
Xapian exceptions seem to handled OK, at least for this case.
2020-07-22 19:52:55 -03:00
David Bremner
dfab190a40
lib: add regresion test for n_d_get_all_tags
...
Existing error handling seems adequate, if not ideal.
2020-07-22 19:52:55 -03:00
David Bremner
64aa896151
lib: add regression test for n_d_find_message_by_filename
...
At least this Xapian exception is caught. Make sure it stays that way.
2020-07-22 19:52:55 -03:00
David Bremner
ce360ce4c9
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.
2020-07-22 19:52:55 -03:00
David Bremner
97c887282a
test: add known broken test for notmuch_database_remove_message
...
The current error message is a bit confusing; fix in next commit.
2020-07-22 19:52:55 -03:00
David Bremner
c477d7ce31
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
2020-07-22 19:52:55 -03:00
David Bremner
be3f4aec3f
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.
2020-07-22 19:52:55 -03:00
David Bremner
9ab3e2e77d
test: regression test for n_d_index_file closed db
...
Current exception handling seems OK, at least for this case.
2020-07-22 19:52:55 -03:00
David Bremner
1ca805a962
test: add regression test for n_d_get_directory
...
At least this exception is already handled correctly.
2020-07-22 19:52:55 -03:00
David Bremner
959cb4b7a7
test: regression test for n_d_get_revision
...
This function only accesses data cached by notmuch, so being closed is
not a problem.
2020-07-22 19:52:55 -03:00
David Bremner
bcb02dd8fc
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.
2020-07-22 19:52:55 -03:00
David Bremner
3f121d636e
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.
2020-07-22 19:52:55 -03:00
David Bremner
f25fc8e211
lib/n_d_needs_upgrade: handle error return from n_d_get_version
...
Also clarify documentation of error return from n_d_needs_upgrade.
2020-07-22 19:52:55 -03:00
David Bremner
cf90431cbf
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.
2020-07-22 19:52:55 -03:00
David Bremner
37dc6045e4
test: add regression tests for notmuch database destroy
...
Either an open or closed database should be ok to destroy
2020-07-22 19:52:55 -03:00
David Bremner
964e783fd4
test: regression test for closing a closed database
...
This does not currently throw an error, and it should stay that way.
2020-07-22 19:52:55 -03:00
David Bremner
ab45654192
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.
2020-07-22 19:52:55 -03:00
David Bremner
920dc56e60
test: add known broken test for n_d_get_version on closed db
...
This should not crash, but it does currently.
2020-07-22 19:52:55 -03:00
David Bremner
f3a56b5f6d
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.
2020-07-22 19:52:55 -03:00
David Bremner
e9867b818b
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.
2020-07-22 19:52:55 -03:00
David Bremner
1a8060b81f
test: sanitize line numbers in exception reports
...
Prevent test suite churn when reported line numbers change.
2020-07-22 19:52:55 -03:00
David Bremner
765ca7bc08
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.
2020-07-20 08:54:42 -03:00
David Bremner
a0c83e1fac
test: add known broken test for n_m_reindex on closed db
...
This is another case where the code should not call INTERNAL_ERROR.
2020-07-20 08:54:42 -03:00
David Bremner
a2279c322e
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.
2020-07-20 08:54:42 -03:00
David Bremner
1578e2af6a
test: regression test for destroying message with closed db
...
This should be fine because the message belongs to the
database (talloc context wise).
2020-07-20 08:54:42 -03:00
David Bremner
9244f58860
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.
2020-07-20 08:54:42 -03:00
David Bremner
a2b90dc084
lib: handle xapian exception in n_m_remove_all_tags
...
At least the exception we already catch should be reported properly.
2020-07-20 08:54:42 -03:00
David Bremner
a4ac9941a8
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.
2020-07-20 08:54:42 -03:00
David Bremner
e32f66d0e3
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.
2020-07-20 08:54:42 -03:00
David Bremner
b7572ceb14
lib: add notmuch_message_has_maildir_flag_st
...
Initially the new function is mainly tested indirectly via the
wrapper.
2020-07-20 08:54:42 -03:00
David Bremner
b21f0fcb6a
test: add regression test for notmuch_message_has_maildir_flag
...
This passes the NULL return inside _ensure_maildir_flags does not
break anything. Probably this should be handled more explicitely.
2020-07-20 08:45:15 -03:00
David Bremner
2d04ed2631
lib: catch exceptions in n_m_get_flag, provide n_m_get_flag_st
...
It's not very nice to return FALSE for an error, so provide
notmuch_message_get_flag_st as a migration path.
Bump LIBNOTMUCH_MINOR_VERSION because the API is extended.
2020-07-18 09:52:27 -03:00
David Bremner
aa8e3f4487
lib: catch Xapian exceptions in n_m_remove_tag
...
The churn here is again mainly re-indentation.
2020-07-14 07:31:45 -03:00
David Bremner
0fc769aa4f
test: add broken test for n_m_remove_tag
...
Exception will be caught in next commit.
2020-07-14 07:31:45 -03:00
David Bremner
33dd5fdc69
lib: catch Xapian exceptions in n_m_add_tag
...
This is mostly just (horizontal) code movement due to wrapping
everything in a try / catch.
2020-07-14 07:31:45 -03:00
David Bremner
503c035077
test: add known broken test for n_m_add_tag with closed db
...
Exception will be caught in next commit.
2020-07-14 07:31:45 -03:00
David Bremner
96befd0dd0
lib: catch Xapian exceptions in n_m_count_files
...
This will require some care for the caller to check the sign, and not
just add error returns into a running total.
2020-07-14 07:31:37 -03:00
David Bremner
6dc62d8bea
test: add known broken test for n_m_count_files
...
This will be fixed in the next commit.
2020-07-14 07:31:30 -03:00
David Bremner
00f1abfdf4
lib: catch Xapian exceptions in n_m_get_tags
...
This allows the function to return an error value rather than
crashing.
2020-07-14 07:12:52 -03:00
David Bremner
d284dc00da
test: add known broken test for n_m_get_tags
...
This will be fixed in the next commit.
2020-07-14 07:12:52 -03:00
David Bremner
6eaadb43ad
lib: add regression test for n_m_get_date; clarify API
...
This function catches Xapian exceptions. The test is intended to make
sure it stays that way.
2020-07-14 07:12:52 -03:00
David Bremner
ef15946def
test: add known broken for n_m_get_flag on closed db
...
Exception caught in next commit. Note that FLAG_GHOST is the only one
that triggers the I/O code path.
2020-07-13 07:19:22 -03:00
David Bremner
286161b703
lib: catch exceptions in n_m_get_filenames
...
This is essentially copied from the change to notmuch_message_get_filename
2020-07-13 07:19:22 -03:00
David Bremner
2c2ba7d6e2
test: add known broken test for n_m_get_filenames
...
This will be fixed in the next commit
2020-07-13 07:19:22 -03:00
David Bremner
a606cba32b
lib/n_m_g_filename: catch Xapian exceptions, document NULL return
...
This is the same machinery as applied for
notmuch_message_get_{thread,message}_id
2020-07-13 07:19:22 -03:00
David Bremner
46e8076281
lib: add known broken test for notmuch_message_get_filename
...
This will be fixed in the next commit
2020-07-13 07:19:22 -03:00
David Bremner
a962bd2bf8
lib/n_m_get_replies: doc return, initial regression test
...
We need to to set a query and retrieve the threads to meaningfully
test this function.
2020-07-13 07:19:22 -03:00
David Bremner
056794a60d
test: add regression test for n_m_get_header
...
This function already catches Xapian exceptions, and we want to make
sure it stays that way.
2020-07-13 07:19:22 -03:00
David Bremner
cca551a736
test: drop use of assert in closed db tests
...
Instead of printing the same static string for each test, can replace
the assert with something simpler (or at least easier to integrate
into the test suite).
2020-07-13 07:19:22 -03:00
David Bremner
a280d2a1a1
test: remove unused backup_database calls
...
Since these backups are never restored, they should be safe to remove.
2020-07-13 07:19:22 -03:00
David Bremner
ee897cab8b
test: drop upgrade from v1 tests
...
These are less crucial since we stopped generating new database
versions and relied primarily on features. They also rely on a
pre-generated v1 database which happens to be chert format. This
backend is not supported by Xapian 1.5.
Also drop the tool gen-testdb.sh, which is currently broken, due to
changes in the testing infrastructure.
2020-07-11 17:20:09 -03:00
David Bremner
dbdb860bb9
lib/message: catch exception in n_m_get_thread_id
...
This allows us to return an error value from the library.
2020-07-03 21:04:43 -03:00
David Bremner
bb51f3aa29
test: add known broken test for n_m_get_thread_id on closed db
...
This will be fixed in the next commit.
2020-07-03 21:04:02 -03:00
David Bremner
87d462a204
lib: catch error from closed db in n_m_get_message_id
...
By catching it at the library top level, we can return an error value.
2020-07-03 21:03:51 -03:00
David Bremner
2c17327ee5
test: add known broken test for error handling on closed database
...
Based on id:87d05je1j6.fsf@powell.devork.be
2020-07-03 21:01:39 -03:00