From 23433b080835323db26a2b245cffa3a13ac40d3c Mon Sep 17 00:00:00 2001 From: Felipe Monteiro Date: Mon, 22 Jan 2018 23:07:57 +0000 Subject: [PATCH] bug(tox): Support regular expressions via tox -e py35 This PS simply allows tox -e py35 to take in regular expressions for better testing experience. For example: tox -e py35 # runs all unit tests tox -e py35 -- test_armada_controller # only run unit tests that match Change-Id: Iab5a70fa0d51e1572a31943d8f38bc9b0d6a7c18 --- tools/run-unit-tests.sh | 15 +++++++++++++++ tox.ini | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 tools/run-unit-tests.sh diff --git a/tools/run-unit-tests.sh b/tools/run-unit-tests.sh new file mode 100755 index 00000000..feab07f9 --- /dev/null +++ b/tools/run-unit-tests.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# Script for passing regex filtering of unit tests to py.test conditionally. +# Needed because tox currently doesn't support conditional logic like this. + +posargs=$@ +if [ ${#posargs} -ge 1 ]; then + py.test -vvv -s --ignore=hapi -k $1 +else + py.test -vvv -s --ignore=hapi +fi +TEST_STATUS=$? +set -e + +exit $TEST_STATUS diff --git a/tox.ini b/tox.ini index de4efeb3..e1977697 100644 --- a/tox.ini +++ b/tox.ini @@ -17,7 +17,7 @@ whitelist_externals = find commands = find . -type f -name "*.pyc" -delete python -V - py.test -vvv -s --ignore=hapi {posargs} + {toxinidir}/tools/run-unit-tests.sh {posargs} [testenv:docs] commands =