blob: 877fc28fb95d6b918ab63d39c4d941e39582bd21 (
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#!/bin/sh
#
# Copyright (C) 2020, 2022 Free Software Foundation, Inc.
#
# This file is part of groff.
#
# groff is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# groff is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
groff="${abs_top_builddir:-.}/test-groff"
# Keep this list of programs in sync with GROFF_CHECK_GROHTML_PROGRAMS
# in m4/groff.m4.
for cmd in pnmcrop pnmcut pnmtopng pnmtops psselect
do
if ! command -v $cmd >/dev/null
then
echo "cannot locate '$cmd' command; skipping test" >&2
exit 77 # skip
fi
done
fail=
wail () {
echo ...FAILED >&2
fail=yes
}
cleanup () {
rm -f grohtml-[0-9]*-[12].png
trap - HUP INT QUIT TERM
}
trap 'trap "" HUP INT QUIT TERM; cleanup; kill -s INT $$' \
HUP INT QUIT TERM
input='.TS
L.
foobar
.TE'
# Inline images are named grohtml-$$-<image sequence number>.png.
echo "checking production of inline image for tbl(1) table" >&2
output=$(echo "$input" | "$groff" -t -Thtml)
echo "$output" | grep -q '<img src="grohtml-[0-9]\+-1.png"' || wail
input='.EQ
x sup 2 + y sup 2 = z sup 2
.EN'
echo "checking production of inline image for eqn(1) equation" >&2
output=$(echo "$input" | "$groff" -e -Thtml)
echo "$output" | grep -q '<img src="grohtml-[0-9]\+-2.png"' || wail
cleanup
# We can't run remaining tests if the environment doesn't support UTF-8.
test "$(locale charmap)" = UTF-8 || exit 77 # skip
# Check two forms of character transformation.
#
# dash's built-in printf doesn't support \x or \u escapes, so likely
# other shells don't either, and expecting one that does to be in the
# $PATH seems optimistic. So use UTF-8 octal bytes directly.
echo "checking -k -Thtml" >&2
printf '\303\241' | "$groff" -k -Thtml | grep -qx '<p>á</p>' \
|| wail
# We test compatibility-mode HTML output somewhat differently since
# preconv only emits groffish \[uXXXX] escapes for non-ASCII codepoints.
echo "checking -C -k -Thtml" >&2
printf "\('a" | "$groff" -C -k -Thtml | grep -qx '<p>á</p>' \
|| wail
test -z "$fail"
# vim:set autoindent expandtab shiftwidth=2 tabstop=2 textwidth=72:
|