chiark / gitweb /
changelog: start 9.14
[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 ERROR.*
27 END
28
29 for roff in $manpages; do
30         for fmt in txt ps; do
31                 cat $tmp/always-expected >$tmp/$roff.$fmt-expected
32         done
33 done
34
35 expected () {
36         cat >>$tmp/$2.$1-expected
37 }
38
39 not_egrep_vxPf () {
40         # egrep -vxPf does not work, so we reimplement it
41         perl -ne '
42                 BEGIN () {
43                         open PATS, shift @ARGV or die $!;
44                         $re = join "|", map { chomp; qr{^(?:$_)$} }
45                                 qr{^(?=a)b}, <PATS>;
46                         print STDERR "RE $re\n";
47                 }
48                 next if m{$re};
49                 print STDERR "unexpected: $_";
50                 $bad = 1;
51                 END { die "unexpected errors\n" if $bad; }
52         ' "$@"
53 }
54
55 expected txt dgit.1 <<'END'
56 .* # table wider than line width
57 END
58
59 prep () {
60         fmt=$1
61         errs=$tmp/$roff.$fmt-errs
62 }
63
64 check () {
65         perl -0777 -i~ -pe 's/\n[ \t]+/ # /' $errs
66         not_egrep_vxPf $tmp/$roff.$fmt-expected $errs
67 }
68
69 for roff in $manpages; do
70         section=${roff##*.}
71         page=${roff%.*}
72
73         prep txt
74         run_man
75         check
76
77         prep ps
78         run_man -Tps
79         check
80 done
81
82 t-ok