groff-commit
[Top][All Lists]
Advanced

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

[groff] 05/23: [hdtbl]: Tweak shell style in test script.


From: G. Branden Robinson
Subject: [groff] 05/23: [hdtbl]: Tweak shell style in test script.
Date: Thu, 21 Nov 2024 14:47:47 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit c472f1096dcaf1da0ddc56e5db2dd497109fc969
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue Nov 19 21:33:53 2024 -0600

    [hdtbl]: Tweak shell style in test script.
    
    * examples/test-hdtbl.sh.in: Favor `[` command over `test` in control
      structures.  Use Bourne style for control structures, not pseudo-C.
      Quote variables that are not under the script's control, in case they
      contain whitespace.  Write messages to standard error, not standard
      output.  Exit with status 2 if an artifact can't be found-- the build
      should have produced it if Ghostscript is available.  Favor `$()`
      command substitution syntax over "backticks"; the groff 1.23.0
      release, with 100+ test scripts using the former syntax, established
      that every platform of interest to us supports it.  Break long lines.
      Align wording of messages with groff's other test scripts.
---
 contrib/hdtbl/ChangeLog                 | 16 ++++++++++++++++
 contrib/hdtbl/examples/test-hdtbl.sh.in | 31 +++++++++++++++++++++----------
 2 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/contrib/hdtbl/ChangeLog b/contrib/hdtbl/ChangeLog
index 6500e8641..3180cb47a 100644
--- a/contrib/hdtbl/ChangeLog
+++ b/contrib/hdtbl/ChangeLog
@@ -1,3 +1,19 @@
+2024-11-19  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [hdtbl]: Tweak shell style in test script.
+
+       * examples/test-hdtbl.sh.in: Favor `[` command over `test` in
+       control structures.  Use Bourne style for control structures,
+       not pseudo-C.  Quote variables that are not under the script's
+       control, in case they contain whitespace.  Write messages to
+       standard error, not standard output.  Exit with status 2 if an
+       artifact can't be found--the build should have produced it if
+       Ghostscript is available.  Favor `$()` command substitution
+       syntax over "backticks"; the groff 1.23.0 release, with 100+
+       test scripts using the former syntax, established that every
+       platform of interest to us supports it.  Break long lines.
+       Align wording of messages with groff's other test scripts.
+
 2024-11-21  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * examples/fonts_n.in (fontdump):
diff --git a/contrib/hdtbl/examples/test-hdtbl.sh.in 
b/contrib/hdtbl/examples/test-hdtbl.sh.in
index c68b8ead8..ebe8f1de1 100644
--- a/contrib/hdtbl/examples/test-hdtbl.sh.in
+++ b/contrib/hdtbl/examples/test-hdtbl.sh.in
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (C) 2018 Free Software Foundation, Inc.
+# Copyright (C) 2018-2024 Free Software Foundation, Inc.
 #
 # This file is part of groff.
 #
@@ -25,24 +25,35 @@ builddir="@abs_top_builddir@"
 gs_program="@GHOSTSCRIPT@"
 ret=0
 
-if test "$gs_program" = "missing"; then
-   echo "ghostscript program missing, can't check hdtbl examples"
+if [ "$gs_program" = "missing" ]
+then
+   echo "ghostscript program missing, can't check hdtbl examples" >&2
    exit 77
 fi
 
 # $1 file, $2 expected number of pages
 check_number_pages()
 {
-    echo "Checking $1"
-    res=`$gs_program -o /dev/null/ -sDEVICE=bbox "$1" 2>&1 | grep 
HiResBoundingBox | wc -l`
-    if test $res != $2; then
-        echo "  Error: expected $2 pages, found $res pages"
-        ret=255
+    echo "checking $1 for $2 pages" >&2
+
+    if ! [ -r "$1" ]
+    then
+        echo "error: \"$1\" does not exist or is not readable" >&2
+        exit 2
+    fi
+
+    res=$("$gs_program" -o /dev/null/ -sDEVICE=bbox "$1" 2>&1 \
+          | grep HiResBoundingBox | wc -l)
+
+    if [ "$res" != $2 ]
+    then
+        echo "...FAILED; found $res page(s)" >&2
+        ret=1
     fi
 }
 
-check_number_pages $builddir/contrib/hdtbl/examples/fonts_n.ps 38
-check_number_pages $builddir/contrib/hdtbl/examples/fonts_x.ps 38
+check_number_pages "$builddir"/contrib/hdtbl/examples/fonts_n.ps 38
+check_number_pages "$builddir"/contrib/hdtbl/examples/fonts_x.ps 38
 
 exit $ret
 



reply via email to

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