summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-10-11 17:43:39 +0000
committerGerrit Code Review <review@openstack.org>2014-10-11 17:43:39 +0000
commit21efadb96f68ccb58a7bff4110152d3a364d3ccc (patch)
tree1132b5abbd47a4f73151c67b712cf9c0b7602582
parent118885e4b05408eaa4c40d1edf71c04df766da2c (diff)
parente5c14b74d3676168008c68fd9f4848d551634873 (diff)
downloadoslotest-21efadb96f68ccb58a7bff4110152d3a364d3ccc.tar.gz
Merge "Add an extra parameter for test directory in debugger script"
-rw-r--r--doc/source/features.rst17
-rwxr-xr-xtools/oslo_debug_helper28
2 files changed, 40 insertions, 5 deletions
diff --git a/doc/source/features.rst b/doc/source/features.rst
index c176d01..61f15a8 100644
--- a/doc/source/features.rst
+++ b/doc/source/features.rst
@@ -25,7 +25,22 @@ Update tox.ini
Within the ``tox.ini`` file of your project add the following::
[testenv:debug]
- commands = oslo_debug_helper.sh {posargs}
+ commands = oslo_debug_helper {posargs}
+
+If the project name, and the module that precedes the tests directory do not
+match, then consider passing an argument to ``tox.ini``.
+
+For example, ``python-keystoneclient`` project has tests in
+``keystoneclient/tests``, thus it would have to pass in::
+
+ [testenv:debug]
+ commands = oslo_debug_helper -t keystoneclient/tests {posargs}
+
+Similarily, most ``oslo`` projects have the tests at the package level, it
+would have to pass in::
+
+ [testenv:debug]
+ commands = oslo_debug_helper -t tests {posargs}
To run with tox:
diff --git a/tools/oslo_debug_helper b/tools/oslo_debug_helper
index e293818..838e389 100755
--- a/tools/oslo_debug_helper
+++ b/tools/oslo_debug_helper
@@ -1,20 +1,40 @@
#!/bin/bash
+# oslo_debug_helper - Script that allows for debugging tests
+#
+# oslo_debug_helper [-t <test_directory>] [<tests_to_run>]
+#
+# <tests_to_run> - may be a test suite, class, or function, if no value is
+# passed, then all tests are run.
+# -t <test_directory> - the name of the directory that houses the tests
+# relative to the project directory. If no value is passed, it is assumed
+# to be packagename/tests.
+
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
+# Default to packagename/tests, i.e., keystone/tests
PACKAGENAME=$(python setup.py --name)
+TEST_DIR=./$PACKAGENAME/tests
+
+# If a specific path is passed, use that one
+while getopts ":t:" opt; do
+ case $opt in
+ t) TEST_DIR=$OPTARG;;
+ esac
+done
-python -m testtools.run discover -t ./ ./$PACKAGENAME/tests --list > $ALL_TESTS
+python -m testtools.run discover -t ./ $TEST_DIR --list > $ALL_TESTS
-if [ "$1" ]; then
- grep "$1" < $ALL_TESTS > $TESTS_TO_RUN
+# getopts friendly way of determining if a positional arg has been passed
+ARG1=${@:$OPTIND:1}
+if [ "$ARG1" ]; then
+ grep "$ARG1" < $ALL_TESTS > $TESTS_TO_RUN
else
mv $ALL_TESTS $TESTS_TO_RUN
fi
python -m testtools.run discover --load-list $TESTS_TO_RUN
-