Commit graph

194 commits

Author SHA1 Message Date
David Bremner
fba968dbfa tests: add a test for symbol hiding side effects
The worry here is that a binary linking with libnotmuch might lose
access to Xapian::Error symbols because libnotmuch hides them.

We are careful here to create ./fakedb/.notmuch in order to trigger a
Xapian exception, and not just a missing file check.

Thanks to jrollins and amddragon for suggestions.
(cherry picked from commit 66f37f5f6864a988f94ddb893e3a176af57f6c8e)
2011-06-23 07:05:25 -03:00
Carl Worth
b0ba84f9e7 smtp-dummy: Prefer return rather than exit() in main.
The main() function should be written as just another function with a
return value. This allows for more reliable code reuse. Imagine that
main() grows too large and needs to be factored into multiple
functions. At that point, exit() is probably the wrong thing, yet can
also be hard to notice as it's in less-frequently-tested exceptional
cases.
2011-06-22 06:38:33 -07:00
Dmitry Kurochkin
41a094624a Fix compilation warnings in test/smtp-dummy.c.
* Remove unused variables in main(): buf, bytes and greeting.
* Replace return with no value in main() with exit(3).
2011-06-22 06:38:33 -07:00
David Bremner
114eb1c520 tests: Add optional use of timeout utility, if present.
Each top level test (basic, corpus, etc...) is run with a fixed
timeout of 2 minutes.

The goal here is to treat a hung test as a failure. The emacs test for
sending mail is known to be problematic on the Debian
autobuilders. This is both a bandaid fix for that, and a sensible long
term feature.
(cherry picked from commit 5f99c80e02736c90495558d9b88008a768876b29)
2011-06-22 08:11:32 -03:00
Dmitry Kurochkin
59b251ef94 test emacs: Add tests for hiding messages in notmuch-show view
This test is expected to fail as it exposes a current bug, (which we
hope to fix soon).
2011-06-15 07:07:32 -07:00
Carl Worth
b7db7ea420 test: Fix from-guessing to actually span Received headers over multiple lines
The intent was always to make these Received headers span multiple
lines. But the escapes were causing the shell to ignore the newlines,
so that the result instead was long Received headers on a single line
each.

Fixing the intent here doesn't actually change the test-suite results
at all.
2011-06-10 17:20:22 -07:00
Carl Worth
ac43a96988 test: Extend from-guessing test with a test with multiple Received headers
This is much more realistic, as most messages in the wild will have multiple
Received headers. Also, this demonstrates a current bug in the Received
header parsing, (multiple Received headers are not properly concatenated
depending on the order in which headers are parsed in a message).
2011-06-10 17:03:14 -07:00
Carl Worth
d5edb1122d test: Add test that emacs detects and hides top-post quotes of original messages
This tests the recently-added detection/hiding of top-posted quotations and
in the testing, it takes advantage of the less-recently-added
visible-buffer-string function for emitting only the visible text
from a buffer.
2011-06-10 16:28:26 -07:00
Jameson Graef Rollins
61ff61cc2c test: modify multipart test to use test_expect_equal_file
Again, this is a much cleaner and more thorough test, and in fact
exposes a bug in the format=text output, that will be fixed the next
commit.  Because of this, some of the multipart tests currently fail.
2011-06-03 15:24:35 -07:00
Jameson Graef Rollins
5b0bf70faa test: update emacs test to use test_expect_equal_file
This is a much cleaner way to do the emacs tests, since we're actually
comparing output against existing files with expected output.  We also
won't miss any trailing newlines this way.

And speaking of which, one of the expected output files was actually
missing a trailing blank line that was actually in one of the original
messages, so this was fixed.
2011-06-03 14:29:05 -07:00
Dmitry Kurochkin
79a587d963 test: add "notmuch-show for message with invalid From" test 2011-06-03 14:07:19 -07:00
Austin Clements
c62a0d016f Fix misspelling in search output sanitization test.
A simple spelling fix in the text description.

Signed-off-by: Jameson Graef Rollins <jrollins@finestructure.net>
2011-06-03 12:30:55 -07:00
Jameson Graef Rollins
c4e6d3291c test: cleanup search-output test names (no functional change)
Signed-off-by: Jameson Graef Rollins <jrollins@finestructure.net>
2011-06-01 21:59:42 -07:00
Florian Friesdorf
8dcd8b6987 test: add test for sanitized notmuch-search output
This feature was recently added, so it of course needs a test now.

Signed-off-by: Jameson Graef Rollins <jrollins@finestructure.net>

Edited-by: Carl Worth <cworth@cworth.org> Fixed test to use
notmuch_search_sanitize in order to be robust against unpredictable
thread ID numbers, (due to unpredictable order in which the filesystem
presents files).
2011-06-01 21:58:16 -07:00
Florian Friesdorf
e584c64c5b test: Create and set temporary home directory
In the master branch in test/emacs two tests access the build users home
directory, so does emacs_deliver_message in the crypto branch.

