summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorG. Branden Robinson <g.branden.robinson@gmail.com>2023-02-06 16:49:42 -0600
committerG. Branden Robinson <g.branden.robinson@gmail.com>2023-02-09 10:33:56 -0600
commitab4be66238af97ebb14a6a0e44cd004d3da31078 (patch)
tree05597402f1a178fab3b917384135ef58c4e423f0 /contrib
parent19afc98d213c86504a5475786987c6f86c6817fa (diff)
downloadgroff-git-ab4be66238af97ebb14a6a0e44cd004d3da31078.tar.gz
[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.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/gdiffmk/ChangeLog13
-rwxr-xr-xcontrib/gdiffmk/tests/runtests.sh15
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