Commit graph

582 commits

Author SHA1 Message Date
Jani Nikula
71521f06b0 lib/cli: pass GMIME_ENABLE_RFC2047_WORKAROUNDS to g_mime_init()
As explained by Jeffrey Stedfast, the author of GMime, quoted in [1]:

> Passing the GMIME_ENABLE_RFC2047_WORKAROUNDS flag to g_mime_init()
> *should* solve the decoding problem mentioned in the thread. This
> flag should be safe to pass into g_mime_init() without any bad side
> effects and my unit tests do test that code-path.

The thread being referred to is [2].

[1] id:87bo56viyo.fsf@nikula.org
[2] id:08cb1dcd-c5db-4e33-8b09-7730cb3d59a2@gmail.com
2013-09-14 14:13:43 -03:00
Jani Nikula
59e311d9af test: add known broken tests for known broken RFC 2047 encodings
Some common broken RFC 2047 encodings that we currently let gmime
parse strictly. We could tell gmime to be forgiving in what it accepts
as RFC 2047 encoding, making these tests pass.
2013-09-14 14:10:21 -03:00
Tomi Ollila
fae15296ec test: unset 'xpg_echo' bash shell option
When 'xpg_echo' bash shell option is unset (usually the default)
echo builtin does not expand backslash-escape sequences by default
(i.e. '\n' is echoed as '\n' instead of newline). Not all bash
installations have this feature we depend on activated by default.

Note that the feature is bash (and GNU /bin/echo) specific. It is used
as it is convenient. If portability is needed (elsewhere) use printf(1)
(also often available as a shell builtin).
2013-09-08 22:42:12 -03:00
Tomi Ollila
11a3805464 test: exit with nonzero value when not all tests completed successfully
If any of the tests in our test system is not passing the execution
of the test suite completes with nonzero exit value.

It is better to rely on the exit value of the test system instead
of some arbitrary strings in test output (or use both).
2013-09-08 22:40:57 -03:00
Jani Nikula
2f7cfcd320 test: improve insert test reliability by checking message-id instead of count
There isn't a reported issue this would fix. Spotted by reading the
test.
2013-09-03 20:49:46 -03:00
Jani Nikula
8ffc60e989 test: add more maildir flag syncing related tests to insert
Specifically test maildir flag syncing with insert.
2013-09-03 20:46:01 -03:00
Louis Rilling
a9b2135c75 tags_to_maildir_flags: Don't rename if no flags change
notmuch_message_tags_to_maildir_flags() unconditionally moves messages from
maildir directory "new/" to maildir directory "cur/", which makes messages lose
their "new" status in the MUA. However some users want to keep this "new"
status after, for instance, an auto-tagging of new messages.

However, as Austin mentioned and according to the maildir specification,
messages living in "new/" are not allowed to have flags, even if mutt allows it
to happen. For this reason, this patch prevents moving messages from "new/" to
"cur/", only if no flags have to be changed. It's hopefully enough to satisfy
mutt (and maybe other MUAs showing the "new" status) users checking the "new"
status.

Changelog:
* v2: Fix bool type as well as NULL returned despite having no errors (Austin
      Clements)
* v4: Tag the related test (contributed by Michal Sojka) as working

Signed-off-by: Louis Rilling <l.rilling@av7.net>

[Condition for keeping messages in new/ was extended to satisfy all
 tests from the previous patch. -Michal Sojka]

[Added by David Bremner, to keep the tests passing at each commit]

update insert tests for new maildir synchronization rules

As of id:1355952747-27350-4-git-send-email-sojkam1@fel.cvut.cz
we are more conservative about moving messages from ./new to ./cur.
This updates the insert tests to match
2013-09-03 20:41:51 -03:00
Michal Sojka
4229966dce test: Add some missing maildir synchronization tests
As mentioned by Jani Nikula in id:87vcccp4y3.fsf@nikula.org, some cases
of maildir synchronization are not covered by our tests. Let's add the
missing tests.
2013-09-03 20:36:12 -03:00
Michal Sojka
0b46d0fd2e test: Adding non-maildir tags does not move message from new to cur
Some MUA's like mutt show the difference between "new" emails living in maildir
directory new/, and "old" emails living in maildir directory cur/. However
notmuch tag unconditionally moves selected messages from new/ to cur/, even if
no maildir synchronized tag is changed.

While maildir specification forbids messages with tags living in new/, there is
no need to move messages to cur/ when no maildir synchronized tag is changed.
Thus notmuch can remain transparent with respect to other MUA's.

[ Edited commit log to better describe the intended changes, and tag the
  test as broken until the actual changes are implemented -- Louis Rilling ]

Signed-off-by: Louis Rilling <l.rilling@av7.net>

