From ba1fe1c9ecad9ca03c9e3e41b1f16912cdb625d8 Mon Sep 17 00:00:00 2001 From: Felipe Monteiro Date: Mon, 15 Jan 2018 15:31:58 -0500 Subject: [PATCH] Fix pifpaf not returning error code upon test failure For whatever reason, the following command: pifpaf run postgresql -- is not returning a non-zero error code on test failure. (An example print out is included below.) This PS updates pretty_tox.sh to forcibly raise a non-zero error code in the event of test failure. It also renames the script to run_pifpaf.sh to be more intuitive. Example: ====== Totals ====== Ran: 7 tests in 5.7673 sec. - Passed: 6 - Skipped: 0 - Expected Fail: 0 - Unexpected Success: 0 - Failed: 1 Sum of execute time for each test: 2.6962 sec. ============== Worker Balance ============== - Worker 0 (7 tests) => 0:00:02.698323 + exit 0 py35: commands succeeded congratulations :) Change-Id: I7b1fa9d42295d06752997f251a0ec14082b44d03 --- tools/pretty_tox.sh | 16 ---------------- tools/run_pifpaf.sh | 23 +++++++++++++++++++++++ tox.ini | 4 ++-- 3 files changed, 25 insertions(+), 18 deletions(-) delete mode 100755 tools/pretty_tox.sh create mode 100755 tools/run_pifpaf.sh diff --git a/tools/pretty_tox.sh b/tools/pretty_tox.sh deleted file mode 100755 index 799ac184..00000000 --- a/tools/pretty_tox.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail - -TESTRARGS=$1 - -# --until-failure is not compatible with --subunit see: -# -# https://bugs.launchpad.net/testrepository/+bug/1411804 -# -# this work around exists until that is addressed -if [[ "$TESTARGS" =~ "until-failure" ]]; then - python setup.py testr --slowest --testr-args="$TESTRARGS" -else - python setup.py testr --slowest --testr-args="--subunit $TESTRARGS" | subunit-trace -f -fi diff --git a/tools/run_pifpaf.sh b/tools/run_pifpaf.sh new file mode 100755 index 00000000..f7510c32 --- /dev/null +++ b/tools/run_pifpaf.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# This script is used for guaranteeing that `pifpaf` returns non-zero codes +# upon test failure. + +function cleanup { + pifpaf_stop +} + +trap cleanup EXIT + +# Instantiate an ephemeral PostgreSQL DB and print out the `pifpaf` environment +# variables for debugging purposes. +set -ex +eval `pifpaf run postgresql` +env | grep PIFPAF +set +ex + +set -eo pipefail + +TESTRARGS=$1 + +python setup.py testr --slowest --testr-args="--subunit --concurrency=1 $TESTRARGS" | subunit-trace -f diff --git a/tox.ini b/tox.ini index 4e1342e3..edd3f834 100644 --- a/tox.ini +++ b/tox.ini @@ -21,12 +21,12 @@ commands = [testenv:py27] commands = {[testenv]commands} - pifpaf run postgresql -- '{toxinidir}'/tools/pretty_tox.sh '--concurrency=1 {posargs}' + {toxinidir}/tools/run_pifpaf.sh '{posargs}' [testenv:py35] commands = {[testenv]commands} - pifpaf run postgresql -- '{toxinidir}'/tools/pretty_tox.sh '--concurrency=1 {posargs}' + {toxinidir}/tools/run_pifpaf.sh '{posargs}' [testenv:functional] usedevelop = True