groff-commit
[Top][All Lists]
Advanced

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

[groff] 05/11: [gdiffmk]: Refactor file handling in test.


From: G. Branden Robinson
Subject: [groff] 05/11: [gdiffmk]: Refactor file handling in test.
Date: Thu, 9 Feb 2023 19:43:53 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit ab4be66238af97ebb14a6a0e44cd004d3da31078
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Feb 6 16:49:42 2023 -0600

    [gdiffmk]: Refactor file handling in test.
    
    * contrib/gdiffmk/tests/runtests.sh: Refactor file handling.  Use
      narrower globs to match the file names actually used; they are
      suffixed with a dot a number, not a number alone.  Honor $TMPDIR when
      creating the even-more-temporary file.  Revise trap setup so that the
      trap handler cannot be interrupted if it is already running.  Call the
      handler, then commit suicide with SIGINT.  Use symbolic names for
      signals, not numbers.  Call new CleanUp function before exiting
      normally.
    
      (CleanUp): Pull temporary file clean-up logic into new function.  Also
      delete the even-more-temporary file used in test 1.
---
 contrib/gdiffmk/ChangeLog         | 13 +++++++++++++
 contrib/gdiffmk/tests/runtests.sh | 15 +++++++++++----
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/contrib/gdiffmk/ChangeLog b/contrib/gdiffmk/ChangeLog
index d4d15a874..c34cb37a3 100644
--- a/contrib/gdiffmk/ChangeLog
+++ b/contrib/gdiffmk/ChangeLog
@@ -1,3 +1,16 @@
+2023-02-06  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * tests/runtests.sh: Refactor file handling.  Use narrower globs
+       to match the file names actually used; they are suffixed with a
+       dot a number, not a number alone.  Honor $TMPDIR when creating
+       the even-more-temporary file.  Revise trap setup so that the
+       trap handler cannot be interrupted if it is already running.
+       Call the handler, then commit suicide with SIGINT.  Use symbolic
+       names for signals, not numbers.  Call new CleanUp function
+       before exiting normally.
+       (CleanUp): Pull temporary file clean-up logic into new function.
+       Also delete the even-more-temporary file used in test 1.
+
 2022-10-18  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * gdiffmk.sh: Drop "GNU" from version information, since this
diff --git a/contrib/gdiffmk/tests/runtests.sh 
b/contrib/gdiffmk/tests/runtests.sh
index f8291b0a4..184864698 100755
--- a/contrib/gdiffmk/tests/runtests.sh
+++ b/contrib/gdiffmk/tests/runtests.sh
@@ -31,7 +31,7 @@ command=${abs_top_builddir}/gdiffmk
 #      Test the number of arguments and the first argument.
 case "$#-$1" in
 1-clean )
-       rm -fv result* tmp_file*
+       rm -fv result.* tmp_file.*
        exit 0
        ;;
 1-run )
@@ -40,7 +40,7 @@ case "$#-$1" in
        echo >&2 "$0 [ clean | run ]
 Run a few simple tests on '${command}'."'
 
-clean  Remove the result? and tmp_file? files.
+clean  Remove the result.? and tmp_file.? files.
 run    Run the tests.
 '
        exit 255
@@ -63,8 +63,13 @@ TestResult () {
        fi
 }
 
-tmpfile=/tmp/$$
-trap 'rm -f ${tmpfile}' 0 1 2 3 15
+CleanUp () {
+       rm -f tmp_file.* ${tmpfile}
+}
+
+tmpfile=${TMPDIR:-/tmp}/$$
+trap 'trap "" HUP INT QUIT TERM; CleanUp; kill -s INT $$' \
+       HUP INT QUIT TERM
 
 #      Run tests.
 
@@ -149,6 +154,8 @@ TestResult ${srcdir}/baseline.10 ${ResultFile}
 
 echo failure_count ${failure_count}
 
+CleanUp
+
 exit ${exit_code}
 
 #      EOF



reply via email to

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