summaryrefslogtreecommitdiff
path: root/t/README
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2012-06-14 13:13:58 +0200
committerStefano Lattarini <stefano.lattarini@gmail.com>2012-06-22 14:24:38 +0200
commit6e713425a0dcede167924e7691e95ab5e54e399c (patch)
tree4ce8cbe368733dc0049b5b690b13e0e3123d7a3a /t/README
parentd0dc448517d3a61ba55e62dd76b9a42b68bef8f8 (diff)
downloadautomake-6e713425a0dcede167924e7691e95ab5e54e399c.tar.gz
tests: use more POSIX shell features our test scripts
Since commit 'v1.12-36-g2d68fd9' of 2012-05-07, "configure: search a sturdy POSIX shell to be used in the testsuite", the shell running our test script is assured to be a POSIX-conforming shell, so we can use the more modern and flexible idioms and features that we couldn't use when we also aimed at compatibility with non-POSIX Bourne shells, like Solaris /bin/sh. * t/README: Suggest to use POSIX shell features liberally in test cases, with possible exception of Makefile recipes and configure shell code. * Several tests: Adjust to use more POSIX shell features; e.g., $(...) rather than `...`, $((...)) rather than `expr ...`, "if ! CMD; then ..." instead of "if CMD; then :; else ...", and so on. In several places, when using the 'test' built-in, prefer '-eq' over '=' for numeric comparisons, and prefer "grep -c PATTERN FILE" over "grep PATTERN FILE | wc -l". Throw in other low-hanging easy improvements and fixlets while we are at it. * t/ax/depcomp.sh, t/ax/tap-summary-aux.sh, t/ax/tap-functions.sh, defs, defs-static.in: Likewise. Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Diffstat (limited to 't/README')
-rw-r--r--t/README16
1 files changed, 16 insertions, 0 deletions
diff --git a/t/README b/t/README
index 5f967d271..57cab89d4 100644
--- a/t/README
+++ b/t/README
@@ -278,6 +278,22 @@ Do
Do not
------
+ In test scripts, prefer using POSIX constructs over their old
+ Bourne-only equivalents:
+
+ - use $(...), not `...`, for command substitution;
+ - use $((...), not `expr ...`, for arithmetic processing;
+ - liberally use '!' to invert the exit status of a command, e.g.,
+ in idioms like "if ! CMD; then ...", instead of relying on clumsy
+ paraphrases like "if CMD; then :; else ...".
+ - prefer use of ${param%pattern} and ${param#pattern} parameter
+ expansions over processing by 'sed' or 'expr'.
+
+ Note however that, when writing Makefile recipes or shell code in a
+ configure.ac, you should still use `...` instead, because the Autoconf
+ generated configure scripts do not ensure they will find a truly POSIX
+ shell (even though they will prefer and use it *if* it's found).
+
Do not test an Automake error with "$AUTOMAKE && Exit 1", or in three
years we'll discover that this test failed for some other bogus reason.
This happened many times. Better use something like