Commit graph

55 commits

Author SHA1 Message Date
Tomi Ollila
2f2ea8a49a test: use dtach(1) instead of screen(1) in emacs tests
dtach is simpler than screen and is not setuid/setgid program so
TMPDIR does not get cleared by dynamic loader when executed
2011-11-11 18:24:53 -05:00
Dmitry Kurochkin
746a13e6f4 test: avoid using screen(1) configuration files
Set SCREENRC and SYSSCREENRC environment variables to "/dev/null"
as suggested by Jim Paris to avoid potential problems with
screen(1) configuration files.
2011-11-05 21:54:40 -03:00
Dmitry Kurochkin
a1ea4e914f test: run emacs inside screen
Before the change, emacs run in daemon mode without any visible
buffers.  Turns out that this affects emacs behavior in some
cases.  In particular, `window-end' function returns `point-max'
instead of the last visible position.  That makes it hard or
impossible to implement some tests.  The patch runs emacs in a
detached screen(1) session.  So that it works exactly as if it
has a visible window.

Note: screen terminates when emacs exits.  So the patch does not
introduce new "running processes left behind" issues.
2011-11-05 20:49:27 -03:00
David Bremner
f4148e9d21 test/test-lib.sh: update comments
- explain test_expect_equal_file
- remove mention of test_expect_failure, since that function was removed.

Based on id:"1317317811-29540-1-git-send-email-thomas@schwinge.name"
2011-10-22 19:43:02 -03:00
Austin Clements
003e718020 test: Report test failures from test_expect_*
This makes test_expect_* return non-zero if the test fails, so the
caller can make decisions based on this, such as setting test
prerequisites.
2011-09-12 23:36:00 -03:00
Austin Clements
5ae1b9c328 test: Fix message when skipping test_expect_equal* tests
For these types of tests, the test name is previously recorded in a
variable, not passed to the test function, so pass this variable to
test_skip.
2011-09-12 23:35:59 -03:00
David Bremner
22af786838 test: reset test_subtest_known_broken_ after each success/failure.
This means that test_subtest_known_broken needs to be called before
every known broken subtest, which is no different than what is
documented for the test_begin_subtest case.

The assumption is that every test ends up calling either skipping,
calling test_ok_ or test_failure_ and and the latter in turn delegate
to the known_broken versions in the case where
test_subtest_known_broken_ is set.
2011-09-12 23:35:21 -03:00
Dmitry Kurochkin
4cc6727688 test: improve known broken tests support
There is existing support for broken tests.  But it is not convenient
to use.  The primary issue is that we have to maintain a set of
test_expect_*_failure functions which are equivalent to the normal
test_expect_* counterparts except for what functions are called for
result reporting.  The patch adds test_subtest_known_broken function
which marks a subset as broken, making the normal test_expect_*
functions behave as test_expect_*_failure.  All test_expect_*_failure
functions are removed.  Test_known_broken_failure_ is changed to
format details the same way as test_failure_ does.

Another benefit of this change is that the diff when a broken test is
fixed would be small and nice.

Documentation is updated accordingly.
2011-09-10 10:13:27 -03:00
Austin Clements
47afbdfb79 test: Nix increment_mtime.
With the fix for the mtime race, this workaround is no longer
necessary.
2011-06-29 15:26:45 -07:00
Dmitry Kurochkin
a854d06e92 test: use emacsclient(1) for Emacs tests
Before the change, every Emacs test ran in a separate Emacs
instance.  Starting Emacs many times wastes considerable time and
it gets worse as the test suite grows.  The patch solves this by
using a single Emacs server and emacsclient(1) to run multiple
tests.  Emacs server is started on the first test_emacs call and
stopped when test_done is called.  We take care not to leave
orphan Emacs processes behind when test is terminated by whatever
reason: Emacs server runs a watchdog that periodically checks
that the test is still running.

Some tests need to provide user input.  Before the change, this
was done using echo(1) to Emacs stdin.  This no longer works and
instead `standard-input' variable is set accordingly to make
`read' return the appropriate string.
2011-06-28 17:10:55 -07:00
Carl Worth
6ea26cfb81 test: Increment mtime when delivering a message with emacs_deliver_message
Without this, mail messages delivered by emacs_deliver_message might
not be seen by the next invocation of "notmuch new", (which can lead
to test-suite failures if emacs_deliver_message is fast enough).
2011-06-28 17:10:55 -07:00
Mark Anderson
eb4cf465a5 test:Improve test behaviors when --root is used
Change add_email_corpus, emacs_deliver_message and tests to use
$TEST_DIRECTORY instead of '..'.

This improves the behavior of the usage of --root=<dir>, as the
assumption of what '..' means will usually be incorrect.

Document -root option in README and update valgrind to work with
-root.
2011-06-28 16:01:56 -07:00
Dmitry Kurochkin
273d896097 test: generate run_emacs script once on test startup
Instead of generating auxiliary run_emacs script every time
test_emacs is run, do it once in the beginning of the test.

Also, use absolute paths in the script to make it more robust.
2011-06-28 15:06:47 -07:00
Dmitry Kurochkin
0cc5483a9c test: set variables using let' instead of setq' in Emacs tests
Using `setq' for setting variables in Emacs tests affect other
tests that may run in the same Emacs environment.  Currently it
works because each test is run in a separate Emacs instance.  But
in the future multiple tests will run in a single Emacs instance.
The patch changes all variables to use `let', so the scope of the
change is limited to a single test.
2011-06-28 15:06:47 -07:00
Dmitry Kurochkin
caeb05493d test: wrap and indent test_emacs calls
Most test_emacs calls have long arguments that consist of many
expressions.  Putting them on a single line makes it hard to read
and produces poor diff when they are changed.  The patch puts
every expression in test_emacs calls on a separate line.
2011-06-28 15:06:47 -07:00
Dmitry Kurochkin
dd75723921 test: cleanup test_emacs
Move auxiliary function definition and configuration from command
line to test-lib.el.
2011-06-28 15:06:47 -07:00
Dmitry Kurochkin
5806c471de test: do not set `message-signature' in test_emacs
It is no longer needed since tests are run in a temporary home
directory instead of the user's one.
2011-06-28 15:06:47 -07:00
Pieter Praet
8bb6f7869c fix sum moar typos [comments in source code]
Various typo fixes in comments within the source code.

Signed-off-by: Pieter Praet <pieter@praet.org>

Edited-by: Carl Worth <cworth@cworth.org> Restricted to just
source-code comments, (and fixed fix of "descriptios" to "descriptors"
rather than "descriptions").
2011-06-23 15:58:39 -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
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
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
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
Thomas Schwinge
21e97c50d4 Clarify usage of `additional_headers' in test/test-lib.sh:generate_message.
Signed-off-by: Thomas Schwinge <thomas@schwinge.name>
2011-01-28 15:19:19 +10:00
Carl Worth
ac1ba43666 Fix misspelling in a comment.
Just a simple change I noticed in passing.
2011-01-15 15:37:43 -08:00
Carl Worth
b41aab78f2 test: Leave tmp.<testname> for broken tests
Previously, this directory was only preserved for failing tests. But
it's important to be able to easily debug known-broken tests, so
preserve the actual vs. expected output for those as well.
2010-12-07 16:23:20 -08:00
Austin Clements
04d633c285 Fix handling of broken tests.
Make sure to close the subtest for test_expect_equal_failure, just
like in test_expect_equal.
2010-12-07 16:21:23 -08:00
Michal Sojka
556986511c test: Detect unfinished subsets
When test_begin_subtest is not followed by corresponding test_expect_equal,
the output of the rest of the test script is errornously suppressed. Add
code to detect these bugs in test scripts.
2010-11-16 11:28:06 -08:00
Michal Sojka
c8d51e2912 test: Add trailing newline to error messages
The newline was removed from say_color in commit 222926ab to allow
printing test status in the beginning of the line. Error messages are
never followed by other text so we add the newline to error function.
2010-11-16 11:28:06 -08:00
Michal Sojka
ac9dbb47de test: Better handling of stdout and stderr
Git-style tests (test_expect_success etc.) suppress stdout and stderr
unless -v is given. Notmuch-style tests (created by test_begin_subtest
and test_expect_equal) do not have this behavior so implement it the
same.

Additionally, for both test styles, the test-lib.sh is changed so that
the content of suppressed stdout and stderr is shown in case of failed
test.

Finally a test for this functionality is added to basic tests.
2010-11-16 11:28:06 -08:00
Michal Sojka
736ac42c45 Tests for maildir synchronization
Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
2010-11-10 13:09:32 -08:00
Carl Worth
08c735c58e test: Don't strip portions of test name after '-' for temporary files.
We have test names like maildir-sync now, so it's cleaner if the
temporary files created are named things like maildir-sync-10.out
rather than maildir-10.out. Presumably the extra stripping here came
from naming conventions in git's test suite.
2010-11-10 13:09:31 -08:00
Carl Worth
fd16b37dc1 test: Don't mess with user's HOME directory
This was too rude of a thing to do and could easily introduce
problems, (as reported by Rob Browning whose environment required some
HOME-specific things for shell startup).

Instead, implement more focused changes to ensure that particular file
in $HOME don't cause problems. Specifically, we fix known problems
with ~/.signature and ~/.mailrc here.
2010-11-05 17:43:27 -07:00
Carl Worth
a09921bdfb test: Generate a little run_emacs script to help debug any failures.
After any emacs test failure, the tmp.emacs directory will have this
run_emacs script in it which the user can use to run emacs within the
test suite environment, (pointing at the test suite's notmuch
database, using the local notmuch command-line program, and the local
notmuch emacs lisp code).
2010-11-05 17:19:51 -07:00
Carl Worth
20018a0c09 test: Emit a friendly error message if run with bash < 4.0.
The bash code in the test suite is using associative arrays which were
only added to bash as of release 4.0.

If the test suite is run with an older bash, we now immediately error
out and explain the situation, (instead of emitting confusing error
messages and failing dozens of tests, which is what happened before
this change).
2010-10-28 12:07:42 -07:00
Carl Worth
f30200a429 test: Set alternate HOME during tests.
We set the HOME environment variable to the test directory to avoid
the tests relying on any configuration files from the test author's
own home directory, (such as ${HOME}/.emacs or similar).
2010-10-27 10:40:44 -07:00
Carl Worth
a8aa437bbc test: Add simple tests for navigating notmuch-hello and notmuch-search views
We simulate the act of selecting the "inbox" saved search from
notmuch-hello and the act of selecting a desired thread from the
notmuch-search results.

The test for the navigation of notmuch-hello is currently marked as
BROKEN since its output is in the opposite order compared to the
'(notmuch-search "tag:inbox")' test. This question of ordering is a
currently open issue on the notmuch mailing list, so we'll let the
test suite reflect that for now.

Finally, this commit also abstracts some common emacs lisp code,
(waiting for the current buffer's process to complete), into a new
notmuch-test-wait function that is made available to anything calling
test_emacs.
2010-10-22 17:02:07 -07:00
Carl Worth
6307f306fd test: Add a new test_expect_equal_failure
Which allows us to have a known-broken test that would otherwise use
test_expect_equal.
2010-10-22 17:01:34 -07:00
Carl Worth
209e756cd4 test: Add a new test_emacs function to test-lib.sh
This should be quite handy for doing automated testing of the
emacs-based functionality in notmuch. This function invokes emacs with
the necessary command-line arguments, (to run in batch mode with no
local initialization, to load the notmuch code from the source
directory, and to ensure an 80-column width).
2010-10-22 12:09:56 -07:00
Carl Worth
b97a763dc1 test: Fix add_email_corpus function to be quiet.
This simply avoids some unneeded noise in the "make test" output.
2010-10-22 12:04:41 -07:00
Carl Worth
5497b01c27 test: Fix the search and dump-restore tests to operator on non-empty mail store.
We do this with a new add_email_corpus function that establishes a
mail store with 50 messages from the notmuch mailing list.
2010-09-20 16:40:35 -07:00
Carl Worth
ba9f9efc9a test: Remove useless NOTMUCH variable (in favor of simply "notmuch")
When the NOTMUCH variable was originally invented it was used as an
explicit path to the notmuch binary being tested. Today, the test
suite sets the PATH variable instead, so the NOTMUCH variable always
has a value of simply "notmuch".

We simplifying that by using the constant value rather than the
continual variable reference.
2010-09-20 16:15:08 -07:00
Carl Worth
129a4417e3 test: Remove some dead code in test-lib.sh
These assignements weren't being used at all and were just confusing me,
(the real assignments happen later on in the file).
2010-09-20 16:09:20 -07:00
Carl Worth
4813ee41d6 test: Print section names, and rename all test sections
Now that we can usefully pass section names via the NOTMUCH_SKIP_TESTS
environment variable, it's useful to actually print those names out
for the user. Then, since we're now printing these names, let's use
nicer names, (not excessively long but also not using abbreviations
like "msg").
2010-09-20 14:38:56 -07:00
Carl Worth
169639e606 test: Make the --valgrind option useful, (and drop --verbose).
In order for --valgrind to be useful, we drop noisy additional output of
all of the commands being executed in verbose mode. This makes --verbose
alone quite useless, so we don't document it any more.

Also, add a zlib valgrind suppression that was showing up frequently in the
test suite.
2010-09-20 14:28:13 -07:00
Carl Worth
16a6301ade test: Rename GIT_SKIP_TESTS to NOTMUCH_SKIP_TESTS
By scanning test-lib.sh for occurrences of "git" or "GIT", I found
that most of those are internal things, (like the GIT_TEST_TEE_STARTED
variable). But GIT_SKIP_TESTS is part of the user-interface to the
test suite, so we rename it to reference notmuch rather than git.

Also, the GIT_TRACE warning is git-specific, so we drop that as well.
2010-09-20 13:54:57 -07:00
Carl Worth
60c599036e test: Fix test suite so that --valgrind option works.
The output is ugly, and we need a better suppressions file, but this
is at least a start.
2010-09-20 13:44:32 -07:00
Carl Worth
c92ad8bf6a test: Rework test-suite input to avoid ulti-command strings
The original git test suite works by concatenating many commands into
a very long string (each separated by &&). This is painful to work
with since it prevents the editor from helping by parsing the shell
script, indenting, colorizing, etc.

Instead, we switch this back to something like the original notmuch
test suite, and add two new functions to test-lib.sh
(test_begin_subtest and test_expect_equal) to support these.

This also fixes the test suite to once again display the diff when a
test fails to generate the expected input.
2010-09-17 15:25:39 -07:00