gbranden pushed a commit to branch master
in repository groff.

commit de09e1ebc2abcde2ced51b3b3b8249bef631e107
Author: Sven Schober <[email protected]>
AuthorDate: Mon Sep 2 20:11:53 2024 +0200

    [mom]: Test handles discrepant pdf{images,totext}.
    
    * examples/test-mom.sh.in: Handle discrepant `pdf{images,totext}`.
      There are at least two different implementation variants for pdfimages
      and pdftotext out there: poppler's and xpdfreader.com's.  Cope with
      minute syntax differences between these implementations in test case.
    
    Fixes <https://savannah.gnu.org/bugs/?66155> (2/2).
    
    [I tweaked the shell style. --GBR]
---
 contrib/mom/ChangeLog               | 10 ++++++++++
 contrib/mom/examples/test-mom.sh.in | 20 +++++++++++++++-----
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/contrib/mom/ChangeLog b/contrib/mom/ChangeLog
index 1ae753248..0210b368c 100644
--- a/contrib/mom/ChangeLog
+++ b/contrib/mom/ChangeLog
@@ -1,3 +1,13 @@
+2024-09-02  Sven Schober <[email protected]>
+
+       * examples/test-mom.sh.in: Handle discrepant
+       `pdf{images,totext}`.  There are at least two different
+       implementation variants for pdfimages and pdftotext out there:
+       poppler's and xpdfreader.com's.  Cope with minute syntax
+       differences between these implementations in test case.
+
+       Fixes <https://savannah.gnu.org/bugs/?66155> (2/2).
+
 2024-09-07  G. Branden Robinson <[email protected]>
 
        * examples/test-mom.sh.in: Tweak shell style.  Favor `[` command
diff --git a/contrib/mom/examples/test-mom.sh.in 
b/contrib/mom/examples/test-mom.sh.in
index 3fa9be3c6..7a32c079f 100644
--- a/contrib/mom/examples/test-mom.sh.in
+++ b/contrib/mom/examples/test-mom.sh.in
@@ -48,6 +48,15 @@ do
     fi
 done
 
+# At least two different implementations of pdfimages exist, poppler and
+# xpdfreader.com.  The latter uses a slightly different input and output
+# syntax; detect and cope with it.
+image_root=
+if pdfimages -v 2>&1 | grep -q xpdfreader
+then
+  image_root=1
+fi
+
 # $1: PDF file
 # $2: expected number of pages
 check_number_pages()
@@ -62,16 +71,17 @@ check_number_pages()
 }
 
 # $1: PDF file
+# $2: expected number of images
 check_has_images()
 {
     echo "Checking whether $1 has images"
-    image_list=$(pdfimages -list "$1")
+    image_list=$(pdfimages -list "$1" $image_root)
     echo "$image_list"
     # Strip header out of poppler pdfimages output.
     image_count=$(echo "$image_list" | sed -n '1,/^---/d;p' | wc -l)
-    if [ "$image_count" -ne 2 ]
+    if [ "$image_count" -ne "$2" ]
     then
-        echo "...FAILED: expected 2 images, found $image_count"
+        echo "...FAILED: expected $2 images, found $image_count"
         ret=1
     fi
 }
@@ -94,8 +104,8 @@ check_number_pages "$examplesdir/typesetting.pdf" 3
 check_number_pages "$examplesdir/copyright-chapter.pdf" 5
 check_number_pages "$examplesdir/copyright-default.pdf" 5
 
-check_has_images "$examplesdir/typesetting.pdf"
-check_has_images "$examplesdir/slide-demo.pdf"
+check_has_images "$examplesdir/typesetting.pdf" 2
+check_has_images "$examplesdir/slide-demo.pdf" 2
 
 exit $ret
 

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

Reply via email to