The tests should not touch the build user's home directory. The patch
creates a directory in the temporary test directory and sets home
accordingly.

In case of a non-existent home directory, the tests are failing without
this patch.

Signed-off-by: Jameson Graef Rollins <jrollins@finestructure.net>
2011-06-01 17:46:51 -07:00
Jameson Graef Rollins
afdfa5674c test: remove json test for search null result, since it's being more properly tested in search-output
The test in json was inferior to the one in search-output, since it
wasn't properly testing for the presence of a trailing newline.
2011-06-01 16:35:11 -07:00
Jameson Graef Rollins
7fdeb0fb63 test: move utf-8 subject search test from json to search test script
This test doesn't have anything to do with json, and has everything to
do with testing search capability, so I'm not sure why it was in the
wrong place.
2011-06-01 16:35:11 -07:00
Jameson Graef Rollins
7a453716c2 test: Move a test from search to search-output, and add a similar json test
The "Search for non-existent message prints nothing" test fits better
with the existing tests in search-output, so move it there. Also add a
similar test for the --format=json case.

These tests also use the new test_expect_equal_file function, (to ensure
that the presence of a trailing newline is correctly tested).
2011-06-01 16:31:52 -07:00
Jameson Graef Rollins
593d96ff1d test: modify search-output test to use the new test_expect_equal_file function
These test now properly test for the presence of a newline at the end
of all output.  Right now some of these test will fail because the
search output is currently broken to *not* produce proper newlines in
some cases.
2011-06-01 13:08:26 -07:00
Carl Worth
c6b49ae752 test: Add test showing notmuch corrupts a part with a CRLF pair in it
Since commit 2f8871df6e notmuch has been
using a function (show_part_content) originally written only for text
parts to save all MIME parts. The problem with this is that this
function converts CRLF pairs to LF only and optionally converts to
UTF-8 encoding. These two conversions have the potential to corrupt
binary data when passed through the function.

This test demonstrates that corruption, and so fails currently, until
we fix the bug.
2011-05-31 15:39:26 -07:00
Carl Worth
6ca7d73239 test: Fix a misspelling in one of our test cases.
Not that it affects the correctness of the test, but it's nice to use
proper spelling. This kind of change could invalidate a signature on the
test message, but I think that would have happened previously when the
HTML part was added in the first place.
2011-05-31 15:19:12 -07:00
Dmitry Kurochkin
5a7a1d4997 test: add test for saving attachments using notmuch-show-save-part
Use .gz filenames for saved attachments in the tests to check
that Emacs does not re-compress the file.

Use test_expect_equal_file instead of test_expect_equal to avoid
binary output on the console.
2011-05-31 15:10:27 -07:00
Dmitry Kurochkin
59a9c36316 test: copy files in test_expect_equal_file instead of moving them
Before the change, test_expect_equal_file moved files it compared
in case of failure.  The patch changes it to copy the files
instead.  This allows testing non-temporary files which are
stored in git.

Note: the change should not result in new temporary files left
after the tests.  Test_expect_equal_file used to move files only
on failure, so callers had to cleanup them anyway.
2011-05-31 15:10:23 -07:00
Jameson Graef Rollins
82daf29187 Render all parts of multipart/encrypted when decrypting.
The primary goal here is to keep the decrypted output as similarly
structured as undecrypted output as possible.  Now, when decrypting
parts, only the original encrypted part is replaced by the it's
decrypted content.  If this part isn't itself a multipart, then all
part numbering should remain consistent during decryption.

The only draw back here is that the useless application/pgp-encrypted
sub-part of the multipart/encrypted part is also emitted.  But this
part can be easily ignored by clients.
2011-05-27 16:22:00 -07:00
Jameson Graef Rollins
5404519749 Do not replace multipart/signed part with content part when doing verification.
Some folks have complained about the part renumbering that occurs when
the entire multipart/signed part is replaced with the part contents
after verification.  This is primarily because it incurs an additional
computational cost to retrieve individual parts, since verification
has to be performed again to ensure that part numbering is consistent.
This patch simply leaves the full multipart/signed part as is.

The emacs crypto test is also updated to reflect this change.
2011-05-27 16:22:00 -07:00
Jameson Graef Rollins
1d6b49561f tag signed/encrypted during notmuch new
This patch adds the tag "signed" to messages with any multipart/signed
parts, and the tag "encrypted" to messages with any
multipart/encrypted parts.  This only occurs when messages are indexed
during notmuch new, so a database rebuild is required to have old
messages tagged.
2011-05-27 16:22:00 -07:00
Jameson Graef Rollins
627d752501 test: add crypto tests for signature verification and decryption
This adds a new "crypto" test script to the test suite to test
PGP/MIME signature verification and message decryption.  Included here
is a test GNUPGHOME with a test secret key (passwordless), and test
for:

  * signing/verification
  * signing/verification with full owner trust
  * verification with signer key unavailable
  * encryption/decryption
  * decryption failure with missing key
  * encryption/decryption + signing/verfifying
  * reply to encrypted message
  * verification of signature from revoked key

