#!/bin/sh # manpage tests using man/roff # # Contact: grubert@users.sourceforge.net # Revision: $Revision: 9897 $ # Date: $Date: 2024-08-14 11:18:20 +0200 (Mi, 14. Aug 2024) $ # Copyright: This script has been placed in the public domain. IN_DIR=input OUT_DIR=output EXP_DIR=expected if [ -z "`man -?|grep -- '^ *-T'`" ] ; then echo 'WARNING: your man does not support "-T Format" to specify encoding' echo 'SKIPPING encoding tests' ENCS="" GROFF="ps" else ENCS="latin1 utf8 ascii ps" GROFF="" fi if [ -z "$1" ] ; then FILES=*.txt else FILES=$1 fi ERROR_CNT=0 inc_ERROR_CNT () { ERROR_CNT=$(( ERROR_CNT + 1 )) } report_ERROR_CNT () { echo "$ERROR_CNT errors" } CMD="python3 ../../docutils/tools/rst2man.py --traceback" for IN_F in $IN_DIR/$FILES ; do BASE=`basename $IN_F` F_BASE=${BASE%.txt} if echo $F_BASE | grep -q -- '-de\.' ; then OPT="-l de" else OPT="" fi $CMD $OPT $IN_F $OUT_DIR/$F_BASE.man if [ $? -eq 0 ] ; then diff -s -u $EXP_DIR/$F_BASE.man $OUT_DIR/$F_BASE.man if [ $? -ne 0 ] ; then inc_ERROR_CNT fi for ENC in $ENCS ; do if [ -e $EXP_DIR/$F_BASE.$ENC ] ; then man -T$ENC $OUT_DIR/$F_BASE.man > $OUT_DIR/$F_BASE.$ENC diff -s -u $EXP_DIR/$F_BASE.$ENC $OUT_DIR/$F_BASE.$ENC if [ $? -ne 0 ] ; then inc_ERROR_CNT fi fi done for ENC in $GROFF ; do if [ -e $EXP_DIR/$F_BASE.groff.$ENC ] ; then # macosx -t means troff means gross -Tps man -t $OUT_DIR/$F_BASE.man > $OUT_DIR/$F_BASE.groff.$ENC diff -s -u $EXP_DIR/$F_BASE.groff.$ENC $OUT_DIR/$F_BASE.groff.$ENC if [ $? -ne 0 ] ; then inc_ERROR_CNT fi fi done fi done if [ -n "$1" ] ; then report_ERROR_CNT exit fi # language test for L in "en" "de" ; do for IN_F in $IN_DIR/docinfo-*.txt ; do BASE=`basename $IN_F` F_BASE=${BASE%.txt} OPT="-l $L" EXT="-l_$L" $CMD $OPT $IN_F $OUT_DIR/$F_BASE$EXT.man if [ $? -eq 0 ] ; then diff -s -u $EXP_DIR/$F_BASE$EXT.man $OUT_DIR/$F_BASE$EXT.man if [ $? -ne 0 ] ; then inc_ERROR_CNT fi fi done done # reference macros EXT=-urue.man for EXP_F in $EXP_DIR/*$EXT ; do BASE=`basename $EXP_F` F_BASE=${BASE%$EXT} OPT="--macro-references" $CMD $OPT $IN_DIR/$F_BASE.txt $OUT_DIR/$BASE if [ $? -eq 0 ] ; then diff -s -u $EXP_DIR/$BASE $OUT_DIR/$BASE if [ $? -ne 0 ] ; then inc_ERROR_CNT fi fi done report_ERROR_CNT