groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 08/24: [tmac]: Verify layout of man pages.


From: G. Branden Robinson
Subject: [groff] 08/24: [tmac]: Verify layout of man pages.
Date: Sun, 10 Nov 2024 14:56:20 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit bfc4a9e599738233cd857158ab8f87b5371d085e
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Nov 9 02:41:33 2024 -0600

    [tmac]: Verify layout of man pages.
    
    [man,mdoc,mdoc-old]: Unit-test vertical margins/gross layout.
    
    * tmac/tests/an_vertical-margins-are-correct.sh:
    * tmac/tests/doc-old_vertical-margins-are-correct.sh:
    * tmac/tests/doc_vertical-margins-are-correct.sh: Do it.
    
    * tmac/tmac.am (tmac_TESTS): Run tests.
---
 ChangeLog                                          |   9 ++
 tmac/tests/an_vertical-margins-are-correct.sh      | 111 ++++++++++++++++++++
 tmac/tests/doc-old_vertical-margins-are-correct.sh | 113 +++++++++++++++++++++
 tmac/tests/doc_vertical-margins-are-correct.sh     | 113 +++++++++++++++++++++
 tmac/tmac.am                                       |   3 +
 5 files changed, 349 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index fd5255b36..e40bf6398 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-11-08  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [man,mdoc,mdoc-old]: Unit-test vertical margins/gross layout.
+
+       * tmac/tests/an_vertical-margins-are-correct.sh:
+       * tmac/tests/doc-old_vertical-margins-are-correct.sh:
+       * tmac/tests/doc_vertical-margins-are-correct.sh: Do it.
+       * tmac/tmac.am (tmac_TESTS): Run tests.
+
 2024-11-08  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [man,mdoc]: Use more historically authentic margin of one
diff --git a/tmac/tests/an_vertical-margins-are-correct.sh 
b/tmac/tests/an_vertical-margins-are-correct.sh
new file mode 100755
index 000000000..d12d330b4
--- /dev/null
+++ b/tmac/tests/an_vertical-margins-are-correct.sh
@@ -0,0 +1,111 @@
+#!/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
+}
+
+input1='.
+.TH foo 1 2024-11-08 "groff test suite"
+.nf
+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'
+input2=$(printf "\\c\n'fi\n")
+
+output=$(printf "%s" "$input1" "$input2" \
+    | "$groff" -r cR=0 -m an -T ascii -P -cbou | nl -ba)
+echo "$output"
+
+echo "checking page length" >&2
+test "$(echo "$output" | wc -l)" = 66 || wail
+
+echo "checking placement of page header" >&2
+echo "$output" \
+    | grep -Eqx ' +4[[:space:]]+foo\(1\) +[A-Za-z ]+ +foo\(1\)' || wail
+
+echo "checking placement of first body text line" >&2
+echo "$output" | grep -Eqx ' +8[[:space:]]+1' || wail
+
+echo "checking placement of last body text line" >&2
+echo "$output" | grep -Eqx ' +59[[:space:]]+52' || wail
+
+echo "checking placement of page footer" >&2
+echo "$output" \
+    | grep -Eqx ' +63[[:space:]]+groff test suite +2024-11-08 +1' \
+    || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/doc-old_vertical-margins-are-correct.sh 
b/tmac/tests/doc-old_vertical-margins-are-correct.sh
new file mode 100755
index 000000000..053157617
--- /dev/null
+++ b/tmac/tests/doc-old_vertical-margins-are-correct.sh
@@ -0,0 +1,113 @@
+#!/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
+}
+
+input1='.
+.Dd 2024-11-08
+.Os "groff test suite"
+.Dt foo 1
+.Sh NAME
+.nf
+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'
+input2=$(printf "\\c\n'fi\n")
+
+output=$(printf "%s" "$input1" "$input2" \
+    | "$groff" -r cR=0 -m doc-old -T ascii -P -cbou | nl -ba)
+echo "$output"
+
+echo "checking page length" >&2
+test "$(echo "$output" | wc -l)" = 66 || wail
+
+echo "checking placement of page header" >&2
+echo "$output" \
+    | grep -Eqx ' +4[[:space:]]+foo\(1\) +[A-Za-z ]+ +foo\(1\)' || wail
+
+echo "checking placement of first body text line" >&2
+echo "$output" | grep -Eqx ' +8[[:space:]]+NAME' || wail
+
+echo "checking placement of last body text line" >&2
+echo "$output" | grep -Eqx ' +59[[:space:]]+51' || wail
+
+echo "checking placement of page footer" >&2
+echo "$output" \
+    | grep -Eqx ' +63[[:space:]]+groff test suite +2024-11-08 +1' \
+    || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/doc_vertical-margins-are-correct.sh 
b/tmac/tests/doc_vertical-margins-are-correct.sh
new file mode 100755
index 000000000..addcfd5fb
--- /dev/null
+++ b/tmac/tests/doc_vertical-margins-are-correct.sh
@@ -0,0 +1,113 @@
+#!/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
+}
+
+input1='.
+.Dd 2024-11-08
+.Dt foo 1
+.Os "groff test suite"
+.nf
+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'
+input2=$(printf "\\c\n'fi\n")
+
+output=$(printf "%s" "$input1" "$input2" \
+    | "$groff" -r cR=0 -m doc -T ascii -P -cbou | nl -ba)
+echo "$output"
+
+echo "checking page length" >&2
+test "$(echo "$output" | wc -l)" = 66 || wail
+
+echo "checking placement of page header" >&2
+echo "$output" \
+    | grep -Eqx ' +4[[:space:]]+foo\(1\) +[A-Za-z ]+ +foo\(1\)' || wail
+
+echo "checking placement of first body text line" >&2
+echo "$output" | grep -Eqx ' +8[[:space:]]+1' || wail
+
+echo "checking placement of last body text line" >&2
+echo "$output" | grep -Eqx ' +59[[:space:]]+52' || wail
+
+echo "checking placement of page footer" >&2
+echo "$output" \
+    | grep -Eqx ' +63[[:space:]]+groff test suite +2024-11-08 +1' \
+    || 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 a8c3390d6..8a8da7e5c 100644
--- a/tmac/tmac.am
+++ b/tmac/tmac.am
@@ -190,11 +190,13 @@ tmac_TESTS = \
   tmac/tests/an_reset-hyphenation-correctly.sh \
   tmac/tests/an_title-abbreviation-works.sh \
   tmac/tests/an_use-input-traps-correctly.sh \
+  tmac/tests/an_vertical-margins-are-correct.sh \
   tmac/tests/an_works-with-ec.sh \
   tmac/tests/andoc_P-register-works.sh \
   tmac/tests/andoc_check-an-to-doc-transition.sh \
   tmac/tests/andoc_clear-doc-traps.sh \
   tmac/tests/andoc_flush-between-packages.sh \
+  tmac/tests/doc-old_vertical-margins-are-correct.sh \
   tmac/tests/doc_CS-register-works.sh \
   tmac/tests/doc_CT-register-works.sh \
   tmac/tests/doc_D-register-places-page-numbers-correctly.sh \
@@ -215,6 +217,7 @@ tmac_TESTS = \
   tmac/tests/doc_reset-data-between-documents.sh \
   tmac/tests/doc_smoke-test.sh \
   tmac/tests/doc_synopsis-is-not-adjusted.sh \
+  tmac/tests/doc_vertical-margins-are-correct.sh \
   tmac/tests/e_chapter-titles-work.sh \
   tmac/tests/e_columns-work-on-long-pages.sh \
   tmac/tests/e_delayed-text-marks-work.sh \



reply via email to

[Prev in Thread] Current Thread [Next in Thread]