These tests are not expected to pass now, but will as crypto
functionality is included.
2011-05-27 16:22:00 -07:00
Jameson Graef Rollins
18967ef750 test: add notmuch_show_sanitize_all function that is a little more aggressive.
The old notmuch_show_sanitize function only scrubed part of the
filename.  This one scrubs the full filename, as well as the message
id.
2011-05-27 16:18:57 -07:00
Jameson Graef Rollins
b596fbbcd3 test: new test-lib function to test for equality between files
We need to be able to test for the presence of a newline at the end of
output.  There's no good way to capture trailing newlines in bash, so
redirecting output to a file is the next best thing.  This new
function should be used when testing for output that is expected to
have trailing newlines.

The next commit will demonstrate the use of this.
2011-05-27 16:18:57 -07:00
Dmitry Kurochkin
a0ebd5c5e4 test: use princ' instead of message' calls in emacs tests
The patch replaces all (message (buffer-string)) calls in emacs
tests with (princ (buffer-string)).  This avoids accidentally
interpreting '%' as format specifiers and makes code simpler
because we do not need to capture stderr.

Also, the patch works around an Emacs (23.3+1-1 on current Debian
Unstable) segfault in "Ensure that emacs doesn't drop results"
test.  Note: the segfault does not happen on every test run.
Though, it seems to be consistently reproducible if the test uses
300 messages instead of 30.  Hopefully, it is the crash described
in Emacs bug #8545 [1] which is already fixed.

[1] http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8545
2011-05-27 16:07:29 -07:00
Carl Worth
33cf04c6a5 Update some more recent tests to use /usr/bin/env to find bash
The recentl-applied patch had grown stale, so update the tests that had
been created since it was originally written.
2011-05-27 14:08:04 -07:00
Joel Borggrén-Franck
3fa843216c test: change "#!/bin/bash" to "#!/usr/bin/env bash" enhances portability
Change #!/bin/bash at start of tests to "#!/usr/bin/env bash". That way
systems running on bash < 4 can prepend bash >= 4 to path before
running the tests.
2011-05-27 14:03:28 -07:00
Dmitry Kurochkin
5297b361d1 test: add test-lib.el file with `visible-buffer-string' function
The patch adds test-lib.el file for Emacs tests auxiliary stuff.
Currently, it implements two functions: `visible-buffer-string'
and `visible-buffer-substring'.  These are similar to standard
counterparts without "visible-" prefix but exclude invisible
text.  The functions are not used anywhere at the moment but
should be useful for testing hiding/showing in the Emacs
interface.

Edited-by: Carl Worth <cworth@cworth.org> Fixed "basic" test to ignore
new test-lib.el file.
2011-05-26 14:13:48 -07:00
Dmitry Kurochkin
31b7c04ae1 test: add test for hiding/showing signature in notmuch-show view 2011-05-24 15:30:45 -07:00
Dmitry Kurochkin
d32b8b1715 test: fix expected output for emacs tests after the wash button label changes 2011-05-24 15:28:44 -07:00
Carl Worth
e267f9a467 test: Expand multipart test to cover "notmuch reply" as well
This gives coverage for the segmentation fault in "notmuch reply" that
was just fixed with the previous commit.
2011-05-24 12:19:18 -07:00
Jameson Graef Rollins
916c2aa624 test: Expand multipart test to cover part output in all formats.
The example multipart message is made a bit more complicated by adding
a message/rfc822 message, and the all parts are output and tested in
all output formats.
2011-05-24 12:19:18 -07:00
Jameson Graef Rollins
04927208fa test: force deletion of test remnants
This keeps the test from failing if only a subset of the remnants were
available for deletion, because e.g. only a subset of the tests were
run.
2011-05-23 14:55:27 -07:00
Jameson Graef Rollins
7058ac2bbe test: allow specifying tests to run with NOTMUCH_TESTS env var
This is useful for just running a specific subset of tests, ie:

NOTMUCH_TESTS=crypto make test
2011-05-23 14:55:27 -07:00
Jameson Graef Rollins
8b9fc33d99 test: remove hard-coded paths from multipart test
Small oversite, easily corrected.
2011-05-20 11:32:47 -07:00
David Edmondson
0898cfad5e emacs: Show cleaner `From:' addresses in the summary line.
Remove double quotes and flatten "foo@bar.com <foo@bar.com>" to
"foo@bar.com".

Edited-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net> (clean up
expected output for emacs tests).