[ Converted to use test_subtest_known_broken, David Bremner ]
2013-09-03 20:33:17 -03:00
Tomi Ollila
dd8ea3203c test: test notmuch show --include-html option
Test new --include-html option added to notmuch show command with
json output message parts containing text in latin1 and utf8 format.
2013-08-27 07:57:59 -03:00
Jani Nikula
09f8ef3e3d test: test notmuch count --output=files
Add tests for notmuch count --output=files option.
2013-08-24 11:44:12 +02:00
Jani Nikula
820a88eaaa test: test notmuch search --duplicate=N
Add test for notmuch search --duplicate=N option.
2013-08-24 11:42:18 +02:00
Austin Clements
e41cd1c518 test: Canonicalize RFC 2047 encoding and charset
RFC 2047 states that the encoding and charset in an encoded word are
case-insensitive, so force them to lower case in the reply test.  This
fixes an issue caused by GMime versions (somewhere between 2.6.10 and
2.6.16), which changed the capitalization of the encoding.
2013-08-20 09:14:25 +02:00
Austin Clements
dc51bf0ad4 reply: Use RFC 2822/MIME wholly for text format template
Previously, reply's default text format used an odd mix of RFC 2045
MIME encoding for the reply template's body and some made-up RFC
2822-like UTF-8 format for the headers.  The intent was to present the
headers to the user in a nice, un-encoded format, but this assumed
that whatever ultimately sent the email would RFC 2047-encode the
headers, while at the same time the body was already RFC 2045 encoded,
so it assumed that whatever sent the email would *not* re-encode the
body.

This can be fixed by either producing a fully decoded UTF-8 reply
template, or a fully encoded MIME-compliant RFC 2822 message.  This
patch does the latter because it is

a) Well-defined by RFC 2822 and MIME (while any UTF-8 format would be
   ad hoc).

b) Ready to be piped to sendmail.  The point of the text format is to
   be minimal, so a user should be able to pop up the template in
   whatever editor they want, edit it, and push it to sendmail.

c) Consistent with frontend capabilities.  If a frontend has the
   smarts to RFC 2047 encode the headers before sending the mail, it
   probably has the smarts to RFC 2047 decode them before presenting
   the template to a user for editing.

Also, as far as I know, nothing automated consumes the reply text
format, so changing this should not cause serious problems.  (And if
anything does still consume this format, it probably gets these
encoding issues wrong anyway.)
2013-08-17 09:06:08 +02:00
Austin Clements
6cdab6e0b7 reply: Remove extraneous space from generated References
Previously, the References header code seemed to assume
notmuch_message_get_header would return NULL if the header was not
present, but it actually returns "".  As a result of this, it was
inserting an unnecessary space when concatenating an empty or missing
original references header with the new reference.

