]> Savannah Git Hosting - gnulib.git/commitdiff
init.sh: Add possibility to not delete temporary files.
authorBruno Haible <bruno@clisp.org>
Thu, 15 Dec 2016 21:26:01 +0000 (22:26 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 16 Dec 2016 18:21:23 +0000 (19:21 +0100)
* tests/init.sh (remove_tmp_): If the environment variable KEEP is set
to yes, don't erase the temporary directory.

ChangeLog
tests/init.sh

index c588296342af5e05bf3d9c8ea062b9c63836cb8b..f3522e71245b434395aa0d5cc3869cd56970d3ce 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2016-12-15  Bruno Haible  <bruno@clisp.org>
+
+       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.
+
 2016-12-16  Paul Eggert  <eggert@cs.ucla.edu>
 
        regex: fix integer-overflow bug in never-used code
index da743c2ab0dd1f2e88dcf4ca7770b2c137b6a250..d780110149311e788752907b67fd3ca49e23da8c 100644 (file)
@@ -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
 }