test: Add support for teardown in tests

If a test defines a function 'test_teardown(), that function will be
called before the test env teardown is run.

Signed-off-by: Magnus Malm <magnusmalm@gmail.com>
This commit is contained in:
Magnus Malm committed 2021-02-23 08:55:11 +01:00
1 parent 70773105ac
commit 4480010d4a
2 files changed
+13 -3

No files matched your search

+5
View File
@@ -69,6 +69,11 @@ say() {
teardown() {
test_status="$?"
if type test_teardown > /dev/null 2>&1 ; then
test_teardown
fi
log "$color_reset" '--' ''
if [ "$test_status" -eq 0 ]; then
log "$fg_green" 'TEST PASS' ''