aboutsummaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2023-09-23CLI: exit with error when load_config returns an error.David Bremner
For now print a generic error message and exit with error on any non-success code. Previously the code exited, but with exit code zero, leading users / scripts to think the command had succeeded.
2023-09-23test: add known broken test for bad utf8 in configDavid Bremner
We should ideally print an informative error message, but at the very least we should not exit with success.
2023-09-02test: suppress all interceptors in glibKevin Boulain
On ppc64el, races are detected by TSan: WARNING: ThreadSanitizer: data race (pid=4520) Read of size 8 at 0x7ffff20016c0 by thread T1: #0 strlen ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:386 (libtsan.so.2+0x77c0c) #1 strlen ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:378 (libtsan.so.2+0x77c0c) #2 g_strdup ../../../glib/gstrfuncs.c:362 (libglib-2.0.so.0+0xa4ac4) Previous write of size 8 at 0x7ffff20016c0 by thread T2: #0 malloc ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:647 (libtsan.so.2+0x471f0) #1 g_malloc ../../../glib/gmem.c:130 (libglib-2.0.so.0+0x7bb68) Location is heap block of size 20 at 0x7ffff20016c0 allocated by thread T2: #0 malloc ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:647 (libtsan.so.2+0x471f0) #1 g_malloc ../../../glib/gmem.c:130 (libglib-2.0.so.0+0x7bb68) This appears to be a false positive in GLib, as explained at https://gitlab.gnome.org/GNOME/glib/-/issues/1672#note_1831968 In short, a call to fstat fails under TSan and GLib's g_sterror will intern the error message, which will be reused by other threads. Since upstream appears to be aware that GLib doesn't play nicely with TSan, suppress everything coming from the library instead of maintaining a fine grained list. Reported at https://buildd.debian.org/status/fetch.php?pkg=notmuch&arch=ppc64el&ver=0.38%7Erc0-1&stamp=1692959868&raw=0
2023-08-26test: minimize impact of native compilation.David Bremner
Native compilation is kindof useless in the test suite because we throw away the cache after every subtest. The test suite could in principle share an eln cache within a given test file; for now try to minimize the amount of native-compilation. There is an intermittent bug where emacs loses track of its default-directory; I suspect (but have no proof) that bug is related to native compilation and/or race conditions. This patch seems to prevent that bug (or at least reduce its frequency).
2023-08-21test/setup: ignore blank lines in generated configDavid Bremner
The presense of the blank lines between sections depends on the version of glib. Strip them before comparison.
2023-08-20test/emacs: adapt to breaking change in Gnus defaultsDavid Bremner
As of Emacs 29.1, In-Reply-To is in the default value for message-hidden-headers. We actually want to see that in the test suite, so remove it again. To future proof the tests, fix a default value for message-hidden-headers specifically for the test suite.
2023-07-21test: support testing notmuch as installedDavid Bremner
We put some effort into testing the built copy rather than some installed copy. On the other hand for people like packagers, testing the installed copy is also of interest. When NOTMUCH_TEST_INSTALLED is set to a nonempty value, tests do not require a built notmuch tree or running configure. Some of the tests marked as broken when running against installed notmuch are probably fixable.
2023-07-21test: Guess a value for NOTMUCH_PYTHONDavid Bremner
python3 will work for many people, and reduce the friction to running the tests without running configure first.
2023-07-21test: check for empty/missing files in test_expect_equal_message_bodyDavid Bremner
Messages can have empty bodies, but empty files are not messages.
2023-07-21test: treat undefined feature variables as 0David Bremner
When running the test suite without building first, it is desirable to have the tests consider these variables being undefined as equivalent to the feature not being present, and in particular for the tests not to generate errors.
2023-07-09test: add known broken test for message-id with embedded spaces.David Bremner
According to my reading of RFC5322, there is an obsolete syntax for Message-Id which permits folding whitespace (i.e. to be removed / ignored by parsers). In [1] Paul Wise observed that notmuch removed whitespace on indexing, but does not do any corresponding normalization of queries. Mark the latter as a bug by adding a failing test. [1]: id:20230409044143.4041560-1-pabs3@bonedaddy.net
2023-04-02lib: index attachments with mime types matching index.as_textDavid Bremner
Instead of skipping indexing all attachments, we check of a (user configured) mime type that is indexable as text.
2023-04-02lib: add config key INDEX_AS_TEXTDavid Bremner
Higher level processing as a list of regular expressions and documentation will follow.
2023-03-31lib: replace some uses of Query::MatchAll with a thread-safe alternativeKevin Boulain
This replaces two instances of Xapian::Query::MatchAll with the equivalent but thread-safe alternative Xapian::Query(std::string()). Xapian::Query::MatchAll maintains an internal pointer to a refcounted Xapian::Internal::QueryTerm. None of this is thread-safe but that wouldn't be an issue if Xapian::Query::MatchAll wasn't static. Because it's static, the refcounting goes awry when Notmuch is called from multiple threads. This is actually documented by Xapian: https://github.com/xapian/xapian/blob/4715de3a9fcee741587439dc3cc1d2ff01ffeaf2/xapian-core/include/xapian/query.h#L65 While static, Xapian::Query::MatchNothing is safe because it doesn't maintain an internal object and as such, doesn't use references. Two best-effort tests making use of TSan were added to showcase the issue (I couldn't figure out a way to deterministically reproduce it without making an unmaintainable mess). First, when two databases are created in parallel, a query that uses Xapian::Query::MatchAll is made (lib/query.cc), resulting in the following backtrace on a segfault: #0 0x00007ffff76822af in Xapian::Query::get_terms_begin (this=0x7fffe80137f0) at api/query.cc:141 #1 0x00007ffff7f933f5 in _notmuch_query_cache_terms (query=0x7fffe80137c0) at lib/query.cc:176 #2 0x00007ffff7f93784 in _notmuch_query_ensure_parsed_xapian (query=0x7fffe80137c0) at lib/query.cc:225 #3 0x00007ffff7f9381a in _notmuch_query_ensure_parsed (query=0x7fffe80137c0) at lib/query.cc:260 #4 0x00007ffff7f93bfe in _notmuch_query_search_documents (query=0x7fffe80137c0, type=0x7ffff7fa9b1e "mail", out=0x7ffff666da18) at lib/query.cc:361 #5 0x00007ffff7f93ba4 in notmuch_query_search_messages (query=0x7fffe80137c0, out=0x7ffff666da18) at lib/query.cc:349 #6 0x00007ffff7f83d98 in notmuch_database_upgrade (notmuch=0x7fffe8000bd0, progress_notify=0x0, closure=0x0) at lib/database.cc:934 #7 0x00007ffff7fa110f in notmuch_database_create_with_config (database_path=0x7ffff666dcb0 "/tmp/notmuch.MZ2AGr", config_path=0x7ffff7faab3c "", profile=0x0, database=0x0, status_string=0x7ffff666dc90) at lib/open.cc:754 #8 0x00007ffff7fa0d6f in notmuch_database_create_verbose (path=0x7ffff666dcb0 "/tmp/notmuch.MZ2AGr", database=0x0, status_string=0x7ffff666dc90) at lib/open.cc:653 #9 0x00007ffff7fa0ceb in notmuch_database_create (path=0x7ffff666dcb0 "/tmp/notmuch.MZ2AGr", database=0x0) at lib/open.cc:637 ... Second, some queries would make use of Xapian::Query::MatchAll (lib/regexp-fields.cc), resulting in the following backtrace on a segfault: #0 0x00007f629828b690 in Xapian::Internal::QueryBranch::gather_terms (this=0x7f628800def0, void_terms=0x7f629726d5a0) at api/queryinternal.cc:1245 #1 0x00007f629828c260 in Xapian::Internal::QueryScaleWeight::gather_terms (this=0x7f628800df70, void_terms=0x7f629726d5a0) at api/queryinternal.cc:1434 #2 0x00007f629828b69f in Xapian::Internal::QueryBranch::gather_terms (this=0x7f628800dd90, void_terms=0x7f629726d5a0) at api/queryinternal.cc:1245 #3 0x00007f6298282571 in Xapian::Query::get_unique_terms_begin (this=0x7f628800dcd8) at api/query.cc:166 #4 0x00007f629841a59b in Xapian::Weight::Internal::accumulate_stats (this=0x7f628800dca0, subdb=..., rset=...) at weight/weightinternal.cc:86 #5 0x00007f62983c15ba in LocalSubMatch::prepare_match (this=0x7f628800df20, nowait=true, total_stats=...) at matcher/localsubmatch.cc:172 #6 0x00007f62983c8fcc in prepare_sub_matches (leaves=std::vector of length 1, capacity 1 = {...}, stats=...) at matcher/multimatch.cc:237 #7 0x00007f62983c98a3 in MultiMatch::MultiMatch (this=0x7f629726d9a0, db_=..., query_=..., qlen=3, omrset=0x0, collapse_max_=0, collapse_key_=4294967295, percent_cutoff_=0, weight_cutoff_=0, order_=Xapian::Enquire::ASCENDING, sort_key_=0, sort_by_=Xapian::Enquire::Internal::VAL, sort_value_forward_=true, time_limit_=0, stats=..., weight_=0x7f6288008d50, matchspies_=std::vector of length 0, capacity 0, have_sorter=false, have_mdecider=false) at matcher/multimatch.cc:353 #8 0x00007f629826fcba in Xapian::Enquire::Internal::get_mset (this=0x7f628800e0b0, first=0, maxitems=0, check_at_least=0, rset=0x0, mdecider=0x0) at api/omenquire.cc:569 #9 0x00007f629827181c in Xapian::Enquire::get_mset (this=0x7f629726db80, first=0, maxitems=0, check_at_least=0, rset=0x0, mdecider=0x0) at api/omenquire.cc:937 #10 0x00007f6298be529a in _notmuch_query_search_documents (query=0x7f6288009750, type=0x7f6298bfaafe "mail", out=0x7f629726dcc0) at lib/query.cc:447 #11 0x00007f6298be4ae8 in notmuch_query_search_messages (query=0x7f6288009750, out=0x7f629726dcc0) at lib/query.cc:349 ... Printing Xapian::Query::MatchAll->internal.px->_refs in these circumstances can help quickly identifying this scenario. This is motivated by some test frameworks (like Rust's Cargo) that runs unit tests in parallel and would easily encounter this issue, unless client code gates every call to Notmuch behind a lock. This is what can be expected from the tests when they fail: == stderr == +================== +WARNING: ThreadSanitizer: data race (pid=207931) + Read of size 1 at 0x7b10000001a0 by thread T2: + #0 memcpy <null> (libtsan.so.2+0x62506) + #1 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) [clone .isra.0] <null> (libxapian.so.30+0x872b3) + + Previous write of size 8 at 0x7b10000001a0 by thread T1: + #0 operator new(unsigned long) <null> (libtsan.so.2+0x8ba83) + #1 Xapian::Query::Query(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, unsigned int) <null> (libxapian.so.30+0x855cd) ...
2023-03-31ruby: database: make path arg optionalFelipe Contreras
It can be automatically loaded from the configuration now. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2023-03-30test: add test for notmuch_message_remove_all_properties_with_prefixKevin Boulain
It wasn't covered, though it shares most of its implementation with notmuch_message_remove_all_properties.
2023-03-30lib/message-property: sync removed properties to the databaseKevin Boulain
_notmuch_message_remove_all_properties wasn't syncing the message back to the database but was still invalidating the metadata, giving the impression the properties had actually been removed. Also move the metadata invalidation to _notmuch_message_remove_terms to be closer to what's done in _notmuch_message_modify_property and _notmuch_message_remove_term.
2023-03-30test: reveal notmuch_message_remove_all_properties as brokenDavid Bremner
Close and re-open the database to show that the removal is not committed to the database.
2023-03-30test: reorganize tests and mark a few of them as brokenKevin Boulain
notmuch_message_remove_all_properties should have removed the testkey1 = testvalue1 property but hasn't. Delay the execution of the corresponding test to avoid updating a few tests that actually relied on the broken behavior.
2023-03-30test: remove unnecessary sortingKevin Boulain
The other tests rely on a stable output.
2023-03-30test: display key name in property testsKevin Boulain
To make the tests a bit easier to understand.
2023-03-30lib/message-property: catch xapian exceptionsKevin Boulain
Since libnotmuch exposes a C interface there's no way for clients to catch this. Inspired by what's done for tags (see notmuch_message_remove_tag).
2023-03-30test: uncaught exception when editing properties of a removed messageKevin Boulain
These two functions don't fail gracefully when editing a removed message: BROKEN edit property on removed message without uncaught exception --- T610-message-property.20.EXPECTED 2023-02-27 11:33:25.792764376 +0000 +++ T610-message-property.20.OUTPUT 2023-02-27 11:33:25.793764381 +0000 @@ -1,2 +1,3 @@ == stdout == == stderr == +terminate called after throwing an instance of 'Xapian::DocNotFoundError' The other functions appear to be safe.
2023-02-20lib: add better diagnostics for over long filenames.David Bremner
Previously we just crashed with an internal error. With this change, the caller can handle it better. Update notmuch-new so that it doesn't crash with "unknown error code" because of this change.
2023-02-20test: add known broken test for diagnostics from over long filenames.David Bremner
Previously we tested over long directory names, add similar testing for over long filenames.
2023-02-20emacs: notmuch-tree-outline-modejao
With this mode, one can fold trees in the notmuch-tree buffer as if they were outlines, using all the commands provided by outline-minor-mode. We also define a couple of movement commands that, optional, will ensure that only the thread around point is unfolded. The implementation is based on registering a :level property in the messages p-list, that is then used by outline-minor-mode to to recognise headers. Amended by db: Copy docstring to manual and edit for presentation. Add two tests. Fix typo "wether".
2023-01-05test: mark some tests as broken when run as root.David Bremner
File permission errors e.g., are hard to trigger as root.
2022-12-27lib/message: move xapian call inside try/catch block in _n_m_deleteDavid Bremner
The call to delete_document can throw exceptions (and can happen in practice [1]), so catch the exception and extract the error message. As a side effect, also move the call to _n_m_has_term inside the try/catch. This should not change anything as that function already traps any Xapian exceptions. [1]: id:wwuk039sk2p.fsf@chaotikum.eu
2022-12-27test: add known broken test for exception handling in _n_m_deleteDavid Bremner
In [1], Thomas Schneider reported an uncaught Xapian exception when running out of disk space. We generate the same exception via database corruption. [1]: id:wwuk039sk2p.fsf@chaotikum.eu
2022-11-05cli: add options --offset and --limit to notmuch showRobin Jarry
notmuch search does not output header values. However, when browsing through a large email corpus, it can be time saving to be able to paginate without running notmuch show for each message/thread. Add --offset and --limit options to notmuch show. This is inspired from commit 796b629c3b82 ("cli: add options --offset and --limit to notmuch search"). Update man page, shell completion and add a test case to ensure it works as expected. Cc: Tim Culverhouse <tim@timculverhouse.com> Cc: Tomi Ollila <tomi.ollila@iki.fi> Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-09-23test: replace aging OpenPGP key used in the test suiteJustus Winter
This replaces the old OpenPGPv4 key that is used in the test suite with a more modern OpenPGPv4 key. All cryptographic artifacts in the test suite are updated accordingly. Having old cryptographic artifacts in the test suite presents a problem once the old algorithms are rejected by contemporary implementations. For reference, this is the old key. sec rsa1024 2011-02-05 [SC] 5AEAB11F5E33DCE875DDB75B6D92612D94E46381 uid [ unknown] Notmuch Test Suite <test_suite@notmuchmail.org> (INSECURE!) ssb rsa1024 2011-02-05 [E] And this is the new key. Note that is has the same shape, but uses Ed25519 and Cv25519 instead of 1024-bit RSA. sec ed25519 2022-09-07 [SC] 9A3AFE6C60065A148FD4B58A7E6ABE924645CC60 uid [ultimate] Notmuch Test Suite (INSECURE!) <test_suite@notmuchmail.org> ssb cv25519 2022-09-07 [E]
2022-09-19test: compute expected keyid from fingerprintJustus Winter
2022-09-03test: add known broken test for indexing text/* attachmentsDavid Bremner
The general problem of indexing attachments requires some help to turn things into text, but (most?) text/* should be doable internally, possibly with optimizations as for the text/html case.
2022-09-03test: rename indexing corpusDavid Bremner
The corpus is not really suitable for general indexing test since the sole message is ignored (and will most likely continue to be ignored) by notmuch-new.
2022-09-03lib: add field processor for lastmod: prefixDavid Bremner
By sharing the existing logic used by the sexp query parser, this allows negative lastmod revisions to be interpreted as relative to the most recent revision.
2022-09-03lib/sexp: provide relative lastmod queriesDavid Bremner
Test the relatively trivial logic changes for the sexp query parser first before refactoring that logic to share with the infix query parser.
2022-09-03lib/open: create database path in some casesDavid Bremner
There is some duplication of code here, but not all of the locations valid to find a database make sense to create. Furthermore we nead two passes, so the control flow in _choose_database_path would get a bit convoluted.
2022-09-03lib/open: return non-SUCCESS on missing database pathDavid Bremner
This simplifies the logic of creating the directory path when it doesn't exist.
2022-09-03test/path-config: set database.mail_root but not database.pathDavid Bremner
The failing "create database" test replicates a bug reported by Sean Whitton [1]. The other two failures also look related to the database being (re)created in the wrong place. [1]: id:87y1wqkw13.fsf@athena.silentflame.com.
2022-09-03test: add test for creating database in various configurations.David Bremner
The existing database creation (via add_email_corpus) was always done in the traditional configuration. The use of xapian-metadata is just to portably ensure that there is a database created where we expect there to be.
2022-08-11emacs/show: restrict inlined mimetypes on refresh.David Bremner
This fixes the bug reported by Al [1]. Essentially apply the same fix as [2] in a different place. [1]: id:877d41nmr1.fsf@gmail.com [2]: 90a7c1af368a527700dcde9b0dcbd760afc7bd92
2022-08-11test/emacs: add known broken test for inlining on refresh.David Bremner
This duplicates the bug reported by Al [1] [1]: id:877d41nmr1.fsf@gmail.com
2022-08-07emacs: add duplicate support to notmuch-show-view-raw-messageDavid Bremner
This fixes one of the bugs reported by Gregor in [1] [1]: id:87edxw8jp4.fsf@no.workgroup
2022-08-07test/emacs: add known broken test for viewing raw duplicateDavid Bremner
This duplicates one of the bugs reported by Gregor in [1]. [1]: id:87edxw8jp4.fsf@no.workgroup
2022-08-07emacs: update notmuch-show-get-filename to handle duplicatesDavid Bremner
This fixes one of the bugs reported by Gregor in [1]. [1]: id:87edxw8jp4.fsf@no.workgroup
2022-08-07test/emacs: add known broken test for stashing duplicate filenameDavid Bremner
This duplicates (no pun intended) one of the bugs reported by Gregor in id:87edxw8jp4.fsf@no.workgroup
2022-08-06tests: remove dead code from T055-path-config.shDavid Bremner
This case statement does nothing.
2022-07-30emacs/reply: reply to correct duplicateDavid Bremner
Essentially we just need to arrange to pass the right --duplicate argument to notmuch reply. As a side-effect, correct the previously unused value of EXPECTED in T453-emacs-reply.sh.
2022-07-30CLI/reply: support --duplicate argumentDavid Bremner
We want the reply used to match that shown e.g. in the emacs interface. As a first step provide that functionality on the command line. Schema does not need updating as the duplicate key was already present (with a constant value of 1).
2022-07-30emacs/show: display count of duplicates in headerlineDavid Bremner
There is no real cost here, except screen real estate. Some people might prefer hiding the duplicate count, but we leave that for a future commit.