groff-commit
[Top][All Lists]
Advanced

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

[groff] 10/14: tmac/tests/an_UR-works.sh: Add PDF output tests.


From: G. Branden Robinson
Subject: [groff] 10/14: tmac/tests/an_UR-works.sh: Add PDF output tests.
Date: Thu, 22 Feb 2024 17:49:16 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 795df757b1f22291239eb2618828064e85ec0b64
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Feb 21 22:33:14 2024 -0600

    tmac/tests/an_UR-works.sh: Add PDF output tests.
    
    * tmac/tests/an_UR-works.sh: Add tests of PDF output, using pdftotext(1)
      (from poppler-utils) to scrape the text from PDF.
    
    Test fails at this commit.
---
 ChangeLog                 |  5 +++++
 tmac/tests/an_UR-works.sh | 53 ++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 51 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c851d2261..8896335af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-02-21  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * tmac/tests/an_UR-works.sh: Add tests of PDF output, using
+       pdftotext(1) (from poppler-utils) to scrape the text from PDF.
+
 2024-02-21  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * tmac/pdf.tmac (pdfbookmark): Validate bookmark level argument;
diff --git a/tmac/tests/an_UR-works.sh b/tmac/tests/an_UR-works.sh
index 6100e62ba..17c17bc2d 100755
--- a/tmac/tests/an_UR-works.sh
+++ b/tmac/tests/an_UR-works.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (C) 2022 Free Software Foundation, Inc.
+# Copyright (C) 2022-2024 Free Software Foundation, Inc.
 #
 # This file is part of groff.
 #
@@ -44,26 +44,26 @@ output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou 
-man -rU0)
 echo "$output"
 
 echo "checking formatting of web URI with link text" \
-    "(hyperlinks disabled)" >&2
+    "(ascii device; hyperlinks disabled)" >&2
 echo "$output" | grep -Fq 'See figure 1 <http://foo.example.com>.' \
     || wail
 
 echo "checking formatting of web URI with no link text" \
-    "(hyperlinks disabled)" >&2
+    "(ascii device; hyperlinks disabled)" >&2
 echo "$output" | grep -Fq 'Or <http://bar.example.com>.' || wail
 
 output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -man -rU1)
 echo "$output"
 
 echo "checking formatting of web URI with link text" \
-    "(hyperlinks enabled)" >&2
+    "(ascii device; hyperlinks enabled)" >&2
 echo "$output" | grep -Fq 'See figure 1.' || wail
 
 echo "checking formatting of web URI with no link text" \
-    "(hyperlinks enabled)" >&2
+    "(ascii device; hyperlinks enabled)" >&2
 echo "$output" | grep -Fq 'Or http://bar.example.com.' || wail
 
-input='.TH foo 1 2022-12-04 "groff test suite"
+html_input='.TH foo 1 2022-12-04 "groff test suite"
 .SH Name
 foo \- frobnicate a bar
 .SH "See also"
@@ -73,7 +73,7 @@ check our
 website
 .UE .'
 
-output=$(printf "%s\n" "$input" | "$groff" -man -Thtml)
+output=$(printf "%s\n" "$html_input" | "$groff" -man -Thtml)
 echo "$output"
 
 echo "checking HTML output of web URI" >&2
@@ -81,6 +81,45 @@ echo "$output" \
     | grep -Fqx '<a href="https://example.com";>website</a>.</p>' \
     || wail
 
+# We want to report failure (if it happened) before we attempt checks we
+# might have to skip.
+test -z "$fail" || exit
+
+if ! command -v pdftotext >/dev/null
+then
+    echo "cannot locate 'pdftotext' command" >&2
+    exit 77 # skip
+fi
+
+output=$(printf "%s\n" "$input" | "$groff" -Tpdf -P-d -man -rU0 \
+    | pdftotext - -)
+echo "$output"
+
+echo "checking formatting of web URI with link text" \
+    "(pdf device; hyperlinks disabled)" >&2
+# expected: See figure 1 〈http://foo.example.com〉.
+echo "$output" | grep -q 'See figure 1 .*http://foo.example.com.*\.' \
+    || wail
+
+echo "checking formatting of web URI with no link text" \
+    "(pdf device; hyperlinks disabled)" >&2
+# expected: Or 〈http://bar.example.com〉.
+echo "$output" | grep -q 'Or .*http://bar.example.com.*\.' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tpdf -P-d -man -rU1 \
+    | pdftotext - -)
+echo "$output"
+
+echo "checking formatting of web URI with link text" \
+    "(pdf device; hyperlinks enabled)" >&2
+# expected: See figure 1. Or http://bar.example.com.
+echo "$output" | grep -Fq 'See figure 1. Or' || wail
+
+echo "checking formatting of web URI with no link text" \
+    "(pdf device; hyperlinks enabled)" >&2
+# expected: See figure 1. Or http://bar.example.com.
+echo "$output" | grep -Fq 'Or http://bar.example.com.' || wail
+
 test -z "$fail"
 
 # vim:set ai et sw=4 ts=4 tw=72:



reply via email to

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