From 67718a0322948827ebc1516c56a6fa2061785d19 Mon Sep 17 00:00:00 2001 From: Brant Knudson Date: Mon, 6 Jan 2014 15:16:52 -0600 Subject: [PATCH] Debug env for tox Running a test with pdb was difficult because testr captures output and causes pdb prompt to quit. Tips for how to run testr with debug are provided here: https://wiki.openstack.org/wiki/Testr#Debugging_.28pdb.29_Tests This change puts these commands into a debug env in tox.ini so you can do a command like tox -e debug test_auth_token_middleware or, for more granularity: tox -e debug keystone.tests.test_sql_migrate_extensions.EndpointFilterExtension tox -e debug keystone.tests.test_sql_migrate_extensions.EndpointFilterExtension.test_downgrade and when it hits your breakpoint you'll get the debug prompt. This same change was made to keystone in commit c8302509 . Change-Id: I2b5dc81f4652dc89ecbcc7c785245a81cf77a1ca --- tools/debug_helper.sh | 18 ++++++++++++++++++ tox.ini | 5 +++++ 2 files changed, 23 insertions(+) create mode 100755 tools/debug_helper.sh diff --git a/tools/debug_helper.sh b/tools/debug_helper.sh new file mode 100755 index 00000000..b80b10cf --- /dev/null +++ b/tools/debug_helper.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +TMP_DIR=`mktemp -d` || exit 1 +trap "rm -rf $TMP_DIR" EXIT + +ALL_TESTS=$TMP_DIR/all_tests +TESTS_TO_RUN=$TMP_DIR/ksc_to_run + +python -m testtools.run discover -t ./ ./keystoneclient/tests --list > $ALL_TESTS + +if [ "$1" ] +then + grep "$1" < $ALL_TESTS > $TESTS_TO_RUN +else + mv $ALL_TESTS $TESTS_TO_RUN +fi + +python -m testtools.run discover --load-list $TESTS_TO_RUN diff --git a/tox.ini b/tox.ini index c7f37d8b..689c6d53 100644 --- a/tox.ini +++ b/tox.ini @@ -29,6 +29,11 @@ commands = python setup.py testr --coverage --testr-args='{posargs}' [tox:jenkins] downloadcache = ~/cache/pip +[testenv:debug] + +commands = + {toxinidir}/tools/debug_helper.sh {posargs} + [flake8] # F821: undefined name # H304: no relative imports