chiark / gitweb /
test suite: manpages-format: New test
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 28 Jun 2018 14:31:56 +0000 (15:31 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 30 Jun 2018 22:25:45 +0000 (23:25 +0100)
Test that manpages format with only expected roff warnings.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Makefile
debian/changelog
debian/tests/control
tests/lib-core
tests/tests/manpages-format [new file with mode: 0755]

index de28f4d690c967f43d2cd2e913d5cd189fcb532d..605b58020fc45248faa87709a5dec007ff912f62 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -119,6 +119,9 @@ installdirs-infra:
        $(INSTALL_DIR) $(DESTDIR)$(bindir) $(DESTDIR)$(infraexamplesdir) \
                $(addprefix $(DESTDIR)$(perldir)/, $(dir $(INFRA_PERLMODULES)))
 
+list-manpages:
+       @echo $(MANPAGES)
+
 check installcheck:
 
 clean distclean mostlyclean maintainer-clean:
index 92287200fbecc0bef681851a68e4c541ce5ae5c1..96a9e6252980ffb8ecbab67624bba4c0c8c8220e 100644 (file)
@@ -3,6 +3,8 @@ dgit (5.6~) unstable; urgency=medium
   * Merge the experimental branch containing the fianl
     version of the test suite gnupg workarounds.
 
+  * test suite: Test that manpages format with only expected warnings.
+
  --
 
 dgit (5.5+exp9) experimental; urgency=medium
index 48ed93fb3bbb6241a8702bb759d569708df635a3..7f5964bacffcb60d5b67d17a947280f65e632ca4 100644 (file)
@@ -33,6 +33,10 @@ Tests-Directory: tests/tests
 Depends: gnupg, patch, diffutils
 Restrictions: hint-testsuite-triggers
 
+Tests: manpages-format
+Tests-Directory: tests/tests
+Depends: dgit, dgit-infrastructure, devscripts, debhelper (>=8), fakeroot, build-essential, chiark-utils-bin, bc, man-db, make, groff, git-debrebase
+
 Tests: defdistro-mirror mirror mirror-debnewgit mirror-private
 Tests-Directory: tests/tests
 Depends: dgit, dgit-infrastructure, devscripts, debhelper (>=8), fakeroot, build-essential, chiark-utils-bin, bc, rsync
index c3a04cbaed1b215cfd62c33b7455976f7a2c4a73..e2b6c0623d6b423301ed7eee59f57ac80bb00d9b 100644 (file)
@@ -13,8 +13,10 @@ t-set-intree () {
        : ${DGIT_SSH_DISPATCH_TEST:=$DGIT_TEST_INTREE/infra/dgit-ssh-dispatch}
        : ${DGIT_INFRA_PFX:=$DGIT_TEST_INTREE${DGIT_TEST_INTREE:+/infra/}}
        : ${DGIT_GITDEBREBASE_TEST:=$DGIT_TEST_INTREE/git-debrebase}
+       : ${DGIT_MANPAGES_SOURCE_DIR:=$DGIT_TEST_INTREE}
        export DGIT_TEST DGIT_BADCOMMIT_FIXUP
        export DGIT_REPOS_SERVER_TEST DGIT_SSH_DISPATCH_TEST
+       export DGIT_MANPAGES_SOURCE_DIR
        export PERLLIB="$DGIT_TEST_INTREE${PERLLIB:+:}${PERLLIB}"
 }
 
diff --git a/tests/tests/manpages-format b/tests/tests/manpages-format
new file mode 100755 (executable)
index 0000000..4b9585f
--- /dev/null
@@ -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