#!/bin/sh
######################################################
#
# Test that the manpages don't have any syntax errors
# as detected by groff.
#
######################################################

if test -z "${MH_OBJ_DIR}"; then
    srcdir=`dirname "$0"`/../..
    MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
fi

. "$MH_OBJ_DIR/test/common.sh"

setup_test

require_prog groff

cd ${MH_INST_DIR}${mandir} || exit 1

# groff will still exit with status zero even if warnings
# were emitted, so we have to jump through hoops to
# find out if any were emitted.

expected=$MH_TEST_DIR/$$.expected
actual=$MH_TEST_DIR/$$.actual

# There aren't any expected warnings at the moment but
# this mechanism does let us add them if necessary later.
rm -f "$expected" "$actual"
touch "$expected" "$actual"

for manpage in man?/*.?; do
  groff -Tutf8 -mandoc -ww "$manpage" > /dev/null 2>>"$actual"
done

check "$expected" "$actual"

exit $failed
