summaryrefslogtreecommitdiff
path: root/tests/tests/manpages-format
blob: 4b9585f2618990edb4a0596da65af1a3f5224ef4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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