Handles canceled payment transactions.
[platal.git] / bin / cron / run_tests.sh
CommitLineData
174cd7e2
RB
1#!/bin/bash
2
3CRONDIR=$(dirname $0)
4PWD=$(pwd)
5PLATAL_ROOT=${CRONDIR}/../..
6
7# Executes a command and displays its output only if retcode != 0
8# @param dir Folder from which the command should be called
9# @param cmd The command to execute
10# After execution, the pwd is returned to its initial value.
11function print_if_err {
12 local dir cmd retcode tmpfile
13 dir=$1
14 cmd=$2
15
16 echo "* Running ${cmd}..."
17 # Capture output and return code
18 tmpfile=$(mktemp pl_run_tests.XXXXXX)
19 cd ${dir} && ${cmd} 2>&1 > ${tmpfile}
20 retcode=$?
21
22 if [ "x${retcode}" != "x0" ]; then
23 echo "** Error running command ${cmd} (code ${retcode})"
24 cat ${tmpfile}
25 rm -f ${tmpfile}
26 exit ${retcode}
27 fi
28
29 # Cleanup
30 rm -f ${tmpfile}
31 cd ${PWD}
32}
33
34print_if_err ${PLATAL_ROOT} "make test"