Moved findprog out of manpage test script into this new file.
-2008-08-03 Peter Maydell <pmaydell@chiark.greenend.org.uk>
+2008-12-26 Peter Maydell <pmaydell@chiark.greenend.org.uk>
+
+ * test/common.sh: new file for common utility functions for the
+ test scripts. Moved findprog out of manpage test script into this
+ new file.
+
+2008-12-25 Peter Maydell <pmaydell@chiark.greenend.org.uk>
* test/runtest: automatically run setup-test if it hasn't already
been done. Improve error handling in test script with 'set -e'.
--- /dev/null
+# Common helper routines for test shell scripts -- intended to be sourced by them
+test_skip ()
+{
+ WHY="$1"
+ echo "$Test $0 SKIP ($WHY)"
+ exit 120
+}
+
+# portable implementation of 'which' utility
+findprog()
+{
+ FOUND=
+ PROG="$1"
+ IFS_SAVE="$IFS"
+ IFS=:
+ for D in $PATH; do
+ if [ -z "$D" ]; then
+ D=.
+ fi
+ if [ -f "$D/$PROG" ] && [ -x "$D/$PROG" ]; then
+ printf '%s\n' "$D/$PROG"
+ break
+ fi
+ done
+ IFS="$IFS_SAVE"
+}
+
+require_prog ()
+{
+ if [ -z "$(findprog $1)" ]; then
+ test_skip "missing $1"
+ fi
+}
#
######################################################
-# First find out whether we have a groff on the path:
-
-# portable implementation of 'which' utility
-findprog()
-{
- FOUND=
- PROG="$1"
- IFS_SAVE="$IFS"
- IFS=:
- for D in $PATH; do
- if [ -z "$D" ]; then
- D=.
- fi
- if [ -f "$D/$PROG" ] && [ -x "$D/$PROG" ]; then
- printf '%s\n' "$D/$PROG"
- break
- fi
- done
- IFS="$IFS_SAVE"
-}
-
-if [ -z "$(findprog groff)" ]; then
- echo "Test $0 SKIP (missing groff)"
- exit 120
-fi
+. common.sh
+
+require_prog groff
cd $MH_TEST_DIR/share/man