Skip to content

Commit

Permalink
Merge branch 'feature/shell' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
fivethreeo committed Feb 9, 2011
2 parents 075b196 + cd7877e commit 2afd7fb
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 67 deletions.
65 changes: 35 additions & 30 deletions cms/test/run_tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
import sys
import os

def configure_settings(env_name):
def configure_settings(is_test, test_args):

failfast = False
direct = False
test_args = list(test_args)
if '--direct' in test_args:
test_args.remove('--direct')
sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", ".."))

if '--manage' in test_args:
test_args.remove('--manage')

test_labels = []

test_args_enum = dict([ (val, idx) for idx, val in enumerate(test_args)])

env_name = ''
if '--toxenv' in test_args:
env_name = test_args[test_args_enum['--toxenv']+1]
test_args.remove('--toxenv')
test_args.remove(env_name)

if '--failfast' in test_args:
test_args.remove('--failfast')
failfast = True

if is_test:
for label in test_args:
test_labels.append('cms.%s' % label)

if not test_labels:
test_labels.append('cms')

from cms.test import project
import cms

Expand Down Expand Up @@ -214,38 +246,11 @@ def configure_settings(env_name):

from cms.conf import patch_settings
patch_settings()
return settings
return test_args, test_labels, failfast, settings

def run_tests(*test_args):

test_args = list(test_args)
if '--direct' in test_args:
test_args.remove('--direct')
sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", ".."))

failfast = False

test_labels = []

test_args_enum = dict([ (val, idx) for idx, val in enumerate(test_args)])

env_name = ''
if '--env-name' in test_args:
env_name = test_args[test_args_enum['--env-name']+1]
test_args.remove('--env-name')
test_args.remove(env_name)

if '--failfast' in test_args:
test_args.remove('--failfast')
failfast = True

for label in test_args:
test_labels.append('cms.%s' % label)

if not test_labels:
test_labels.append('cms')

settings = configure_settings(env_name)
test_args, test_labels, failfast, settings = configure_settings(True, test_args)

from django.test.utils import get_runner

Expand Down
72 changes: 39 additions & 33 deletions runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ num_args=${#args[@]}
index=0

quicktest=false
disable_coverage=true
manage=false

while [ "$index" -lt "$num_args" ]
do
Expand Down Expand Up @@ -40,18 +40,13 @@ case "${args[$index]}" in
echo ""
echo " --quicktest - use already built tox env, for running a simple test quickly"
echo " --failfast - abort at first failing test"
echo " --with-coverage - enables coverage"
echo " --manage - run management shell"
exit 1
;;

"--rebuild-env")
# just to make ci run instantly
;;

"--with-coverage")
# just to make ci run instantly
;;


"--manage")
manage=true
;;
*)
suite="${args[$index]}"
esac
Expand All @@ -64,44 +59,55 @@ if [ ! "$toxenv" ]; then
toxenv='py26-1.2.X'
fi

if [ "$failfast" ]; then
echo "--failfast supplied, not using xmlrunner."
fi

if [ ! "$suite" ]; then
echo "Running complete cms testsuite."
else
if [ $quicktest == false ]; then
echo "Can only run specific suite with --quicktest"
OLD_IFS=IFS
IFS=","
tox_envs=( $toxenv )
tox_len=${#tox_envs[@]}
IFS=OLD_IFS

if [[ $quicktest == true || $manage == true ]]; then
if [[ $manage == true ]]; then
if [[ "$tox_len" -gt "1" || "$toxenv" == "ALL" ]]; then
echo "Cannot use multiple envs with --manage"
exit 1
fi
if [ ! -d ".tox/$toxenv" ]; then
echo ".tox/$toxenv does not exist, run without --manage first"
exit 1
fi
.tox/$toxenv/bin/python cms/test/run_shell.py --direct "$@"
exit 1
fi
echo "Running cms test $suite."
fi

if [ ! -f "toxinstall/bin/tox" ]; then
echo "Installing tox"
virtualenv toxinstall
toxinstall/bin/pip install -U tox
fi

if [ $quicktest == true ]; then
if [ "$toxenv" == "ALL" ]; then
echo "Cannot use ALL with --quicktest"
exit 1
fi
IFS=","
tenvs=( $toxenv )
for tenv in ${tenvs[@]}; do
for tenv in ${tox_envs[@]}; do
if [ ! -d ".tox/$tenv" ]; then
echo ".tox/$tenv does not exist, run without --quicktest first"
exit 1
fi
read -p "Hit any key to run tests in tox env $tenv"
echo "Running cms test $suite using $tenv"
# running tests without invoking tox to save time
.tox/$tenv/bin/python cms/test/run_tests.py --direct $failfast $suite
if [ "$failfast" ]; then
echo "--failfast supplied, not using xmlrunner."
fi
.tox/$tenv/bin/python cms/test/run_tests.py --toxenv $tenv --direct $failfast $suite
retcode=$?
done
else
if [ "$suite" ]; then
echo "Can only run specific suite with --quicktest"
fi

if [ ! -f "toxinstall/bin/tox" ]; then
echo "Installing tox"
virtualenv toxinstall
toxinstall/bin/pip install -U tox
fi
echo "Running complete cms testsuite."
toxinstall/bin/tox -e $toxenv
retcode=$?
fi
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ envlist =

[testenv]
commands =
coverage run --rcfile=.coveragerc cms/test/run_tests.py --direct --env-name {envname} # get rid of --direct somehow
coverage run --rcfile=.coveragerc cms/test/run_tests.py --direct --toxenv {envname} # get rid of --direct somehow
coverage xml -o coverage-{envname}.xml
sitepackages = False

Expand Down Expand Up @@ -84,7 +84,7 @@ deps =
[testenv:py25-trunk]
commands =
pip install -e svn+http://code.djangoproject.com/svn/django/trunk#egg=Django
coverage run --rcfile=.coveragerc cms/test/run_tests.py --direct --env-name {envname} # get rid of --direct somehow
coverage run --rcfile=.coveragerc cms/test/run_tests.py --direct --toxenv {envname} # get rid of --direct somehow
coverage xml -o coverage-{envname}.xml
basepython = python2.5
deps =
Expand All @@ -99,7 +99,7 @@ deps =
[testenv:py26-trunk]
commands =
pip install -e svn+http://code.djangoproject.com/svn/django/trunk#egg=Django
coverage run --rcfile=.coveragerc cms/test/run_tests.py --direct --env-name {envname} # get rid of --direct somehow
coverage run --rcfile=.coveragerc cms/test/run_tests.py --direct --toxenv {envname} # get rid of --direct somehow
coverage xml -o coverage-{envname}.xml
basepython = python2.6
deps =
Expand All @@ -114,7 +114,7 @@ deps =
[testenv:py27-trunk]
commands =
pip install -e svn+http://code.djangoproject.com/svn/django/trunk#egg=Django
coverage run --rcfile=.coveragerc cms/test/run_tests.py --direct --env-name {envname} # get rid of --direct somehow
coverage run --rcfile=.coveragerc cms/test/run_tests.py --direct --toxenv {envname} # get rid of --direct somehow
coverage xml -o coverage-{envname}.xml
basepython = python2.7
deps =
Expand Down

0 comments on commit 2afd7fb

Please sign in to comment.