#!/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 #XXXXX.

EXAMPLE='\
.Dd September 11, 2020
.Dt mdoc\-test 7
.Os
.Sh NAME \" It REALLY DOES need to be in full caps.
.Nm mdoc\-test
.Nd a correctness test for groff'"'"'s mdoc implementation
.Sh Description
When rendering multiple man page documents,
a partially-collected line at the end of an
.Xr mdoc 7
page would not be flushed before rendering the next page,
omitting that line and the page footer from the output.
.
The next man page would emit the partially-collected line from the
previous page between its header and summary.
.
.Pp
This is a short line.'

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

#if ! echo "$OUTPUT" | grep -qE '^mdoc-test\(7\) +BSD Miscellaneous'
#then
#    FAIL=yes
#    echo "header check failed" >&2
#fi

echo "$OUTPUT"
test -z "$FAIL"

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