aboutsummaryrefslogtreecommitdiff
path: root/test/test-lib.sh
AgeCommit message (Collapse)Author
2025-06-22test: do not add legacy bindings to PYTHONPATHMichael J Gruber
d526797a ("python: move legacy python bindings to contrib.", 2025-02-15) moved the legacy python bindings away from the location in `bindingss/`. Do not add that location to the PYTHONPATH since it is obsolete.
2023-07-21test: support testing notmuch as installedDavid Bremner
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-21test: check for empty/missing files in test_expect_equal_message_bodyDavid Bremner
Messages can have empty bodies, but empty files are not messages.
2023-01-05test: mark some tests as broken when run as root.David Bremner
File permission errors e.g., are hard to trigger as root.
2022-09-23test: replace aging OpenPGP key used in the test suiteJustus Winter
This replaces the old OpenPGPv4 key that is used in the test suite with a more modern OpenPGPv4 key. All cryptographic artifacts in the test suite are updated accordingly. Having old cryptographic artifacts in the test suite presents a problem once the old algorithms are rejected by contemporary implementations. For reference, this is the old key. sec rsa1024 2011-02-05 [SC] 5AEAB11F5E33DCE875DDB75B6D92612D94E46381 uid [ unknown] Notmuch Test Suite <test_suite@notmuchmail.org> (INSECURE!) ssb rsa1024 2011-02-05 [E] And this is the new key. Note that is has the same shape, but uses Ed25519 and Cv25519 instead of 1024-bit RSA. sec ed25519 2022-09-07 [SC] 9A3AFE6C60065A148FD4B58A7E6ABE924645CC60 uid [ultimate] Notmuch Test Suite (INSECURE!) <test_suite@notmuchmail.org> ssb cv25519 2022-09-07 [E]
2022-07-30CLI/show: support --duplicate for structured outputDavid Bremner
This introduces a new mandatory key for message structures, namely "duplicate". Per convention in devel/schemata this does _not_ increase the format version. This means that clients are responsible for checking that it exists, and not crashing if it does not. The main functional change is teaching mime_node_open to understand a 'duplicate' argument. Support for --duplicate in notmuch-reply would make sense, but we defer it to a later commit.
2022-07-07CL/git: add format version 1David Bremner
The original nmbug format (now called version 0) creates 1 subdirectory of 'tags/' per message. This causes problems for more than (roughly) 100k messages. Version 1 introduces 2 layers of hashed directories. This scheme was chose to balance the number of subdirectories with the number of extra directories (and git objects) created via hashing. This should be upward compatible in the sense that old repositories will continue to work with the updated notmuch-git.
2022-07-05test: define and use notmuch_sexp_*_sanitize functionsDavid Bremner
These are based on the equivalent functions for json. Like those, these are pretty simple-minded, and don't really understand the syntax.
2022-06-25test: define test_private_CDavid Bremner
When testing error handling, it is sometimes difficult to cover a particular error path deterministically. Introduce a test function to allow calling lower level functions directly.
2022-02-25perf-test: allow running test_emacs from performance test suite.David Bremner
test_require_external prereq has to move to test-lib-common.sh, and the new shell functions print_emacs_header and time_emacs are provided. The somewhat indirect way of printing the output is to avoid the extra "" present on string values from emacsclient.
2022-02-25test: split variable settings to their own fileDavid Bremner
This allows sharing more variable settings between the (correctness) tests and the performance-tests. Unfortunately it seems a bit tricky to move settings to test-lib-common.sh, as that is sourced late in test-lib.sh, and moving it earlier breaks things.
2022-01-27test: sanitize generated message files namesDavid Bremner
It is fragile to encode the generated names into tests, as it makes tests break when e.g. new tests are added. There is a possibility that this will hide certain failures; in that case meaningful filenames should be chosen for the generated messages.
2022-01-26test: define test_expect_equal_message_bodyDavid Bremner
This is a relatively simple sed invocation, but rather than write a comment everywhere, give it a descriptive name.
2022-01-12Merge remote-tracking branch 'origin/release'David Bremner
2022-01-12test/gpgsm: use --with-colons when calculating fingerprint.David Bremner
As stressed by the gpg documentation, the non-'with-colons' output format is subject to change, and indeed it did in 2.3.x (x<=3). This should make the the test suite more robust against such changes.
2021-12-23test: remove directory names from paths in exceptionsDavid Bremner
These cause failures when building out of tree.
2021-12-04test: add python-cffi bindings to path for test_pythonDavid Bremner
This will allow testing the new python bindings using test_python, in addition to the current invocation of pytest.
2021-09-29test/T355-smime: Use key as exported by gpgsmDavid Bremner
As reported in id:87h7pxiek3.fsf@tethera.net, the previous version of the test is flaky. There is some so-far undebugged interaction between openssl and gpgsm that causes the keys to fail to import. As a potential workaround, use the key as exported by gpgsm, and eliminate openssl from this particular pipeline.
2021-08-21test: add test_expect_equal_file_nonemptyDavid Bremner
A common bug in tests is that the code used to generate the EXPECTED file fails, generating no output. When the code generating the OUTPUT file fails in the same way, the test passes, even though there is a failure being hidden. Add a new test function that guards against this.
2021-08-21test: factor out test_diff_file_David Bremner
A following commit will use this new function in a public test function.
2021-08-21test/expect_equal_file: whitespace cleanupDavid Bremner
No functional change, just reindent to Emacs defaults.
2021-08-03test: revert to mkdir -p to make results directory.David Bremner
As suggested by id:m21r7al3mt.fsf@guru.guru-group.fi
2021-06-26cli/show: produce "email" element in sigstatusDaniel Kahn Gillmor
When the certificate that signs a message is known to be valid, GMime is capable of reporting on the e-mail address embedded in the certificate. We pass this information along to the caller of "notmuch show", as often only the e-mail address of the certificate has actually been checked/verified. Furthermore, signature verification should probably at some point compare the e-mail address of the caller against the sender address of the message itself. Having to parse what gmime thinks is a "userid" to extract an e-mail address seems clunky and unnecessary if gmime already thinks it knows what the e-mail address is. See id:878s41ax6t.fsf@fifthhorseman.net for more motivation and discussion. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2021-06-20Merge branch 'release'David Bremner
2021-06-08test: check openssl prequisite for add_gpgsm_homeDavid Bremner
This is a fix for the test failures reported by Dan Čermák [1]. It is more robust to check for the prerequisite inside the function that uses it, rather than in every test file that calls the function. [1]: id:87k0n4fqgm.fsf@tethera.net
2021-06-07test: aggregate-results updatesTomi Ollila
notmuch-test will now call aggregate-results.sh with file list that it compiles based on the test ran, and aggregate-results will report failure is any of the test files are missing. With this notmuch-test no longer has to exit in non-parallel run if some test fail to write its report file -- so it works as parallel tests in this sense. Changed test_done() in test-lib.sh write report file in one write(2), so there is (even) less chance it being partially written. Also, now it writes 'total' last and aggregate-results.sh expects this line to exist in all report files for reporting to be successful. Added 'set -eu' to notmuch-test and modified code to work with these settings. That makes it harder to get mistakes slipped into committed code.
2021-05-23test: say_color() in one write(2)Tomi Ollila
say_color() used to call (builtin) printf (and tput(1) to stdout) several times, which caused attempts to write messages with color to have partial content (e.g. escape sequences) often intermixed with other tests when parallel tests were run. Now, with all output collected, then written out using one printf, all strings with color print out correctly ((at least short) write(2)'s appear to write out "atomically"). While at it, used only one tput(1) execution to determine whether color output works, and made bold/colors/sgr0 to tput(1) their values once per test.
2021-05-23test: ignore debugging messagesDavid Bremner
Previously building with "-DDEBUG" broke the test suite in several places.
2021-05-22test: replace notmuch_passwd_sanitize() with _libconfig_sanitize()Tomi Ollila
notmuch_passwd_sanitize() in test-lib.sh is too generic, it cannot work in many cases... The more specific version _libconfig_sanitize() replaces it in T590-libconfig.sh and the code that uses it is modified to output the keys (ascending numbers printed in hex) so the sanitizer knows what to sanitize in which lines... "@" + fqdn -> "@FQDN" replacement is used as fqdn could -- in theory -- be substring of 'USERNAME'. 'user -> 'USER_FULL_NAME replacement to work in cases where user is empty -- as only first ' is replaced that works as expected. In addition to ".(none)" now also ".localdomain" is filtered from USERNAME@FQDN. /dev/fd/{n} is not defined in posix, but it is portable enough (if it weren't it is easy to fix -- now code looks clearer).
2021-05-17test: split emacs functionality to its own fileFelipe Contreras
This way it's easier to identify the tests that do require emacs stuff. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-17test: emacs: fix a couple of shellcheck complaintsFelipe Contreras
In test-lib-emacs.sh line 20: test_require_external_prereq ${TEST_EMACS} || ret=1 ^-----------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: test_require_external_prereq "${TEST_EMACS}" || ret=1 In test-lib-emacs.sh line 21: test_require_external_prereq ${TEST_EMACSCLIENT} || ret=1 ^-----------------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: test_require_external_prereq "${TEST_EMACSCLIENT}" || ret=1 Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-17test: emacs: check for configured emacsFelipe Contreras
Commit d59d9c81 (test: Make the emacsclient binary user-configurable, 2012-11-27) modified the prereq check for the configured emacsclient, but we probably want to do the same for emacs itself. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-17test: emacs: simplify missing dependencies checkFelipe Contreras
No functional changes. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-17test: more style fixesFelipe Contreras
In order to fit the git coding style. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-17test: trivial style cleanupsFelipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-02test: move test_ruby() inside the only clientFelipe Contreras
Not much point in polluting the main library, and also will be useful to modify it in tandem with the tests. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-01test: add external prereqs to many emacs testsFelipe Contreras
The tests fail otherwise. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-01test: add prereqs check in test_emacs_expect_tFelipe Contreras
test_emacs may update the external prereqs, in which case we want to skip the test rather than fail. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-01test: fix wrong SKIP messagesFelipe Contreras
When the external prereqs are updated inside the body of the command (e.g. test_emacs) the message in test_report_skip_ is wrong: it outputs the body of the command instead of the subtest name. We need to pass the same argument we pass to test_skip. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-01test: use correct fqdn in passwd_sanitize()Felipe Contreras
My fqdn is 'natae.localdomain', however, socket.getfqdn() returns 'localhost'. To fetch the true fqdn we need socket.getaddrinfo(). For more information see: https://stackoverflow.com/a/11580042/10474 Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-01test: unset NAME environment variableFelipe Contreras
Otherwise the output from the tests would be different. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-01test: fix passwd_sanitize()Felipe Contreras
If any of the variables is empty the output is completely messed up, because replace("", "FOO") puts "FOO" before every single character. I don't have my full name configured, and this is what I get: USER_FULL_NAME=USER_FULL_NAME=USER_FULL_NAME USER_FULL_NAMEsUSER_FULL_NAMEtUSER_FULL_NAMEdUSER_FULL_NAMEoUSER_FULL_NAMEuUSER_FULL_NAMEtUSER_FULL_NAME USER_FULL_NAME=USER_FULL_NAME=USER_FULL_NAME Let's check for empty strings before doing any replace. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-04-24test: replace notmuch_passwd_sanitize with python versionDavid Bremner
Apparently the -f option to hostname is not portable, and in fact it does not seem to always behave reasonably in e.g. a chroot. Python code originally due to Tomi [1], modified by yours truly. [1]: id:m2lf9fbkug.fsf@guru.guru-group.fi
2021-04-18test-lib: unset XDG_CONFIG_HOMEĐoàn Trần Công Danh
lib/open.cc:_load_key_file will only open xdg-config files in $XDG_CONFIG_HOME if it's defined, $HOME/.config will be considered if and only if XDG_CONFIG_HOME not defined. Let's unset said variable before running the test.
2021-04-16test: put shim at end of LD_PRELOAD pathDavid Bremner
Certain tools like the address-sanitizer fail if they are not the first LD_PRELOADed library. It does not seem to matter for our shims, as long as they are loaded before libnotmuch.
2021-03-27lib/config: set default for primary user emailDavid Bremner
This is mainly copying code from the CLI into the lib. The CLI copy will be deleted in a later commit.
2021-03-27lib/config: set defaults for user full nameDavid Bremner
This just copies code from from the CLI into the library. New test infrastructure is needed because apparently we have never tested this code path.
2021-03-18test: Add tests for write access to database from hooks.David Bremner
Recent changes to configuration handling meant the pre-new hook was run while the database was open read only, limiting what could be done in the hook. Add some known broken tests for this problem, as well as a regression test for write access from the post-new hook.
2021-01-17test: add (back) upgrade testsDavid Bremner
In ee897cab8b721 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.
2020-08-09test: Fix indentationJonas Bernoulli
Fix it to consistently match the style we have configured in ".dir-locals.el".