From a8b4ff6b33fc8b00160e5af004eba5d520906a6e Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Mon, 15 Jul 2013 19:01:49 +0200 Subject: [PATCH] Ensure correct return code of run-tests.sh If 'kill -9 mongodb_pid' failed, run-tests.sh exit with a return code of 0. This change ensure that the return code is the one of the failed command. Change-Id: Iad58dac3fa66d1ea688af706940511033c1d76f7 --- run-tests.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/run-tests.sh b/run-tests.sh index 657cdbb73..413feee19 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -1,6 +1,15 @@ #!/bin/bash set -e +function clean_exit(){ + local error_code="$?" + rm -rf ${MONGO_DATA} + if [ "$MONGO_PID" ]; then + kill -9 ${MONGO_PID} || true + fi + return $error_code +} + if [ "$1" = "--coverage" ]; then COVERAGE_ARG="$1" shift @@ -14,9 +23,8 @@ fi # Main unit tests MONGO_DATA=`mktemp -d` -trap "rm -rf ${MONGO_DATA}" EXIT +trap "clean_exit" EXIT mongod --maxConns 32 --smallfiles --quiet --noauth --port 29000 --dbpath "${MONGO_DATA}" --bind_ip localhost & MONGO_PID=$! -trap "kill -9 ${MONGO_PID} || true" EXIT export CEILOMETER_TEST_MONGODB_URL="mongodb://localhost:29000/ceilometer" python setup.py testr --slowest --testr-args="--concurrency=1 $*" $COVERAGE_ARG