From 174cd7e2f7ac822b43c108ac4e3f6417e51fbc44 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Sat, 29 May 2010 01:31:49 +0200 Subject: [PATCH] Add cron for running misc tests (Closes #1036) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * make test Signed-off-by: Raphaël Barrois --- bin/cron/run_tests.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 bin/cron/run_tests.sh diff --git a/bin/cron/run_tests.sh b/bin/cron/run_tests.sh new file mode 100755 index 0000000..9e11558 --- /dev/null +++ b/bin/cron/run_tests.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +CRONDIR=$(dirname $0) +PWD=$(pwd) +PLATAL_ROOT=${CRONDIR}/../.. + +# Executes a command and displays its output only if retcode != 0 +# @param dir Folder from which the command should be called +# @param cmd The command to execute +# After execution, the pwd is returned to its initial value. +function print_if_err { + local dir cmd retcode tmpfile + dir=$1 + cmd=$2 + + echo "* Running ${cmd}..." + # Capture output and return code + tmpfile=$(mktemp pl_run_tests.XXXXXX) + cd ${dir} && ${cmd} 2>&1 > ${tmpfile} + retcode=$? + + if [ "x${retcode}" != "x0" ]; then + echo "** Error running command ${cmd} (code ${retcode})" + cat ${tmpfile} + rm -f ${tmpfile} + exit ${retcode} + fi + + # Cleanup + rm -f ${tmpfile} + cd ${PWD} +} + +print_if_err ${PLATAL_ROOT} "make test" -- 2.1.4