summaryrefslogtreecommitdiff
path: root/test/test-lib.sh
AgeCommit message (Collapse)Author
2011-12-18test: optionally print subtest numberDavid Bremner
The idea is that $test_count could be used in tests to label intermediate files. The output enabled by this patch (and --debug) helps figure out which OUTPUT.nn file belongs to which test in case several subtests write to OUTPUT.$test_count
2011-12-11test: use python2 instead of python if availableThomas Jost
Some distros (Arch Linux) ship Python as python2 and Python 3 as python. Checking for python2 is necessary for the Python tests to work on these platforms.
2011-12-11test: add a function to run Python testsThomas Jost
The new test_python() function makes writing Python tests a little easier: - it sets the environment variables as needed - it redirects stdout to the OUTPUT file (like test_emacs()). This commit also declares python as an external prereq. The stdout redirection is required to avoid trouble when running commands like "python 'script' | sort > OUTPUT": in such a case, any error due to a missing external prereq would be "swallowed" by sort, resulting to a failed test instead of a skipped one.
2011-12-07test: add functions to count how much times notmuch was calledDmitry Kurochkin
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-11-30test: fix error messages for missing binary dependenciesDmitry Kurochkin
The fake missing binary functions check if the binary has already be added to the diagnostic message to avoid duplicates. Unfortunately, this check was buggy because the message string does not have the trailing space.
2011-11-30test: fix spurious output from missing external binaries functionsDmitry Kurochkin
The grep(1) command used in the fake binary functions was missing the quiet option.
2011-11-30test: add missing escape backslash in test_declare_external_prereq()Dmitry Kurochkin
2011-11-30test: fix test_require_external_prereq()Dmitry Kurochkin
test_missing_external_prereq_${binary}_ variable indicates that the binary is missing. It must be set in test_declare_external_prereq() outside of the fake $binary() function.
2011-11-27test: check if emacs is available in the beginning of test_emacsDmitry Kurochkin
Unfortunately, this is needed to avoid the emacs waiting loop.
2011-11-27test: add function to explicitly check for external dependenciesDmitry Kurochkin
Useful when binary is called indirectly (e.g. from emacs).
2011-11-27test: declare external dependencies for the testsDmitry Kurochkin
That are: dtach(1), emacs(1), emacsclient(1), gdb(1) and gpg(1).
2011-11-27test: skip all subtests if external dependencies are missing during initDmitry Kurochkin
Some tests (e.g. crypto) do a common initialization required for all subtests. The patch adds a check for missing external dependencies during this initialization. If any prerequisites are missing, all subtests are skipped. The check is run on the first call of test_reset_state_ function, so no changes for the tests are needed.
2011-11-27test: fix "skipping test" verbose outputDmitry Kurochkin
2011-11-27test: add support for external executable dependenciesDmitry Kurochkin
There is existing support for general prerequisites in the test suite. But it is not very convenient to use: every test case has to keep track for it's dependencies and they have to be explicitly listed. The patch aims to add better support for a particular type of external dependencies: external executables. The main idea is to replace missing external binaries with shell functions that have the same name. These functions always fail and keep track of missing dependencies for a subtest. The result reporting functions later can check that an external binaries are missing and correctly report SKIP result instead of FAIL. The primary benefit is that the test cases do not need to declare their dependencies or be changed in any way.
2011-11-27test: add test state reset to test_expect_* functions that did not have itDmitry Kurochkin
2011-11-27test: set EMACS_SERVER variable only after dtach(1) was successfully startedDmitry Kurochkin
Otherwise, we can set the EMACS_SERVER and return with an error. And subsequent calls to test_emacs would assume that emacs server is running.
2011-11-27test: move subtest variables reset into a dedicated functionDmitry Kurochkin
Currently, there is only one such variable test_subtest_known_broken_. But more will be added in the future.
2011-11-26test: remove executable permissions from test-lib.shDmitry Kurochkin
It is not supposed to be run, only sourced.
2011-11-18test: attempt to send QUIT to smtp-dummy in case mail send failedTomi Ollila
If mail sending from emacs fails before it has chance to connect to the smtp-dummy mail server, the opportunistic QUIT message sending makes smtp-dummy to exit.
2011-11-17test: create dtach's session socket in $TEST_TMPDIRTomi Ollila
Due to 108-character limit in unix domain socket path this change is required; it is more probable that length of ${TMPDIR:-/tmp} is shorter than length of path to the current directory of notmuch test source directory. One can expect to create reasonable-length unix domain sockets wherever $TMPDIR points to.
2011-11-17test: create TEST_TMPDIR for holding temporary filesTomi Ollila
The TEST_TMPDIR if first needed to hold dtach's socket (due to 108-character limit in socket file names). Later it can be used to hold other temporary files; directory deleted at exit.
2011-11-13test: do not hide test_emacs errorsDmitry Kurochkin
Do not redirect test_emacs stderr to /dev/null. Test_emacs uses emacsclient(1) now and it does not print unwanted messages (like those from `message') to stderr. But it does print useful errors, e.g. when emacs server connection fails, given expression is not valid or undefined function is called.
2011-11-12exec emacs at the end of run_emacs scriptTomi Ollila
In the last line of run_emacs, exec the emacs process. With one fork less the process list is (also) neater.
2011-11-11test: use dtach(1) instead of screen(1) in emacs testsTomi Ollila
dtach is simpler than screen and is not setuid/setgid program so TMPDIR does not get cleared by dynamic loader when executed
2011-11-05test: avoid using screen(1) configuration filesDmitry Kurochkin
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-05test: run emacs inside screenDmitry Kurochkin
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-10-22test/test-lib.sh: update commentsDavid Bremner
- 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-09-12test: Report test failures from test_expect_*Austin Clements
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-12test: Fix message when skipping test_expect_equal* testsAustin Clements
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-12test: reset test_subtest_known_broken_ after each success/failure.David Bremner
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-10test: improve known broken tests supportDmitry Kurochkin
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-06-29test: Nix increment_mtime.Austin Clements
With the fix for the mtime race, this workaround is no longer necessary.
2011-06-28test: use emacsclient(1) for Emacs testsDmitry Kurochkin
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-28test: Increment mtime when delivering a message with emacs_deliver_messageCarl Worth
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-28test:Improve test behaviors when --root is usedMark Anderson
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-28test: generate run_emacs script once on test startupDmitry Kurochkin
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-28test: set variables using `let' instead of `setq' in Emacs testsDmitry Kurochkin
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-28test: wrap and indent test_emacs callsDmitry Kurochkin
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-28test: cleanup test_emacsDmitry Kurochkin
Move auxiliary function definition and configuration from command line to test-lib.el.
2011-06-28test: do not set `message-signature' in test_emacsDmitry Kurochkin
It is no longer needed since tests are run in a temporary home directory instead of the user's one.
2011-06-23fix sum moar typos [comments in source code]Pieter Praet
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-01test: Create and set temporary home directoryFlorian Friesdorf
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-05-31test: copy files in test_expect_equal_file instead of moving themDmitry Kurochkin
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-27test: add crypto tests for signature verification and decryptionJameson Graef Rollins
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-27test: add notmuch_show_sanitize_all function that is a little more aggressive.Jameson Graef Rollins
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-27test: new test-lib function to test for equality between filesJameson Graef Rollins
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-27test: change "#!/bin/bash" to "#!/usr/bin/env bash" enhances portabilityJoel Borggrén-Franck
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-26test: add test-lib.el file with `visible-buffer-string' functionDmitry Kurochkin
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-01-28Clarify usage of `additional_headers' in test/test-lib.sh:generate_message.Thomas Schwinge
Signed-off-by: Thomas Schwinge <thomas@schwinge.name>
2011-01-15Fix misspelling in a comment.Carl Worth
Just a simple change I noticed in passing.