From 54fd9f10b8536d430448606cf3e29abd60b63ad6 Mon Sep 17 00:00:00 2001 From: Jerome Charaoui Date: Wed, 30 Dec 2020 23:29:24 -0500 Subject: [PATCH] tests: Improve handling of log file during teardown --- test/common.bash | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/common.bash b/test/common.bash index a227ee3..6a38db7 100644 --- a/test/common.bash +++ b/test/common.bash @@ -44,8 +44,14 @@ EOF teardown() { # Print the debug log in case the test case fails - echo "cat ${BATS_TMPDIR}/log/backupninja.log :" - cat "${BATS_TMPDIR}/log/backupninja.log" + if [ -f "${BATS_TMPDIR}/log/backupninja.log" ]; then + echo "cat ${BATS_TMPDIR}/log/backupninja.log :" + cat "${BATS_TMPDIR}/log/backupninja.log" + # Copy logfile so it can be examined in subsequent tests + cp "${BATS_TMPDIR}/log/backupninja.log" "${BATS_TMPDIR}/_backupninja.log" + else + echo "backupninja.log not found" + fi # Clean up rm -rf "${BATS_TMPDIR}/backupninja.conf" \