[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
init.sh: add option to preserve temporary files
From: |
Bruno Haible |
Subject: |
init.sh: add option to preserve temporary files |
Date: |
Thu, 15 Dec 2016 22:24:53 +0100 |
User-agent: |
KMail/4.8.5 (Linux/3.8.0-44-generic; KDE/4.8.5; x86_64; ; ) |
Hi,
init.sh is used in the GNU gettext test suite, and I frequently have the need
to inspect temporary files after a test failure (or even after an unexpected
test pass). Therefore here's a proposed patch that introduces an option to do
this.
2016-12-15 Bruno Haible <address@hidden>
init.sh: Add possibility to not delete temporary files.
* tests/init.sh (remove_tmp_): If the environment variable KEEP is set
to yes,
don't erase the temporary directory.
diff --git a/tests/init.sh b/tests/init.sh
index da743c2..d780110 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -45,6 +45,9 @@
# Running a single test, with verbose output:
# $ make check TESTS=test-foo.sh VERBOSE=yes
#
+# Running a single test, keeping the temporary directory:
+# $ make check TESTS=test-foo.sh KEEP=yes
+#
# Running a single test, with single-stepping:
# 1. Go into a sub-shell:
# $ bash
@@ -349,11 +352,15 @@ remove_tmp_ ()
{
__st=$?
cleanup_
- # cd out of the directory we're about to remove
- cd "$initial_cwd_" || cd / || cd /tmp
- chmod -R u+rwx "$test_dir_"
- # If removal fails and exit status was to be 0, then change it to 1.
- rm -rf "$test_dir_" || { test $__st = 0 && __st=1; }
+ if test "$KEEP" = yes; then
+ echo "Not removing temporary directory $test_dir_"
+ else
+ # cd out of the directory we're about to remove
+ cd "$initial_cwd_" || cd / || cd /tmp
+ chmod -R u+rwx "$test_dir_"
+ # If removal fails and exit status was to be 0, then change it to 1.
+ rm -rf "$test_dir_" || { test $__st = 0 && __st=1; }
+ fi
exit $__st
}
- init.sh: add option to preserve temporary files,
Bruno Haible <=