summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2011-09-12 23:55:04 +0000
committerGerrit Code Review <review@openstack.org>2011-09-12 23:55:04 +0000
commitfd34e804ad1f856f5be7d675fb54b8a1ac160fce (patch)
treea68a6296bf21228d180e192d5b0de2acfa4568bc
parenta07986659434c05d39491cb99dca3934f7ffe0b5 (diff)
parent242048ad698cde3bd7471ac5c432b1c56f6b9bba (diff)
Merge "Add toggle to run tests in-process, w/ realtime progress feedback"
-rw-r--r--keystone/test/__init__.py20
-rwxr-xr-xrun_tests.sh4
2 files changed, 18 insertions, 6 deletions
diff --git a/keystone/test/__init__.py b/keystone/test/__init__.py
index 2aef27c4..9b8c924f 100644
--- a/keystone/test/__init__.py
+++ b/keystone/test/__init__.py
@@ -91,11 +91,19 @@ class KeystoneTest(object):
# discover and run tests
print "Running tests..."
- loader = unittest.TestLoader()
- suite = loader.discover(TEST_DIR, top_level_dir=BASE_DIR)
- result = unittest.TextTestRunner(verbosity=1).run(suite)
- if not result.wasSuccessful():
- raise RuntimeError("%s unresolved issues." %
- (len(result.errors) + len(result.failures),))
+ if '--with-progress' in sys.argv:
+ loader = unittest.TestLoader()
+ suite = loader.discover(TEST_DIR, top_level_dir=BASE_DIR)
+ result = unittest.TextTestRunner(verbosity=1).run(suite)
+ if not result.wasSuccessful():
+ raise RuntimeError("%s unresolved issues." %
+ (len(result.errors) + len(result.failures),))
+ elif '--with-coverage' in sys.argv:
+ print "running coverage"
+ execute('coverage run %s discover -t %s -s %s' %
+ ('/usr/bin/unit2', BASE_DIR, TEST_DIR))
+ else:
+ execute('unit2 discover -f -t %s -s %s' %
+ (BASE_DIR, TEST_DIR))
finally:
self.tearDown()
diff --git a/run_tests.sh b/run_tests.sh
index 60b321ae..aee3f055 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -8,6 +8,10 @@ function usage {
echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment"
echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added."
echo " --unittests-only Run unit tests only, exclude functional tests."
+ echo " --with-coverage Runs tests with python code coverage (useful for jenkins)"
+ echo " Note: cannot be used in combination --with-progress"
+ echo " --with-progress Runs tests with progress (useful for developers)"
+ echo " Note: cannot be used in combination --with-coverage"
echo " -p, --pep8 Just run pep8"
echo " -l, --pylint Just run pylint"
echo " -h, --help Print this usage message"