horizon/tools/unit_tests.sh
adrian-turjak 280848c55f Ensure tox registers failures properly
Tox runs tests via unit_tests.sh which when not
running a test subset will mean tox only checks for
the final exit code. This means horizon test failues
will not be seen by tox unless openstack_dashboard
tests also fail.

This change forces an exit code which !=0 if either
test run fails.

Change-Id: I8fbcb834d9817e7eea1b2c39fc4caab6004b981b
2017-07-29 00:10:22 +12:00

37 lines
1.2 KiB
Bash
Executable File

# Uses envpython and toxinidir from tox run to construct a test command
testcommand="${1} ${2}/manage.py test"
posargs="${@:3}"
# Attempt to identify if any of the arguments passed from tox is a test subset
if [ -n "$posargs" ]; then
for arg in "$posargs"
do
if [ ${arg:0:1} != "-" ]; then
subset=$arg
fi
done
fi
# If we are running a test subset, supply the correct settings file.
# If not, simply run the entire test suite.
if [ -n "$subset" ]; then
project="${subset%%.*}"
if [ $project == "horizon" ]; then
$testcommand --settings=horizon.test.settings $posargs
elif [ $project == "openstack_dashboard" ]; then
$testcommand --settings=openstack_dashboard.test.settings \
--exclude-dir=openstack_dashboard/test/integration_tests $posargs
fi
else
$testcommand horizon --settings=horizon.test.settings $posargs
horizon_tests=$?
$testcommand openstack_dashboard --settings=openstack_dashboard.test.settings \
--exclude-dir=openstack_dashboard/test/integration_tests $posargs
openstack_dashboard_tests=$?
# we have to tell tox if either of these test runs failed
if [[ $horizon_tests != 0 || $openstack_dashboard_tests != 0 ]]; then
exit 1;
fi
fi