gbranden pushed a commit to branch master
in repository groff.
commit 984451d240d0d3409b615133bf365403a305c955
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Nov 22 22:21:05 2026 -0600
[groff]: Unit-test `pstream` request.
* src/roff/groff/tests/error-pstream-request-given-bogus-argument.sh:
* src/roff/groff/tests/pstream-request-works.sh: New files; do it.
* src/roff/groff/groff.am: Update `groff_TESTS` to run tests.
Continues fixing <https://savannah.gnu.org/bugs/?68952>.
---
ChangeLog | 6 ++
src/roff/groff/groff.am | 2 +
.../error-pstream-request-given-bogus-argument.sh | 22 ++++++
src/roff/groff/tests/pstream-request-works.sh | 83 ++++++++++++++++++++++
4 files changed, 113 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index a3792bbaa..d2b7c6af2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,12 @@
stream name, and dump its info if it exists. in range. Migrate
existing report of all open streams to use new function.
+ * src/roff/groff/tests/\
+ error-pstream-request-given-bogus-argument.sh:
+ * src/roff/groff/tests/pstream-request-works.sh: New files; test
+ it.
+ * src/roff/groff/groff.am: Update `groff_TESTS` to run tests.
+
2026-11-22 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp (struct grostream): Fix code style
diff --git a/src/roff/groff/groff.am b/src/roff/groff/groff.am
index 7d689e915..16f044758 100644
--- a/src/roff/groff/groff.am
+++ b/src/roff/groff/groff.am
@@ -123,6 +123,7 @@ groff_TESTS = \
src/roff/groff/tests/error-pftr-request-given-bogus-argument.sh \
src/roff/groff/tests/error-pi-request-given-empty-argument.sh \
src/roff/groff/tests/error-pso-request-given-empty-argument.sh \
+ src/roff/groff/tests/error-pstream-request-given-bogus-argument.sh \
src/roff/groff/tests/error-rm-request-given-bogus-argument.sh \
src/roff/groff/tests/error-rn-request-given-bogus-arguments.sh \
src/roff/groff/tests/error-rr-request-given-bogus-argument.sh \
@@ -168,6 +169,7 @@ groff_TESTS = \
src/roff/groff/tests/pnr-request-works.sh \
src/roff/groff/tests/po-request-works.sh \
src/roff/groff/tests/ps-device-smoke-test.sh \
+ src/roff/groff/tests/pstream-request-works.sh \
src/roff/groff/tests/pwh-request-works.sh \
src/roff/groff/tests/recognize-end-of-sentence.sh \
src/roff/groff/tests/regression_savannah_56555.sh \
diff --git a/src/roff/groff/tests/error-pstream-request-given-bogus-argument.sh
b/src/roff/groff/tests/error-pstream-request-given-bogus-argument.sh
new file mode 100755
index 000000000..24233d0b0
--- /dev/null
+++ b/src/roff/groff/tests/error-pstream-request-given-bogus-argument.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# This file is part of groff, the GNU roff typesetting system.
+#
+# 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"
+
+output=$(printf '.pstream \002\n' | "$groff" -T ascii)
+
+# vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72:
diff --git a/src/roff/groff/tests/pstream-request-works.sh
b/src/roff/groff/tests/pstream-request-works.sh
new file mode 100755
index 000000000..0a07b4e82
--- /dev/null
+++ b/src/roff/groff/tests/pstream-request-works.sh
@@ -0,0 +1,83 @@
+#!/bin/sh
+#
+# Copyright 2026 G. Branden Robinson
+#
+# This file is part of groff, the GNU roff typesetting system.
+#
+# 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
+}
+
+tmpfile1=savannah-68952a.txt
+tmpfile2=savannah-68952b.txt
+
+cleanup () {
+ rm -f $tmpfile1 $tmpfile2
+}
+
+# A process handling a fatal signal should:
+# 1. Mask all fatal signals of interest. (GBR often excludes ABRT.)
+# 2. Perform cleanup operations.
+# 3. Unmask the signal (removing the handler).
+# 4. Signal its own process group with the signal caught so that the
+# the children exit and shell accurately reports how the process
+# died.
+fatals="HUP INT QUIT TERM"
+for s in $fatals
+do
+ trap "trap '' $fatals; cleanup; trap - $fatals; kill -$s -$$" $s
+done
+
+input='.
+.tmc START:
+.pstream
+.open stream1 '$tmpfile1'
+.open stream2 '$tmpfile2'
+.tmc MIDDLE:
+.pstream stream2
+.close stream1
+.close stream2
+.tmc END:
+.pstream
+.'
+
+output=$(printf '%s\n' "$input" | "$groff" -U)
+echo "$output"
+
+# Expected output:
+# START:[ ]
+# MIDDLE:[{"stream": "stream2", "file name": "savannah-68952b.txt", "mode":
"writing"}]
+# END:[ ]
+
+echo "checking that no streams are open initially" >&2
+echo "$output" | grep -Fqx 'START:[ ]'
+
+echo "checking that argumentful form of 'pstream' request works" >&2
+echo "$output" | grep -Eqx 'MIDDLE:\[{"stream": "stream2", [^]]\+}]'
+
+echo "checking that no streams are open finally" >&2
+echo "$output" | grep -Fqx 'END:[ ]'
+
+cleanup
+test -z "$fail"
+
+# vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72:
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit