+2011-10-25 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ test defs: new function 'am_keeping_testdirs', for better APIs
+
+ This change is meant to make it easier for TAP-based test scripts
+ to remove files left over by completed (sub)tests, while still
+ honoring the user-provided `$keep_testdirs' setting.
+
+ * tests/defs (am_keeping_testdirs): New function, telling whether
+ we should keep the test directories around, even in case of
+ success (by default, we don't).
+ (exit trap): Use it.
+ * tests/depmod.tap: Likewise.
+ * tests/instspc.tap: Likewise. Also, fix some pre-existing
+ "copy & paste" bugs, and a typo in comments.
+
2011-10-25 Stefano Lattarini <stefano.lattarini@gmail.com>
tests: remove redundant `set -e', and other minor improvements
## Auxiliary shell functions. ##
## ---------------------------- ##
+# Tell whether we should keep the test directories around, even in
+# case of success. By default, we don't.
+am_keeping_testdirs ()
+{
+ case $keep_testdirs in
+ ""|n|no|NO) return 1;;
+ *) return 0;;
+ esac
+}
+
# This is used in `Exit' and in the exit trap. See comments in the latter
# for more information,
am__test_skipped=no
trap 'exit_status=$?
set +e
cd "$testbuilddir"
- if test -n "$keep_testdirs"; then
- keep_testdirs=yes
- else
- keep_testdirs=no
- fi
if test $am_using_tap = yes; then
if test $have_tap_plan_ != yes && test $exit_status -eq 0; then
plan_ "now"
esac
test $exit_status -eq 0 || keep_testdirs=yes
fi
- test $keep_testdirs = no && rm_rf_ $testSubDir
+ am_keeping_testdirs || rm_rf_ $testSubDir
set +x
echo "$me: exit $exit_status"
exit $exit_status
# expected to be skipped (which ones exactly depends on the system),
# thus causing the test directory not to be removed when the script
# terminates.
- case $keep_testdirs,$r0,$r1 in
- ,ok,ok) rm_rf_ $depmode-$vpath.d;;
- *) : For lesser shells with broken 'set -e';;
- esac
+ if not am_keeping_testdirs && test "$r0,$r1" = ok,ok; then
+ rm_rf_ $depmode-$vpath.d \
+ || fatal_ "removing directory \`$depmode-$vpath.d'"
+ else
+ : For lesser shells with broken 'set -e'.
+ fi
done
done
unset n
else
test_names_list=$all_test_names_list
- # Prefer static TAP plan if possible, minimizes the chance of errors.
+ # Prefer static TAP plan if possible, it minimizes the chance of errors.
plan_ 94
fi
# with a too big test directory. This is especially important since
# some tests in this tests are expected to fail, and this will cause
# the test directory not to be removed when the script terminates.
- case $keep_testdirs,$r1 in
- ,ok) rm_rf_ $depmode-$vpath.d;;
- *) : For lesser shells with broken 'set -e';;
- esac
+ if not am_keeping_testdirs && test "$r" = ok; then
+ rm_rf_ "$build" "$dest" || fatal_ "removing temporary subdirectory"
+ else
+ : For lesser shells with broken 'set -e'.
+ fi
done # $instspc_action