Signed-off-by: Jameson Rollins <jrollins@finestructure.net>
2011-05-18 16:11:53 -07:00
Carl Worth
22443de789 test: Link to compat files when building program during "make test"
The compilation of the smtp-dummy program would fail if a build was
attempted on a system without getline. Fix this by simply including
the existing notmuch_compat_srcs variable when constructing the list
of source files for compiling smtp-dummy.
2011-05-18 13:15:46 -07:00
Carl Worth
362ab047c2 notmuch show: Properly nest MIME parts within mulipart parts
Previously, notmuch show flattened all output, losing information
about the nesting of the MIME hierarchy. Now, the output is properly
nested, (both in the --format=text and --format=json output), so that
clients can analyze the original MIME structure.

Internally, this required splitting the final closing delimiter out of
the various show_part functions and putting it into a new
show_part_end function instead. Also, the show_part function now
accepts a new "first" argument that is set not only for the first MIME
part of a message, but also for each first MIME part within a series
of multipart parts. This "first" argument controls the omission of a
preceding comma when printing a part (for json).

Many thanks to David Edmondson <dme@dme.org> for originally
identifying the lack of nesting in the json output and submitting an
early implementation of this feature. Thanks as well to Jameson Graef
Rollins <jrollins@finestructure.net> for carefully shepherding David's
patches through a remarkably long review process, patiently explaining
them, and providing a cleaned up series that led to this final
implementation. Jameson also provided the new emacs code here.
2011-05-17 15:58:57 -07:00
Carl Worth
c51d5b3cdb notmuch show: Include output for the enclosing multipart part of a MIME mail
Previously, the outer multipart part of any multipart/mixed,
multipart/signed, etc. MIME message was silently omitted from the
"notmuch show" output. This prevented any client from correctly
determining to which parts a signature applies, for example.

Now, we actually emit these parts as their own parts. The output is
still flattened---the contained parts are not yet included "within"
the multipart part---so it's still not possible to determine to which
parts a signature applies, but this is one step along the path.

The test suite is updated to reflect this change, (though we'll
eventually want to fix the emacs interface to not display buttons for
the multipart enclosure parts as there's nothing useful for the user
to actually do with them).
2011-05-17 14:51:06 -07:00
Carl Worth
d67f755497 test: Add a test of "notmuch show" with a multipart message
This tests "notmuch show" with both --format=text and --format=json on
a message with some non-trivial MIME multipart nesting, (multiple parts
within a multipart/mixed part which is within a multipart/signed part).

The test captures the current behavior (where only the leaf nodes of
the MIME structure are emitted as a flat list---the multipart parts
are effectively ignored). We plan to soon change the json output at
least to emit an actual hierarchy matching the MIME structure, (at
which point we will update this test).
2011-05-16 22:21:31 -07:00
Carl Worth
d313bfb59b test: Mark the search-insufficient-from-quoting tests to expect success
Theses were expected failures only due to a bug in GMime (with
versions of GMime before 2.4.18). As of GMime version 2.4.18 this bug
is fixed and these tests now pass.
2011-04-25 15:16:49 -07:00
Carl Worth
708c4f46ca emacs: Don't drop error messages from "notmuch search"
With the previous commit, unexpected output before or between search results
would be displayed. However, trailing junk from the "notmuch search" output
would still be silently swallowed.

The most common case for an error message from "notmuch search" would be
an invalid command-line, and in that case, there would be no search results
and the trailing error message would get swallowed.

We fix the process sentinel to check for leftover data and add it to the
final buffer. We also add a test case to ensure this works.
2011-03-10 16:53:46 -08:00
Carl Worth
44d3c57e2a emacs: Display any unexpected output from notmuch search
Rather than silently swallowing unexpected output, the emacs interface will now
display it. This will allow error messages to actually arrive at the emacs
interface (though not in an especially pretty way). This also allows for easier
investigation of the inadvertent swallowing of search results that span page
boundaries (as demonstrated by the recent added emacs-large-search-buffer test).

The page-boundary bug has been present since a commit from 2009-11-24:
93af7b5745

Many thanks to Thomas Schwinge for tracking that bug down and
contributing the test for it.
2011-03-10 15:18:40 -08:00
Carl Worth
4e414e2a5a Rename/rewrite the new emacs-forgetfulness test (to emacs-large-search-buffer)
The new name is more descriptive of the bug being tested. Also, the test
is rewritten slightly so that it's much more plain to see how the bug
manifests itself, (that messages are droped from the emacs result at
regular intervals). Primarily, this is by collapsing the large blobs
used to inflate the message subjects.
2011-03-10 13:22:04 -08:00
Thomas Schwinge
a3bf541e2b New test: Emacs' forgetfulness.
Signed-off-by: Thomas Schwinge <thomas@schwinge.name>
2011-03-10 12:07:53 -08:00