chiark / gitweb /
test suite: manpages-format: Provision for always-expected msgs
[dgit.git] / tests / tests / manpages-format
1 #!/bin/bash
2 set -e
3 autoimport=
4 . tests/lib
5
6 t-dependencies man-db make groff git-debrebase git-debpush
7
8 cd $root
9
10 printenv |grep MAKE ||: |t-sort
11 manpages=$(MAKEFLAGS= MAKELEVEL= make list-manpages)
12
13 export MANWIDTH=80
14
15 run_man () {
16         if [ "x${DGIT_MANPAGES_SOURCE_DIR}" = x ]; then
17                 cmd='man --warnings "$@" $section $page'
18         else
19                 make $roff >&2
20                 cmd='man --warnings "$@" -l $roff'
21         fi
22         eval "$cmd 2>&1 >/dev/null |tee $errs"
23 }
24
25 cat >$tmp/always-expected <<'END'
26 END
27
28 for roff in $manpages; do
29         for fmt in txt ps; do
30                 cat $tmp/always-expected >$tmp/$roff.$fmt-expected
31         done
32 done
33
34 expected () {
35         cat >>$tmp/$2.$1-expected
36 }
37
38 not_egrep_vxPf () {
39         # egrep -vxPf does not work, so we reimplement it
40         perl -ne '
41                 BEGIN () {
42                         open PATS, shift @ARGV or die $!;
43                         $re = join "|", map { chomp; qr{^(?:$_)$} }
44                                 qr{^(?=a)b}, <PATS>;
45                         print STDERR "RE $re\n";
46                 }
47                 next if m{$re};
48                 print STDERR "unexpected: $_";
49                 $bad = 1;
50                 END { die "unexpected errors\n" if $bad; }
51         ' "$@"
52 }
53
54 expected txt dgit.1 <<'END'
55 .* # table wider than line width
56 END
57
58 prep () {
59         fmt=$1
60         errs=$tmp/$roff.$fmt-errs
61 }
62
63 check () {
64         perl -0777 -i~ -pe 's/\n[ \t]+/ # /' $errs
65         not_egrep_vxPf $tmp/$roff.$fmt-expected $errs
66 }
67
68 for roff in $manpages; do
69         section=${roff##*.}
70         page=${roff%.*}
71
72         prep txt
73         run_man
74         check
75
76         prep ps
77         run_man -Tps
78         check
79 done
80
81 t-ok