summaryrefslogtreecommitdiff
path: root/tests/tests/manpages-format
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tests/manpages-format')
-rwxr-xr-xtests/tests/manpages-format61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/tests/manpages-format b/tests/tests/manpages-format
new file mode 100755
index 0000000..4b9585f
--- /dev/null
+++ b/tests/tests/manpages-format
@@ -0,0 +1,61 @@
+#!/bin/bash
+set -e
+autoimport=
+. tests/lib
+
+t-dependencies man-db make groff git-debrebase
+
+cd $root
+
+printenv |grep MAKE ||: |sort
+manpages=$(MAKEFLAGS= MAKELEVEL= make list-manpages)
+
+export MANWIDTH=80
+
+run_man () {
+ if [ "x${DGIT_MANPAGES_SOURCE_DIR}" = x ]; then
+ cmd='man "$@" $section $page'
+ else
+ make $roff >&2
+ cmd='man "$@" -l $roff'
+ fi
+ eval "$cmd 2>&1 >/dev/null |tee $errs >&2"
+}
+
+for roff in $manpages; do
+ >$tmp/$roff.expected
+done
+
+expected () {
+ cat >$tmp/$1.expected
+}
+
+not_egrep_vxPf () {
+ # egrep -vxPf does not work, so we reimplement it
+ perl -ne '
+ BEGIN () {
+ open PATS, shift @ARGV or die $!;
+ $re = join "|", map { chomp; qr{^(?:$_)$} } <PATS>;
+ }
+ next if m{$re};
+ print STDERR "unexpected: $_";
+ $bad = 1;
+ END { die "unexpected, re= $re\n" if $bad; }
+ ' "$@"
+}
+
+expected dgit.1 <<'END'
+.* # table wider than line width
+END
+
+for roff in $manpages; do
+ section=${roff##*.}
+ page=${roff%.*}
+
+ errs=$tmp/$roff.errs
+ run_man >/dev/null
+ perl -0777 -i~ -pe 's/\n[ \t]+/ # /' $errs
+ not_egrep_vxPf $tmp/$roff.expected $errs
+done
+
+t-ok