gbranden pushed a commit to branch master
in repository groff.

commit 14b482e196e1a3604292e95c1d0735773dc77812
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Oct 22 14:35:28 2025 -0500

    [gropdf]: Add negative testing to new unit tests.
    
    Check that `man:` URIs are not incorrectly rewritten as internal links
    when no corresponding bookmark exists.
    
    * tmac/tests/an_MR-internal-hyperlinks-work-with-pdfmom.sh:
    * tmac/tests/andoc_internal-hyperlinks-work-with-pdfmom.sh:
    * tmac/tests/doc_Xr-internal-hyperlinks-work-with-pdfmom.sh: Do it.
---
 ChangeLog                                                | 11 +++++++++++
 tmac/tests/an_MR-internal-hyperlinks-work-with-pdfmom.sh |  8 ++++++++
 tmac/tests/andoc_internal-hyperlinks-work-with-pdfmom.sh | 16 ++++++++++++++++
 .../tests/doc_Xr-internal-hyperlinks-work-with-pdfmom.sh |  9 +++++++++
 4 files changed, 44 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index cddada105..34cb51a02 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2025-10-22  G. Branden Robinson <[email protected]>
+
+       [gropdf]: Add negative testing to new unit tests; check that
+       `man:` URIs are not incorrectly rewritten as internal links when
+       no corresponding bookmark exists.
+
+       * tmac/tests/an_MR-internal-hyperlinks-work-with-pdfmom.sh:
+       * tmac/tests/andoc_internal-hyperlinks-work-with-pdfmom.sh:
+       * tmac/tests/doc_Xr-internal-hyperlinks-work-with-pdfmom.sh: Do
+       it.
+
 2025-10-21  G. Branden Robinson <[email protected]>
 
        [gropdf]: Add unit tests for pdfmom(1)'s replacement of external
diff --git a/tmac/tests/an_MR-internal-hyperlinks-work-with-pdfmom.sh 
b/tmac/tests/an_MR-internal-hyperlinks-work-with-pdfmom.sh
index 220b27662..13e8094de 100755
--- a/tmac/tests/an_MR-internal-hyperlinks-work-with-pdfmom.sh
+++ b/tmac/tests/an_MR-internal-hyperlinks-work-with-pdfmom.sh
@@ -43,6 +43,8 @@ bar \\- a command that is difficult to use
 .SH Description
 Novice users should avoid this command in favor of its wrapper,
 .MR foo 1 .
