Commit graph

39 commits

Author SHA1 Message Date
David Bremner
ec26eeaeec test: support testing notmuch as installed
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-21 07:41:50 -03:00
David Bremner
6a7b61b1d5 test: add (back) upgrade tests
In ee897cab8b the upgrade tests from pre v3 databases were
removed. The reasons for that are still valid, but we should still
test the code paths that do the upgrade, and it is relatively
straightforward to do that for v3 to v3 upgrades.
2021-01-17 13:24:04 -04:00
David Bremner
25f9a42287 test: update README to reflect dropping upgrade tests
These test databases have been unneeded since ee897cab8.
2020-08-16 10:41:44 -03:00
Jameson Graef Rollins
eeff431996 tests: environment variable to specify that tests should be serialized
If NOTMUCH_TEST_SERIALIZE is non-null all tests will be run in series,
rather than in parallel.
2019-05-07 06:55:31 -03:00
Jani Nikula
d455c8b74a test: remove --root option and fix TMP_DIRECTORY cleanup
The primary motivation here is to fix TMP_DIRECTORY cleanup prior to
running each test when the current working directory is not the test
subdirectory. Tests with failures would leave their TMP_DIRECTORY
directory behind for debugging, and repeated out-of-tree test runs
would have old temp directories. (This lead to e.g. T310-emacs.sh
hanging because emacs would prompt for overwriting files.)

We remove the likely anyway defunct --root test option while at it,
just to be on the safe side when doing 'rm -rf' on the TMP_DIRECTORY.
2017-10-21 11:32:20 -03:00
Daniel Kahn Gillmor
87bdfbc91f Fix orthography 2017-07-18 06:50:44 -03:00
Mikhail
9b7dbed58e tests: add compatibility layer
Make test-lib-common.sh load test-lib-<$PLATFORM>.sh to create
additional shim for platform specifics.

Use test-lib-FREEBSD.sh to call GNU utilities instead of native ones.

- amended by db following Tomi's suggestions
2017-03-25 07:56:52 -03:00
Jani Nikula
0497d695ca test: require test_begin_subtest before test_expect_code
Unify the subtests by requiring test_begin_subtest before
test_expect_code. (Similar change for test_expect_success has already
been done.)

This increases clarity in the test scripts by having a separate line
for the start of the subtest with the heading, and makes it possible
to simplify the test infrastructure by making all subtests similar.
2017-03-09 09:03:40 -04:00
Jani Nikula
d0cd253b37 test: require test_begin_subtest before test_expect_success
Unify the subtests by requiring test_begin_subtest before
test_expect_success. (Similar change for test_expect_code will
follow.)

This increases clarity in the test scripts by having a separate line
for the start of the subtest with the heading, and makes it possible
to simplify the test infrastructure by making all subtests similar.
2017-03-09 09:01:21 -04:00
Tomi Ollila
b183f2635e test: copyright information updates
Files in test directories had only copyright of a single individual,
of which code was adapted here as a base of the test system.
Since then many Notmuch Developers have contributed to the test
system, which is now acknowledged with a constant string in some
of the test files.

The README file in test directory instructed new files contain a
copyright notice, but that has never been done (and it is also not
needed). To simplify things a bit (and lessen confusion) this
instruction is now removed.

As a side enchangement, all of the 3 entries in the whole source
tree cd'ing to `dirname` of "$0" now uses syntax cd "$(dirname "$0")".
This makes these particular lines work when current working directory
is e.g. /c/Program Files/notmuch/test/.
(Probably it would fail elsewhere, though.)
2016-05-19 07:56:58 -03:00
Tomi Ollila
f8cc320694 test/README: have matching test script file names
A while ago test script names were changed to format
Tddd-basename.sh. Update README to reflect that.

While at it, included some small requirements updates.
2016-03-04 20:45:19 -04:00
David Bremner
3cf7ed26c0 test suite: don't consider skipped individual tests as failing
It isn't completely clear what we want to do here, but

1) We currently don't fail if we skip a whole test file (mainly because
we neglect to count those skipped tests properly). This change at least
makes the two kinds of skipping consistent.

2) Automated build environments may have good reasons for building with
a minimal set of prereqs, and we don't want to discourage running our
test suite by breaking builds.
2015-09-25 09:18:22 -03:00
Tomi Ollila
02a2eeb427 test: make script exit (1) if it "fails" to source (.) a file
The files (test) scripts source (with builtin command `.`) provides
information which the scripts depend, and without the `source` to
succeed allowing script to continue may lead to dangerous situations
(e.g. rm -rf "${undefined_variable}"/*).

At the end of all source (.) lines construct ' || exit 1' was added;
In our case the script script will exit if it cannot find (or read) the
file to be sourced. Additionally script would also exits if the last
command of the sourced file exited nonzero.
2015-08-07 21:56:39 +02:00
David Bremner
1e69afe8af test: add support for compiling and running C snippets
This is to limit the copy-pasta involved in running C tests. I decided
to keep things simple and not try to provide an actual C skeleton.

The setting of LD_LIBRARY_PATH is to force using the built libnotmuch
rather than any potential system one.
2015-03-29 00:33:56 +01:00
David Bremner
8413582b6e test: add machinery to download and verify databases
Note that it is intentional that the checksum file is not
downloaded. The intent is to check those into git.
2014-03-11 19:51:22 -03:00
Tomi Ollila
88e6a2995a test: implement and document NOTMUCH_TEST_QUIET variable usage
When NOTMUCH_TEST_QUIET environment variable is set to non-null value
messages when new test script starts and when test PASSes are disabled.
This eases picking the cases when tests FAIL (as those are still printed).
2013-12-09 23:29:11 +08: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
Austin Clements
d59d9c8152 test: Make the emacsclient binary user-configurable
And require that if TEST_EMACS is specified, so is TEST_EMACSCLIENT.

Previously, the test framework always used "emacsclient", even if the
Emacs in use was overridden by TEST_EMACS.  This causes problems if
both Emacs 23 and Emacs 24 are installed, the Emacs 23 emacsclient is
the system default, but TEST_EMACS is set to emacs24.  Specifically,
with an Emacs 24 server and an Emacs 23 client, emacs tests that run
very quickly may produce no output from emacsclient, causing the test
to fail.

The Emacs server uses a very simple line-oriented protocol in which
the client sends a request to evaluate an expression and the server
sends a request to print the result of evaluation.  Prior to Emacs bzr
commit 107565 on March 11th, 2012 (released in Emacs 24.1), if
multiple commands were sent to the emacsclient between when it sent
the evaluation command and when it entered its receive loop, it would
only process the first response command, ignoring the rest of the
received buffer.  This wasn't a problem with the Emacs 23 server
because it sent only the command to print the evaluation result.
However, the Emacs 24 server first sends an unprompted command
specifying the PID of the Emacs server, then processes the evaluation
request, then sends the command to print the result.  If the
evaluation is fast enough, it can send both of these commands before
emacsclient enters the receive loop.  Hence, if an Emacs 24 server is
used with an Emacs 23 emacsclient, it may miss the response printing
command, ultimately causing intermittent notmuch test failures.
2012-11-29 09:24:12 -04:00
Tomi Ollila
3977b250cd Fixed 2 misspellings of word 'separate'
"Seperate: The second most common misspelling on the Internet..."
(from http://www.re-vision.com/spelling/separate.html).

s/seperate/separate/ in debian/NEWS.Debian & test/README done.
2012-11-16 15:50:55 -04:00
Dmitry Kurochkin
1ffb382961 test: make test_expect_equal_file() arguments flexible
Before the change, test_expect_equal_file() function treated the first
argument as "actual output file" and the second argument as "expected
output file".  When the test fails, the files are copied for later
inspection.  The first files was copied to "$testname.output" and the
second file to "$testname.expected".  The argument order for
test_expect_equal_file() is often wrong which results in confusing
diff output and incorrectly named files.

The patch solves the issue by changing test_expect_equal_file() to
treat arguments just as two files, without any special properties
(like "actual" and "expected").  The file names for copying is now
based on the given file name: "$testname.$file1" and
"$testname.$file2".  E.g. if test_expect_equal_file() is called with
"OUTPUT" and "EXPECTED", the copied files can be named
"emacs.1.OUTPUT" and "emacs.1.EXPECTED".

The down side of this approach is that diff argument order depends on
test_expect_equal_file() argument order.  So sometimes we get diff
from expected to actual results, and sometimes the other way around.
But the files are always named correctly.
2012-09-01 23:09:26 -03:00
David Edmondson
260975e8af test: Add `test_emacs_expect_t'.
Add a new test function to allow simpler testing of emacs
functionality.

`test_emacs_expect_t' takes one argument - a lisp expression to
evaluate. The test passes if the expression returns `t', otherwise it
fails and the output is reported to the tester.
2012-01-25 07:25:44 -04:00
Ethan Glasser-Camp
8ae753f30f Document external dependencies in the test suite
Add an explicit note to the README explaining what programs are
necessary and the perhaps-surprising behavior of skipping tests if
they aren't present.

Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>
2012-01-21 08:28:47 -04:00
David Bremner
bed6022ed1 test: allow user to choose which emacs to run tests with.
As we start to pay more attention to emacs24, it helps to be able to
select a different version of emacs to run the tests with to verify
version specific bugs.

A separate variable TEST_EMACS is needed to avoid being overwritten by the
make variable EMACS in Makefile.config

For what it's worth, the value of emacs is chosen at the time
tmp.emacs/run_emacs is created, so is fixed for all subtests.
2011-12-28 15:50:04 -04:00
Dmitry Kurochkin
e994bb28df test: add functions to count how much times notmuch was called
The patch adds two auxiliary functions and a variable:

  notmuch_counter_reset
  $notmuch_counter_command
  notmuch_counter_value

They allow to count how many times notmuch binary is called.
notmuch_counter_reset() function generates a script that counts how
many times it is called and resets the counter to zero.  The function
sets $notmuch_counter_command variable to the path to the generated
script that should be called instead of notmuch to do the counting.
The notmuch_counter_value() function returns the current counter
value.
2011-12-07 20:03:00 -04:00
David Bremner
7bf1f6e85a test: add test-binaries target
The goal here is to have a simple way of making sure all of the
binaries needed to run tests are available.
2011-12-06 09:37:44 -04:00
David Bremner
3ee541ab31 test: remove documentation for test_expect_equal_failure.
The actual function was deleted in commit 4cc67276
2011-09-10 14:54:56 -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
Dmitry Kurochkin
0db3a4d5be test: update documentation for test_emacs in test/README
Update test_emacs documentation in test/README according to the latest
changes in emacs tests.  Move the note regarding setting variables
from test/emacs to test/README.
2011-09-10 10:12:03 -03:00
Jameson Graef Rollins
a31ad0bd01 test: document test_expect_equal_file
This test was not properly documented when it was originally added (my
bad).
2011-06-29 15:36:43 -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
Pieter Praet
18bf91def9 fix sum moar typos [text files]
Various typo fixes in auxiliary text files included with the source,
(README, TODO, etc.).

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

Edited-by: Carl Worth <cworth@cworth.org> Restricted to just text files.
2011-06-23 15:40:50 -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
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
9c7fd320c9 test/README: Document add_email_corpus (and add_message/generate_message)
While adding the documentation here for add_email_corpus I noticed
that the other email-adding functions in test-lib.sh were not yet
documented here, so add all of that documentation.
2010-09-20 16:41:31 -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
029a105da3 test/README: Update to become notmuch-specific rather than git-specific
This file was obviously describing the git test suite previously, and
would have been very hard to understand in the context of the notmuch
test suite. HOpefully it's easier to follow now.
2010-09-20 14:06:38 -07:00
Michal Sojka
223987bace Update test framework for use with notmuch
This removes Git specific things from the test-lib.sh and adds helper
functions for notmuch taken from Carl's notmuch-test script. README is
also slightly modified to reflect the current state.

Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
2010-09-16 15:56:44 -07:00
Michal Sojka
0083854b12 Copy test framework from Git
Git uses a simple and yet powerful test framework, written in shell.
The framework is easy to use for both users and developers so I think
it would help if it is used in notmuch as well.

This is a copy of Git's test framework from commit
b6b0afdc30e066788592ca07c9a6c6936c68cc11 in git repository.

Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
2010-09-16 15:56:44 -07:00