summaryrefslogtreecommitdiffstats
path: root/tmac/tests/andoc_flush-between-packages.sh
blob: 6b24f840f1ce65f1cf37f06bea679cb36ea41c2b (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
#!/bin/sh
#
# Copyright (C) 2020 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"

# Regression-test Savannah #59016.
#
# Ensure that a partially-collected line at the end of a file gets
# flushed, and page footers written,  before proceeding to the next
# document.  Check going from man(7) to mdoc(7) documents and back.

EXAMPLE=\
'.TH man\-flush\-test 7 2020-10-11 "groff test page 1"
.SH Name
man\-flush-test \- a sanity test for groff_man(7)
.SH Description
This gratuitously loquacious sentence should end up with a
partially-collected output line.
.Dd October 11, 2020
.Dt mdoc\-test 7
.Os "groff test page 2"
.Sh Name
.Nm mdoc\-test
.Nd a sanity test for groff_mdoc(7)
.Sh Description
This additional gratuitously loquacious sentence should end up with a
partially-collected output line.
.TH man\-flush\-test2 7 2020-10-11 "groff test page 3"
.SH Name
man\-flush-test2 \- a second sanity test for groff_man(7)
.SH Description
This supernumerary loquacious sentence should end up with a
partially-collected output line.'

OUTPUT=$(printf "%s\n" "$EXAMPLE" | "$groff" -Tascii -P-cbou -mandoc)

FAIL=

# Strip blank lines from the output first; all we care about for this
# test is the presence, adjacency, and ordering of non-blank lines.

if [ -z "$(echo "$OUTPUT" \
    | sed '/^$/d' \
    | sed -n '/collected/{N;/test page 1/p;}')" ]
then
    FAIL=yes
    echo "man to mdoc transition failed" >&2
fi

if [ -z "$(echo "$OUTPUT" \
    | sed '/^$/d' \
    | sed -n '/partially-collected/{N;/test page 2/p;}')" ]
then
    FAIL=yes
    echo "mdoc to man transition failed" >&2
fi

test -z "$FAIL"

# vim:set ai et sw=4 ts=4 tw=72: