groff-commit
[Top][All Lists]
Advanced

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

[groff] 06/10: [troff]: Unit-test device control spec chars.


From: G. Branden Robinson
Subject: [groff] 06/10: [troff]: Unit-test device control spec chars.
Date: Sat, 13 Jan 2024 13:46:59 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 974c063f0a9e1ef6c0d2cac4755a3b9d6e925b0d
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Jan 13 08:08:16 2024 -0600

    [troff]: Unit-test device control spec chars.
    
    * src/roff/groff/tests/device-control-special-character-handling.sh: Add
      unit test for this feature.  We want to be able to consistently pass
      (some) special character escape sequences to device control commands,
      and we want the `device` request and `\X` escape sequences to behave
      consistently with each other.
    
    * src/roff/groff/groff.am (groff_TESTS): Run test.
    
    Test fails at this commit.  See Savannah #64484.
---
 ChangeLog                                          | 10 +++
 src/roff/groff/groff.am                            |  1 +
 .../device-control-special-character-handling.sh   | 77 ++++++++++++++++++++++
 3 files changed, 88 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 0d9860dde..45db977cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-01-13  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/roff/groff/tests/\
+       device-control-special-character-handling.sh: Add unit test for
+       this feature.  We want to be able to consistently pass (some)
+       special character escape sequences to device control commands,
+       and we want the `device` request and `\X` escape sequences to
+       behave consistently with each other.
+       * src/roff/groff/groff.am (groff_TESTS): Run test.
+
 2024-01-13  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/roff/troff/input.cpp (encode_char_for_troff_output):
diff --git a/src/roff/groff/groff.am b/src/roff/groff/groff.am
index 99a8ced95..5c7ed2f3b 100644
--- a/src/roff/groff/groff.am
+++ b/src/roff/groff/groff.am
@@ -45,6 +45,7 @@ groff_TESTS = \
   src/roff/groff/tests/detect-evil-link-time-optimizer.sh \
   src/roff/groff/tests/device-request-works.sh \
   src/roff/groff/tests/device_control_escapes_express_basic_latin.sh \
+  src/roff/groff/tests/device-control-special-character-handling.sh \
   src/roff/groff/tests/do_not_loop_infinitely_when_breaking_cjk.sh \
   src/roff/groff/tests/dot-cp_register_works.sh \
   src/roff/groff/tests/dot-nm_register_works.sh \
diff --git a/src/roff/groff/tests/device-control-special-character-handling.sh 
b/src/roff/groff/tests/device-control-special-character-handling.sh
new file mode 100755
index 000000000..5ad3713d7
--- /dev/null
+++ b/src/roff/groff/tests/device-control-special-character-handling.sh
@@ -0,0 +1,77 @@
+#!/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
+}
+
+input='.nf
+\X#bogus1: esc \%man-beast\[u1F63C]\\[u1F00] -\[aq]\[dq]\[ga]\[ha]\[rs]\[ti]#
+.device bogus1: req \%man-beast\[u1F63C]\\[u1F00] 
-\[aq]\[dq]\[ga]\[ha]\[rs]\[ti]
+.ec @
+@X#bogus2: esc @%man-beast@[u1F63C]@@[u1F00] -@[aq]@[dq]@[ga]@[ha]@[rs]@[ti]#
+.device bogus2: req @%man-beast@[u1F63C]@@[u1F00] 
-@[aq]@[dq]@[ga]@[ha]@[rs]@[ti]'
+
+output=$(printf '%s\n' "$input" | "$groff" -T ps -Z 2> /dev/null \
+  | grep '^x X')
+error=$(printf '%s\n' "$input" | "$groff" -T ps -Z 2>&1 > /dev/null)
+
+echo "$output"
+
+echo "checking X escape sequence, default escape character" >&2
+# x X bogus1: esc man-beast\[u1F00] -'"`^\~
+echo "$output" \
+  | grep -qx 'x X bogus1: esc man-beast\\\[u1F00\] -'"'"'"`^\\~' \
+  || wail
+
+echo "checking device request, default escape character" >&2
+# x X bogus1: req man-beast\[u1F00] -'"`^\~
+echo "$output" \
+  | grep -qx 'x X bogus1: req man-beast\\\[u1F00\] -'"'"'"`^\\~' \
+  || wail
+
+echo "checking X escape sequence, alternate escape character" >&2
+# x X bogus2: esc man-beast\[u1F00] -'"`^\~
+echo "$output" \
+  | grep -qx 'x X bogus2: esc man-beast\\\[u1F00\] -'"'"'"`^\\~' \
+  || wail
+
+echo "checking device request, alternate escape character" >&2
+# x X bogus2: req man-beast\[u1F00] -'"`^\~
+echo "$output" \
+  | grep -qx 'x X bogus2: req man-beast\\\[u1F00\] -'"'"'"`^\\~' \
+  || wail
+
+echo "checking for errors on unsupported special character escapes" >&2
+for lineno in 2 3 5 6
+do
+  echo "$error" \
+    | grep -q 'troff:.*:'$lineno':.* invalid.*device control command' \
+    || wail
+done
+
+test -z "$fail"
+
+# vim:set autoindent expandtab shiftwidth=2 tabstop=2 textwidth=72:



reply via email to

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