From: Raphaël Barrois Date: Fri, 28 May 2010 23:31:49 +0000 (+0200) Subject: Add cron for running misc tests (Closes #1036) X-Git-Tag: xorg/1.0.0~148 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=174cd7e2f7ac822b43c108ac4e3f6417e51fbc44;p=platal.git Add cron for running misc tests (Closes #1036) * make test Signed-off-by: Raphaël Barrois --- 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"