From dc4d670e10a244c153427f9d61cab2d814a13a43 Mon Sep 17 00:00:00 2001 From: guohliu Date: Tue, 13 Aug 2013 02:33:50 +0800 Subject: [PATCH] Add debug option to run_tests.sh Change-Id: Ie21cb8b7a370d5e62c7ac75d37affd62f761765a --- run_tests.sh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/run_tests.sh b/run_tests.sh index 63b306e9ec..ab92055e50 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -14,6 +14,7 @@ function usage { echo " -p, --pep8 Run pep8 tests" echo " --all Run pep8 and unit tests" echo " -c, --coverage Generate coverage report" + echo " -d, --debug Run tests with testtools instead of testr. This allows you to use the debugger." echo " -h, --help Print this usage message" exit } @@ -29,6 +30,7 @@ function process_option { -p|--pep8) test_pep8=1;; --all) test_unit=1; test_pep8=1;; -c|--coverage) coverage=1;; + -d|--debug) debug=1;; -h|--help) usage;; *) args="$args $1"; test_unit=1;; esac @@ -37,11 +39,28 @@ function process_option { venv=.venv with_venv=tools/with_venv.sh wrapper="" +debug=0 function run_tests { echo 'Running tests' # Remove any extraneous DB migrations find heat/db/sqlalchemy/migrate_repo/versions/ -name '*.pyc' -delete + + if [ $debug -eq 1 ]; then + echo "Debugging..." + if [ "$args" = "" ]; then + # Default to running all tests if specific test is not + # provided. + testrargs="discover ./heat/tests" + fi + ${wrapper} python -m testtools.run $args $testrargs + + # Short circuit because all of the testr and coverage stuff + # below does not make sense when running testtools.run for + # debugging purposes. + return $? + fi + # Just run the test suites in current environment if [ -n "$args" ] ; then args="-t $args" @@ -84,7 +103,7 @@ fi result=0 # If functional or unit tests have been selected, run them -if [ "$test_unit" == 1 ] ; then +if [ "$test_unit" == 1 ] || [ "$debug" == 1 ] ; then run_tests result=$? fi