Removed double quotes around case arguments in test scripts.
[mmh] / test / README
1 nmh unit test suite.
2
3 The purpose of these tests is to verify the functionality of the nmh
4 commands.  The goal of the suite is to create an environment where testing
5 nmh commands is easy and useful.  Each test is a shell script, and is
6 launched via the 'sh' command. The script should run the test and report
7 the result by one of:
8
9   * for a test pass: exit with status 0
10   * where a test has been skipped (perhaps because it depends on an
11     external program which can't be found): print "Test $0 SKIP (reason)"
12     and exit with status 77
13   * for a test fail: exit with some status other than 0 or 120
14
15 The Suite is a re-worked version of the original test suite; it now is
16 designed to work with Automake.  To run these tests you can do "make check"
17 via the top-level Makefile.  This is also done automatically via
18 "make distcheck".
19
20 WARNING:  The test suite installs nmh and runs the tests on that test
21 installation.  If you run tests individually, they will not remove
22 that test installation or check to see if it remains up to date with
23 your nmh workspace.  You can run test/clean after a test to remove the
24 test installation.  "make check" will do that, so it is best to use
25 it.
26
27 If you wish to write a new test script, here are the steps:
28
29 - Make sure your test script sources $MH_OBJ_DIR/test/common.sh and
30   calls the setup_test shell function (the other scripts have examples
31   of this).
32
33 - Your path will be set up to find the locations of the test nmh binaries.
34
35 - Add your script to the TESTS variable in the toplevel Makefile.am.
36   By convention, test script names start with "test-", though that
37   is not a requirement.
38
39 - If you need additional files for your tests, be sure to add them to
40   the EXTRA_DIST variable in Makefile.am.  Note that you should insure
41   that you access these files relative to the $srcdir environment variable.
42
43 - Verify that the test works with both "make check" and "make distcheck".
44
45 Please use only Bourne shell and bare-bones POSIX program constructs
46 in the test scripts.  In particular:
47
48 - Use `` instead of $().
49
50 - Wrap shell variables with "" if they could possibly contain
51   whitespace or special characters that would affect syntax.
52
53 - Use the arith_eval() function in common.sh instead of $(()) or expr.
54   It detects at run time if $(()) is available.
55
56 - Use grep >/dev/null instead of grep -q.
57
58 - Don't use egrep, grep -E, fgrep, grep -F, or other non-portable grep
59   functionality.  The built-in case statement supports alternation (|).
60
61 - Don't use ! to negate conditions.  Instead, use something like:
62     <condition> || <statement>
63   or
64     if <condition>; then :; else <statements> fi
65
66 - Separate variable assignment from export (don't assign in export
67   statements).
68
69 - Use sed >tmpfile and mv instead of sed -i.
70
71 - Avoid depending on the exact format of output from system (non-nmh)
72   programs.
73
74 The Heirloom Bourne Shell, http://heirloom.sourceforge.net/sh.html,
75 catches many non-portable shell constructs, such as $(), $(()), !, and
76 assignment in export statements.
77
78 checkbashisms, available at http://sourceforge.net/projects/checkbaskisms/,
79 might help some catch problems.  Though it misses all of the troublesome
80 constructs, except for assignment in an export statement, listed above.
81
82 The "Portable Shell" section of the Autoconf info manual has a wealth
83 of tips for avoiding portability problems in shell scripts.  It might
84 be available by entering:  info autoconf portable.