This shows up in only two tests because the text reply format later
passes the whole reply template through g_mime_filter_headers, which
has the side effect of stripping out this extra space.
2013-08-17 09:05:44 +02:00
Austin Clements
ad7bb423fb reply: Test replying to messages with RFC 2047-encoded headers 2013-08-17 09:04:07 +02:00
Austin Clements
a7696844f0 test: Make symbol-test depend on libnotmuch.so
Without this
$ make -j test
intermittently fails and
$ make clean; make test/symbol-test
always fails (not that anybody would do the latter).
2013-08-15 11:35:30 +02:00
Peter Wang
9a64b2df29 test: test insert --create-folder option
Add tests for notmuch insert --create-folder option.
2013-07-04 00:08:16 -03:00
Peter Wang
0c4b8aa736 test: test insert --folder option
Add tests for notmuch insert --folder option.
2013-07-01 12:23:09 -03:00
Peter Wang
7e3a7ed62f test: add tests for insert
Add tests for new 'insert' command.
2013-06-29 19:29:02 -03:00
Austin Clements
43251ab653 emacs: Use S-exp format everywhere
This switches `notmuch-mua-reply' and `notmuch-query-get-threads' to
the S-exp format.  These were the last two uses of the JSON format in
the Emacs frontend.
2013-06-24 22:57:13 -07:00
Tomi Ollila
8d863c9e87 revert: Removed top level --stderr= option
While looked good on paper, its attempted use caused confusion, complexity,
and potential for information leak when passed through wrapper scripts.
For slimmer code and to lessen demand for maintenance/support the set of
commits which added top level --stderr= option is now reverted.
2013-06-24 22:52:59 -07:00
Tomi Ollila
2593df5271 test/basic: replaced find -perm +111 with portable alternative
The find option syntax `-perm +111` is deprecated gnu find feature.
The replacement `( -perm -100 -o -perm -10 -o -perm 1 )` should also
work outside of the GNU domain.
2013-06-24 22:49:51 -07:00
Austin Clements
89efd5717a emacs: Use streaming S-expr parser for search
In addition to being the Right Thing to do, this noticeably improves
the time taken to display the first page of search results, since it's
roughly an order of magnitude faster than the JSON parser.
Interestingly, it does *not* significantly improve the time to
completely fill a large search buffer because for large search
buffers, the cost of creating author invisibility overlays and
inserting text (which slows down with more overlays) dominates.
However, the time required to display the first page of results is
generally more important to the user experience.
2013-06-01 09:00:40 -03:00
Austin Clements
08fde50bf3 emacs: Use async process helper for search
Previously, search started the async notmuch process directly.  Now,
it uses `notmuch-start-notmuch'.  This simplifies the process sentinel
a bit and means that we no longer have to worry about errors
interleaved with the JSON output.

We also update the tests of Emacs error handling, since the error
output is now separated from the search results buffer.
2013-06-01 08:56:16 -03:00
Austin Clements
7eaf698e23 test: Remove extraneous Emacs error handling test
We now check error handling more carefully in the last test in
test/emacs and we're about to add more error handling tests.  (This
was also a strange place for this test, since it had nothing to do
with large search buffers.)
2013-06-01 08:53:19 -03:00
Austin Clements
1546387d72 emacs: Simplify MIME part command implementation
This unifies the part button actions and the underlying part action
functions into single interactive command that simply applies to the
part containing point using the just-added part p-list text property
instead of button properties.  Since all part actions can be performed
by applying the appropriate mm function to an mm-handle, this patch
abstracts out the creation of mm handles, making the implementations
of the part commands trivial.  This also eliminates our special
handling for part save in favor of using the appropriate mm function.

This necessarily modifies the way we handle the default part button
action, but in a way that does not change the meaning of the
notmuch-show-part-button-default-action defcustom.

Since these commands are no longer specific to buttons, this patch
eliminates the extra metadata stored with each button.  This also
eliminates one rather special-purpose macro for a collection of
general purpose part handling utilities.
2013-05-31 22:01:02 -03:00
Tomi Ollila
ff598e4fdd test: added --stderr=FILE tests
--stderr=FILE tests were added to test/help-test as it is the one
doing most global option testing. Also, it was simplest to test
this new option using `notmuch help` command.
2013-05-29 20:01:38 -03:00
Peter Wang
42102e0b3f test: add tests for search --exclude=all
Test the new search --exclude=all option.
2013-05-13 21:32:46 -03:00
Aaron Ecay
cf8aaafbad lib/database.cc: change how the parent of a message is calculated
Presently, the code which finds the parent of a message as it is being
added to the database assumes that the first Message-ID-like substring
of the In-Reply-To header is the parent Message ID.  Some mail clients,
however, put stuff other than the Message-ID of the parent in the
In-Reply-To header, such as the email address of the sender of the
parent.  This can fool notmuch.

The updated algorithm prefers the last Message ID in the References
header.  The References header lists messages oldest-first, so the last
Message ID is the parent (RFC2822, p. 24).  The References header is
also less likely to be in a non-standard
syntax (http://cr.yp.to/immhf/thread.html,
http://www.jwz.org/doc/threading.html).  In case the References header
is not to be found, fall back to the old behavior.

V2 of this patch, incorporating feedback from Jani and (indirectly)
Austin.
2013-05-13 21:29:13 -03:00
Aaron Ecay
983d5e1df2 test: add tests for the handling of References and In-Reply-To headers
These tests are known_broken, the following commit fixes them.

amended per

	id:87txmi1zq3.fsf@nikula.org
	id:87vc6yalo7.fsf@zancas.localnet
2013-05-13 21:27:01 -03:00
Jani Nikula
9641fe1ce7 cli: config: fix config file save when the file does not exist
The use of realpath(3) in
commit 58ed67992d
Author: Jani Nikula <jani@nikula.org>
Date:   Sun Apr 7 20:15:03 2013 +0300

    cli: config: do not overwrite symlinks when saving config file

broke config file save when the file does not exist, which results in
'notmuch setup' always failing to create a new config file.

Fix by checking ENOENT from realpath(3).
2013-05-12 07:46:44 -03:00
Jani Nikula
2c64c2e0eb test: add basic test for notmuch setup
And annotate with test_subtest_known_broken. Hooray.
2013-05-12 07:46:23 -03:00
Jani Nikula
58ed67992d cli: config: do not overwrite symlinks when saving config file
Use realpath to canonicalize the config path before writing.

Previously 'notmuch setup' and 'notmuch config set' overwrote the
config file even if it was a symbolic link.
2013-04-14 18:38:07 -03:00
Jani Nikula
7defbcdcec test: add some config file tests
Test the --config=FILE option, and add a broken test for writing
config file through a symbolic link.
2013-04-14 18:35:02 -03:00
Jani Nikula
360c3c8607 test: notmuch count --batch and --input options 2013-04-01 09:38:48 -04:00
Jani Nikula
6b405143d7 test: notmuch tag --remove-all 2013-03-30 18:34:22 -04:00
Jani Nikula
e76f6517de cli: config: make notmuch_config_open() "is new" parameter input only
We now have a notmuch_config_is_new() function to query whether a
config was created or not. Change the notmuch_config_open() is_new
parameter into boolean create_new to determine whether the function
should create a new config if one doesn't exist. This reduces the
complexity of the API.
2013-03-07 09:39:12 -04:00
Aaron Ecay
ed5150d2df test/README: mention the test_expect_equal_json and *sanitize* functions
also fix one typo
2013-03-07 09:38:26 -04:00
David Bremner
16aa65ba25 Merge branch 'release'
add in NEWS from 0.15.2

Conflicts:
	NEWS
2013-02-18 20:33:48 -04:00
Tomi Ollila
0d8d11d338 test/test-lib.sh: separate signaled exit
When execution of tests is interrupted by signal coming outside of the
test system itself, output just one line "interrupted by signal <num>"
message to standard output. This distinguishes the case from internal
exit and reduces noise.
2013-02-18 20:17:17 -04:00
Tomi Ollila
3a15602d8e test/test-lib.sh: use $test_subtest_name in all tests
Set the variable '$test_subtest_name' in all functions which starts
a new test and use that variable in all functions that output
test results.

Additionally output the latest '$test_subtest_name' in case of
abnormal exit, to avoid confusion.
2013-02-18 20:17:05 -04:00
David Bremner
f021a06288 test: delay watchdog checks in emacs.
Instead of checking immediately for the watched process, delay a
minute, or in the case that process-attributes returns nil, for two
minutes.  This is intended to cope with the case that
process-attributes is unimplimented, and returns always returns nil.
In this case, the watchdog check is the same as the two minute limit
imposed by timeout.
2013-01-29 19:17:07 -04:00
Tomi Ollila
a12f810a00 test/test-lib.sh: use vt100 as dtach terminal if TERM dumb or unset/empty
The TERM environment variable is set to 'dumb' when running tests, but
the original value of it is stored for echoing colors and running emacs
(somewhat interactively) in detached session. Emacs requires some
terminal control sequences to be available for interactive operation.
In case original TERM is (also) 'dumb' (or unset/empty) emacs cannot
run interactively. To fix this problem dtach (and emacs as it's child
process) is run with TERM=vt100 in case original TERM was unset, empty
or 'dumb'. This way there is a chance to run emacs tests with different
user terminals and potentially find problems there.
2013-01-24 06:59:21 -04:00
David Bremner
bd829fde96 test/tagging: add test for naked punctuation in tags; compare with quoting spaces.
This test also serves as documentation of the quoting
requirements. The comment lines are so that it exactly matches the man
page. Nothing more embarrassing than having an example in the man page
fail.
2013-01-07 20:49:00 -04:00
David Bremner
bbdbc83854 test/tagging: add test for exotic message-ids and batch tagging
The (now fixed) bug that this test revealed is that unquoted
message-ids with whitespace or other control characters in them are
split into several tokens by the Xapian query parser.
2013-01-07 20:49:00 -04:00
David Bremner
9a31cbd386 test/tagging: add tests for exotic tags
We test quotes seperately because they matter to the query escaper.
2013-01-07 20:49:00 -04:00
David Bremner
e77a99f44e test/tagging: add basic tests for batch tagging functionality
This tests argument parsing, blank lines and comments, and basic hex
decoding functionality.
2013-01-07 20:49:00 -04:00
David Bremner
45c593095b test/tagging: add test for error messages of tag --batch
This is based on the similar test for notmuch restore, but the parser
in batch tagging mode is less tolerant of a few cases, in particular
those tested by illegal_tag.
2013-01-07 20:49:00 -04:00
Austin Clements
401dbebd48 emacs: Use the minibuffer for CLI error reporting
We recently switched to popping up a buffer to report CLI errors, but
this was too intrusive, especially for transient errors and especially
since we made fewer things ignore errors.  This patch changes this to
display a basic error message in the minibuffer (using Emacs' usual
error handling path) and, if there are additional details, to log
these to a separate error buffer and reference the error buffer from
the minibuffer message.  This is more in line with how Emacs typically
handles errors, but makes the details available to the user without
flooding them with the details.

Given this split, we pare down the basic message and make it more
user-friendly, and also make the verbose message even more detailed
(and more debugging-oriented).
2013-01-06 22:47:35 -04:00