summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Martinelli <stevemar@ca.ibm.com>2014-08-25 12:18:28 -0400
committerSteve Martinelli <stevemar@ca.ibm.com>2014-08-25 12:36:02 -0400
commitb371ea2373e74bbdd490ffdde39f124088f07f71 (patch)
tree76460e519b22113a9c553e53c383facdf4fb6781
parent97464ff560841393251549cb3ee1c910ebc4a07d (diff)
downloadoslotest-b371ea2373e74bbdd490ffdde39f124088f07f71.tar.gz
Add pdb support to tox with debug helper shell script
The Keystone team has been using a home brewed `debug_helper.sh` file to run tests with pdb support, it's now being also used by pycadf too. As noted by bnemec [1] we should move this to oslo. [1] https://bugs.launchpad.net/pycadf/+bug/1354192 To run any test in particular, run tox with -e debug: `tox -e debug` It also supports passing in a specific test module, class or case. The shell file runs testtools underneath the covers to get pdb support. Change-Id: Idb715bc137459a2f6d16ac3f65c718a567df49ff Co-Authored-By: Brant Knudson <bknudson@us.ibm.com>
-rw-r--r--setup.cfg2
-rwxr-xr-xtools/oslo_debug_helper.sh30
2 files changed, 32 insertions, 0 deletions
diff --git a/setup.cfg b/setup.cfg
index db254a7..bf3ce7d 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -22,6 +22,8 @@ classifier =
[files]
packages =
oslotest
+scripts =
+ tools/oslo_debug_helper.sh
[global]
setup-hooks =
diff --git a/tools/oslo_debug_helper.sh b/tools/oslo_debug_helper.sh
new file mode 100755
index 0000000..f681742
--- /dev/null
+++ b/tools/oslo_debug_helper.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+# To utilize this file, add the following to tox.ini:
+#[testenv:debug]
+#commands = oslo_debug_helper.sh {posargs}
+
+# To run with tox:
+#tox -e debug
+#tox -e debug test_notifications
+#tox -e debug test_notifications.NotificationsTestCase
+#tox -e debug test_notifications.NotificationsTestCase.test_send_notification
+
+TMP_DIR=`mktemp -d` || exit 1
+trap "rm -rf $TMP_DIR" EXIT
+
+ALL_TESTS=$TMP_DIR/all_tests
+TESTS_TO_RUN=$TMP_DIR/tests_to_run
+
+PACKAGENAME=$(python setup.py --name)
+
+python -m testtools.run discover -t ./ ./$PACKAGENAME/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
+