From a210c97c83fa6234bc62ceed7e5c74dbd06714f4 Mon Sep 17 00:00:00 2001 From: Evili del Rio <erio@iri.upc.edu> Date: Fri, 26 Oct 2018 13:19:51 +0200 Subject: [PATCH] Add coverage support --- bin/test | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bin/test b/bin/test index abb5dafe..6ccb7df1 100755 --- a/bin/test +++ b/bin/test @@ -18,6 +18,14 @@ MANAGE_FILE=${MANAGE_FILE:-fakepath} #sp-grep -s django && DJANGO_INSTALLED=1 DJANGO_INSTALLED=1 +coverage=$(which coverage 2> /dev/null) +if [ -x "${coverage}" ] +then + test_cmd=${coverage} +else + test_cmd=python +fi + if [ -f "$MANAGE_FILE" ] && [ "$DJANGO_INSTALLED" ]; then set +e @@ -38,7 +46,7 @@ if [ -f "$MANAGE_FILE" ] && [ "$DJANGO_INSTALLED" ]; then python "$MANAGE_FILE" dbshell <<EOF 2>&1 | tee "$TEST_LOG" CREATE ROLE postgres SUPERUSER; EOF - python "$MANAGE_FILE" test 2>&1 | tee "$TEST_LOG" + ${test_cmd} "$MANAGE_FILE" test 2>&1 | tee "$TEST_LOG" TEST_STATUS="${PIPESTATUS[0]}" set -e @@ -53,6 +61,10 @@ EOF exit 1 } + if [ -x "${coverage}" ] + then + ${coverage} report 2>&1 | tee "$TEST_LOG" + fi echo else exit 1 -- GitLab