]> git.notmuchmail.org Git - notmuch/blobdiff - test/test-lib.sh
test-lib.sh: add "atexit" functionality
[notmuch] / test / test-lib.sh
index 988b00afde86b7ff306c2b0812d9b7e6fa0a0428..37f8ddfa4f94ff02cfe294392604b0c08545aa32 100644 (file)
@@ -219,10 +219,21 @@ test_fixed=0
 test_broken=0
 test_success=0
 
+declare -a _exit_functions=()
+
+at_exit_function () {
+       _exit_functions=($1 ${_exit_functions[@]/$1})
+}
+
+rm_exit_function () {
+       _exit_functions=(${_exit_functions[@]/$1})
+}
+
 _exit_common () {
        code=$?
        trap - EXIT
        set +ex
+       for _fn in ${_exit_functions[@]}; do $_fn; done
        rm -rf "$TEST_TMPDIR"
 }