[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 01/02: tmac/tests/doc_Xr-works.sh: Unit-test `Xr` macro.
From: |
G. Branden Robinson |
Subject: |
[groff] 01/02: tmac/tests/doc_Xr-works.sh: Unit-test `Xr` macro. |
Date: |
Thu, 22 Feb 2024 22:17:02 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit b6546ec2c874c40e465f42a5903517bde1736bb5
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Thu Feb 22 20:48:08 2024 -0600
tmac/tests/doc_Xr-works.sh: Unit-test `Xr` macro.
---
ChangeLog | 5 +++
tmac/tests/doc_Xr-works.sh | 80 ++++++++++++++++++++++++++++++++++++++++++++++
tmac/tmac.am | 1 +
3 files changed, 86 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 9b49cc27f..2855ae4d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-02-22 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * tmac/tests/doc_Xr-works.sh: Unit-test `Xr` macro.
+ * tmac/tmac.am (tmac_TESTS): Run test.
+
2024-02-21 G. Branden Robinson <g.branden.robinson@gmail.com>
* tmac/an.tmac (an*end-hyperlink): Fix bug: when no link text
diff --git a/tmac/tests/doc_Xr-works.sh b/tmac/tests/doc_Xr-works.sh
new file mode 100755
index 000000000..5706431cf
--- /dev/null
+++ b/tmac/tests/doc_Xr-works.sh
@@ -0,0 +1,80 @@
+#!/bin/sh
+#
+# Copyright (C) 2024 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"
+
+fail=
+
+wail() {
+ echo ...FAILED >&2
+ fail=yes
+}
+
+# Unit test the Xr maco.
+
+input='.Dd 2024-02-22
+.Dt foo 1
+.Os "groff test suite"
+.Sh Name
+.Nm foo
+.Nd frobnicate a bar
+.Sh Description.
+Degenerate macro call here.
+.Xr
+.Pp
+Read the
+.Xr groff 1
+man page.
+.Pp
+Read the man page
+.Xr groff 1 ,
+reflect,
+and find enlightenment.
+.Pp
+The
+.Xr groff ,
+.Xr groff_diff ,
+and
+.Xr roff
+pages in section 7 are also illuminating.'
+
+output=$(echo "$input" | "$groff" -Tascii -P-cbou -mdoc 2>/dev/null)
+error=$(echo "$input" | "$groff" -Tascii -P-cbou -mdoc 2>&1 >/dev/null)
+echo "$output"
+echo "$error"
+
+echo "checking for error diagnostic on argumentless Xr call" >&2
+echo "$error" | grep -q '9' || wail
+
+echo "checking two-argument Xr call with full cross reference" >&2
+echo "$output" \
+ | grep -Fq 'Read the groff(1) man page.' || wail
+
+echo "checking two-argument Xr call with partial reference and" \
+ "trailing punctuation" >&2
+echo "$output" \
+ | grep -Fq 'Read the man page groff(1), reflect,' || wail
+
+echo "checking a series of partial references, some punctuated" >&2
+echo "$output" \
+ | grep -Fq 'The groff, groff_diff, and roff pages' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tmac.am b/tmac/tmac.am
index e7b9bcb7b..00bf256a7 100644
--- a/tmac/tmac.am
+++ b/tmac/tmac.am
@@ -208,6 +208,7 @@ tmac_TESTS = \
tmac/tests/doc_P-register-works.sh \
tmac/tests/doc_TS-do-not-keep-tables-when-cR-set.sh \
tmac/tests/doc_X-register-works.sh \
+ tmac/tests/doc_Xr-works.sh \
tmac/tests/doc_accept-mixed-case-section-headings.sh \
tmac/tests/doc_do-not-loop-infinitely-when-shortening-headers.sh \
tmac/tests/doc_heading-font-remapping-works.sh \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 01/02: tmac/tests/doc_Xr-works.sh: Unit-test `Xr` macro.,
G. Branden Robinson <=