From: Bruno Haible Date: Thu, 15 Dec 2016 21:26:01 +0000 (+0100) Subject: init.sh: Add possibility to not delete temporary files. X-Git-Tag: v1.0~6491 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=3044ae7f4310079527010ddd52be0e117ae28ca6;p=gnulib.git 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/ChangeLog b/ChangeLog index c588296342..f3522e7124 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-12-15 Bruno Haible + + 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 regex: fix integer-overflow bug in never-used code diff --git a/tests/init.sh b/tests/init.sh index da743c2ab0..d780110149 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 }