+An even more esoteric interface is
+.MR baz 1 .
 .'
 
 output=$(echo "$input" \
@@ -52,6 +54,7 @@ echo "$output"
 # Expected (lines truncated):
 #  109 x X pdf: markstart 6830 -1770 2000 /Subtype /Link /Dest /bar(1)
 #  265 x X pdf: markstart 6830 -1770 2000 /Subtype /Link /Dest /foo(1)
+#  301 x X pdf: markstart 6830 -140 2000 /Subtype /Link /Action << /Subtype 
/URI /URI (man:baz(1))
 
 echo "checking that backward internal links work" >&2
 echo "$output" \
@@ -63,6 +66,11 @@ echo "$output" \
   | grep -Eq '^ *109[[:space:]]+x X pdf: markstart .*/Dest /bar\(1\)' \
   || wail
 
+echo "checking that external links are not rewritten" >&2
+echo "$output" \
+  | grep -Eq '^ *301[[:space:]]+x X pdf: markstart .*/URI \(man:baz\(1\))' \
+  || wail
+
 test -z "$fail"
 
 # vim:set autoindent expandtab shiftwidth=2 tabstop=2 textwidth=72:
diff --git a/tmac/tests/andoc_internal-hyperlinks-work-with-pdfmom.sh 
b/tmac/tests/andoc_internal-hyperlinks-work-with-pdfmom.sh
index f7e91ce86..234701bf6 100755
--- a/tmac/tests/andoc_internal-hyperlinks-work-with-pdfmom.sh
+++ b/tmac/tests/andoc_internal-hyperlinks-work-with-pdfmom.sh
@@ -50,6 +50,8 @@ The real work is done by
 .Sh Description
 Novice users should avoid this command in favor of its wrapper,
 .Xr foo 1 .
+An even more esoteric interface is
+.Xr baz 1 .
 .'
 
 output1=$(echo "$input1" \
@@ -59,6 +61,7 @@ echo "$output1"
 # Expected (lines truncated):
 #  109 x X pdf: markstart 6830 -1770 2000 /Subtype /Link /Dest /bar(1)
 #  244 x X pdf: markstart 6830 -1770 2000 /Subtype /Link /Dest /foo(1)
+#  278 x X pdf: markstart 6830 -140 2000 /Subtype /Link /Action << /Subtype 
/URI /URI (man:baz(1))
 
 echo "checking that backward internal link from mdoc(7) document" \
   "to man(7) document works" >&2
@@ -72,6 +75,11 @@ echo "$output1" \
   | grep -Eq '^ *109[[:space:]]+x X pdf: markstart .*/Dest /bar\(1\)' \
   || wail
 
+echo "checking that external links are not rewritten" >&2
+echo "$output1" \
+  | grep -Eq '^ *278[[:space:]]+x X pdf: markstart .*/URI \(man:baz\(1\)\)' \
+  || wail
+
 # Second, arrange an mdoc(7) document before a man(7) one.
 
 input2='.
@@ -90,6 +98,8 @@ bar \\- a command that is difficult to use
 .SH Description
 Novice users should avoid this command in favor of its wrapper,
 .MR foo 1 .
+An even more esoteric interface is
+.MR baz 1 .
 .'
 
 output2=$(echo "$input1" \
@@ -99,6 +109,7 @@ echo "$output2"
 # Expected (lines truncated):
 #  109 x X pdf: markstart 6830 -1770 2000 /Subtype /Link /Dest /bar(1)
 #  244 x X pdf: markstart 6830 -1770 2000 /Subtype /Link /Dest /foo(1)
+#  278 x X pdf: markstart 6830 -140 2000 /Subtype /Link /Action << /Subtype 
/URI /URI (man:baz(1))
 
 echo "checking that backward internal link from man(7) document" \
   "to mdoc(7) document works" >&2
@@ -112,6 +123,11 @@ echo "$output2" \
   | grep -Eq '^ *109[[:space:]]+x X pdf: markstart .*/Dest /bar\(1\)' \
   || wail
 
+echo "checking that external links are not rewritten" >&2
+echo "$output2" \
+  | grep -Eq '^ *278[[:space:]]+x X pdf: markstart .*/URI \(man:baz\(1\))' \
+  || wail
+
 test -z "$fail"
 
 # vim:set autoindent expandtab shiftwidth=2 tabstop=2 textwidth=72:
diff --git a/tmac/tests/doc_Xr-internal-hyperlinks-work-with-pdfmom.sh 
b/tmac/tests/doc_Xr-internal-hyperlinks-work-with-pdfmom.sh
index 663901e93..8d502ac2b 100755
--- a/tmac/tests/doc_Xr-internal-hyperlinks-work-with-pdfmom.sh
+++ b/tmac/tests/doc_Xr-internal-hyperlinks-work-with-pdfmom.sh
@@ -49,15 +49,19 @@ The real work is done by
 .Sh Description
 Novice users should avoid this command in favor of its wrapper,
 .Xr foo 1 .
+An even more esoteric interface is
+.Xr baz 1 .
 .'
 
 output=$(echo "$input" \
   | GROFF_COMMAND="$groff" "$pdfmom" --roff -rU1 -mdoc -Z | nl -ba)
 echo "$output"
 
+exit
 # Expected (lines truncated):
 #   90 x X pdf: markstart 6830 -1770 2000 /Subtype /Link /Dest /bar(1)
 #  222 x X pdf: markstart 6830 -1770 2000 /Subtype /Link /Dest /foo(1)
+#  256 x X pdf: markstart 6830 -140 2000 /Subtype /Link /Action << /Subtype 
/URI /URI (man:baz(1))
 
 echo "checking that backward internal links work" >&2
 echo "$output" \
@@ -69,6 +73,11 @@ echo "$output" \
   | grep -Eq '^ *90[[:space:]]+x X pdf: markstart .*/Dest /bar\(1\)' \
   || wail
 
+echo "checking that external links are not rewritten" >&2
+echo "$output" \
+  | grep -Eq '^ *256[[:space:]]+x X pdf: markstart .*/URI \(man:baz\(1\))' \
+  || wail
+
 test -z "$fail"
 
 # vim:set autoindent expandtab shiftwidth=2 tabstop=2 textwidth=72:

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to