gbranden pushed a commit to branch master
in repository groff.
commit 29f5ddf7d7d47a0308deca9489e4365ba50d0fd4
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Jul 11 10:17:47 2024 -0500
[nroff]: Refactor test script.
Migrate to more recent test conventions. Skip test if nroff and groff
versions mismatch. Use `fail` variable and `wail()` function instead of
`set -e`. Report the generated groff command no matter what it is, but
quiet output from grep(1) when checking it for expected output. Add Vim
modeline.
---
src/roff/nroff/tests/verbose_option_works.sh | 53 +++++++++++++++++++---------
1 file changed, 37 insertions(+), 16 deletions(-)
diff --git a/src/roff/nroff/tests/verbose_option_works.sh
b/src/roff/nroff/tests/verbose_option_works.sh
index 85ca8f0ff..8a2b3e38a 100755
--- a/src/roff/nroff/tests/verbose_option_works.sh
+++ b/src/roff/nroff/tests/verbose_option_works.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Copyright (C) 2020 Free Software Foundation, Inc.
+# Copyright (C) 2020-2024 Free Software Foundation, Inc.
#
# This file is part of groff.
#
@@ -18,13 +18,18 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+fail=
+
+wail () {
+ echo ...FAILED >&2
+ fail=YES
+}
+
# Ensure a predictable character encoding.
export LC_ALL=C
export LESSCHARSET=
export GROFF_TYPESETTER=
-set -e
-
export GROFF_TEST_GROFF=${abs_top_builddir:-.}/test-groff
# The $PATH used by an installed nroff at runtime does not match what
@@ -43,26 +48,42 @@ groff_ver=$(nroff -v | awk 'NR == 2 {print $NF}')
echo nroff: $nroff_ver >&2
echo groff: $groff_ver >&2
-test "$nroff_ver" = "$groff_ver"
+if [ "$nroff_ver" != "$groff_ver" ]
+then
+ echo "nroff and groff version numbers mismatch; skipping test" >&2
+ exit 77
+fi
-echo "testing 'nroff -V'" >&2
-nroff -V | sed "$sedexpr" | grep -x "test-groff -Tascii -mtty-char"
+echo "checking 'nroff -V'" >&2
+nroff -V | sed "$sedexpr"
+nroff -V | sed "$sedexpr" | grep -qx "test-groff -Tascii -mtty-char" \
+ || wail
-echo "testing 'nroff -V 1'" >&2
-nroff -V 1 | sed "$sedexpr" | grep -x "test-groff -Tascii -mtty-char 1"
+echo "checking 'nroff -V 1'" >&2
+nroff -V 1 | sed "$sedexpr"
+nroff -V 1 | sed "$sedexpr" \
+ | grep -qx "test-groff -Tascii -mtty-char 1" || wail
-echo "testing 'nroff -V \"1a 1b\"'" >&2
+echo "checking 'nroff -V \"1a 1b\"'" >&2
+nroff -V \"1a 1b\" | sed "$sedexpr"
nroff -V \"1a 1b\" | sed "$sedexpr" \
- | grep -x "test-groff -Tascii -mtty-char \"1a 1b\""
+ | grep -qx "test-groff -Tascii -mtty-char \"1a 1b\"" || wail
-echo "testing 'nroff -V \"1a 1b\" 2'" >&2
+echo "checking 'nroff -V \"1a 1b\" 2'" >&2
+nroff -V \"1a 1b\" 2 | sed "$sedexpr"
nroff -V \"1a 1b\" 2 | sed "$sedexpr" \
- | grep -x "test-groff -Tascii -mtty-char \"1a 1b\" 2"
+ | grep -qx "test-groff -Tascii -mtty-char \"1a 1b\" 2" || wail
-echo "testing 'nroff -V 1a\\\"1b 2'" >&2
+echo "checking 'nroff -V 1a\\\"1b 2'" >&2
+nroff -V 1a\"1b 2 | sed "$sedexpr"
nroff -V 1a\"1b 2 | sed "$sedexpr" \
- | grep -x "test-groff -Tascii -mtty-char 1a\"1b 2"
+ | grep -qx "test-groff -Tascii -mtty-char 1a\"1b 2" || wail
-echo "testing 'nroff -V -d FOO=BAR 1'" >&2
+echo "checking 'nroff -V -d FOO=BAR 1'" >&2
+nroff -V -d FOO=BAR 1 | sed "$sedexpr"
nroff -V -d FOO=BAR 1 | sed "$sedexpr" \
- | grep -x "test-groff -Tascii -mtty-char -d FOO=BAR 1"
+ | grep -qx "test-groff -Tascii -mtty-char -d FOO=BAR 1" || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit