From 1066c6442bc1471d440ac86711250d825b5ddc2c Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 28 Jun 2018 15:31:56 +0100 Subject: test suite: manpages-format: New test Test that manpages format with only expected roff warnings. Signed-off-by: Ian Jackson --- Makefile | 3 +++ debian/changelog | 2 ++ debian/tests/control | 4 +++ tests/lib-core | 2 ++ tests/tests/manpages-format | 61 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+) create mode 100755 tests/tests/manpages-format diff --git a/Makefile b/Makefile index de28f4d..605b580 100644 --- 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: diff --git a/debian/changelog b/debian/changelog index 9228720..96a9e62 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 diff --git a/debian/tests/control b/debian/tests/control index 48ed93f..7f5964b 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -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 diff --git a/tests/lib-core b/tests/lib-core index c3a04cb..e2b6c06 100644 --- a/tests/lib-core +++ b/tests/lib-core @@ -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 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{^(?:$_)$} } ; + } + 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 -- cgit v1.2.3