ab06831c1df1405c8a771c602bf86f6775dc7ac6
[mmh] / test / tests / manpages / test-manpages
1 #!/bin/sh
2 ######################################################
3 #
4 # Test that the manpages don't have any syntax errors
5 # as detected by groff.
6 #
7 ######################################################
8
9 # First find out whether we have a groff on the path:
10
11 # portable implementation of 'which' utility
12 findprog()
13 {
14   FOUND=
15   PROG="$1"
16   IFS_SAVE="$IFS"
17   IFS=:
18   for D in $PATH; do
19     if [ -z "$D" ]; then
20       D=.
21     fi
22     if [ -f "$D/$PROG" ] && [ -x "$D/$PROG" ]; then
23       printf '%s\n' "$D/$PROG"
24       break
25     fi
26   done
27   IFS="$IFS_SAVE"
28 }
29
30 if [ -z "$(findprog groff)" ]; then
31   echo "Test $0 SKIP (missing groff)"
32   exit 120
33 fi
34
35 cd $MH_TEST_DIR/share/man
36
37 # groff will still exit with status zero even if warnings
38 # were emitted, so we have to jump through hoops to
39 # find out if any were emitted.
40
41 expected=$MH_TEST_DIR/$$.expected
42 actual=$MH_TEST_DIR/$$.actual
43
44 # There aren't any expected warnings at the moment but
45 # this mechanism does let us add them if necessary later.
46 rm -f "$expected" "$actual"
47 touch "$expected" "$actual"
48
49 for manpage in man?/*.?; do
50   groff -Tutf8 -mandoc -wmac "$manpage" > /dev/null 2>>"$actual"
51 done
52
53 diff -u "$expected" "$actual"