de-nova the test runner

This commit is contained in:
Jason Kölker 2011-11-01 12:56:44 -05:00
parent adf11f731c
commit 3db4d8dc3b
2 changed files with 29 additions and 27 deletions

View File

@ -57,19 +57,18 @@ To run a single test module:
import gettext
import heapq
import logging
import os
import unittest
import sys
import time
gettext.install('nova', unicode=1)
gettext.install('melange', unicode=1)
from nose import config
from nose import core
from nose import result
from nova import log as logging
class _AnsiColorizer(object):
"""
@ -193,7 +192,7 @@ def get_elapsed_time_color(elapsed_time):
return 'green'
class NovaTestResult(result.TextTestResult):
class MelangeTestResult(result.TextTestResult):
def __init__(self, *args, **kw):
self.show_elapsed = kw.pop('show_elapsed')
result.TextTestResult.__init__(self, *args, **kw)
@ -304,13 +303,13 @@ class NovaTestResult(result.TextTestResult):
self.stream.flush()
class NovaTestRunner(core.TextTestRunner):
class MelangeTestRunner(core.TextTestRunner):
def __init__(self, *args, **kwargs):
self.show_elapsed = kwargs.pop('show_elapsed')
core.TextTestRunner.__init__(self, *args, **kwargs)
def _makeResult(self):
return NovaTestResult(self.stream,
return MelangeTestResult(self.stream,
self.descriptions,
self.verbosity,
self.config,
@ -336,27 +335,32 @@ class NovaTestRunner(core.TextTestRunner):
if __name__ == '__main__':
logging.setup()
# If any argument looks like a test name but doesn't have "nova.tests" in
logger = logging.getLogger()
hdlr = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.DEBUG)
# If any argument looks like a test name but doesn't have "melange.tests" in
# front of it, automatically add that so we don't have to type as much
show_elapsed = True
argv = []
for x in sys.argv:
if x.startswith('test_'):
argv.append('nova.tests.%s' % x)
argv.append('melange.tests.%s' % x)
elif x.startswith('--hide-elapsed'):
show_elapsed = False
else:
argv.append(x)
testdir = os.path.abspath(os.path.join("nova", "tests"))
testdir = os.path.abspath(os.path.join("melange", "tests"))
c = config.Config(stream=sys.stdout,
env=os.environ,
verbosity=3,
workingDir=testdir,
plugins=core.DefaultPluginManager())
runner = NovaTestRunner(stream=c.stream,
runner = MelangeTestRunner(stream=c.stream,
verbosity=c.verbosity,
config=c,
show_elapsed=show_elapsed)

View File

@ -4,7 +4,7 @@ set -eu
function usage {
echo "Usage: $0 [OPTION]..."
echo "Run Nova's test suite(s)"
echo "Run Melange's test suite(s)"
echo ""
echo " -V, --virtual-env Always use virtualenv. Install automatically if not present"
echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment"
@ -40,7 +40,7 @@ function process_option {
esac
}
venv=.nova-venv
venv=.melange-venv
with_venv=tools/with_venv.sh
always_venv=0
never_venv=0
@ -59,7 +59,7 @@ done
# If enabled, tell nose to collect coverage data
if [ $coverage -eq 1 ]; then
noseopts="$noseopts --with-coverage --cover-package=nova"
noseopts="$noseopts --with-coverage --cover-package=melange"
fi
function run_tests {
@ -81,14 +81,12 @@ function run_tests {
function run_pep8 {
echo "Running pep8 ..."
# Opt-out files from pep8
ignore_scripts="*.sh:*nova-debug:*clean-vlans"
ignore_scripts="*.sh:*melange-debug:*clean-vlans"
ignore_files="*eventlet-patch:*pip-requires"
ignore_dirs="*ajaxterm*"
GLOBIGNORE="$ignore_scripts:$ignore_files:$ignore_dirs"
srcfiles=`find bin -type f ! -name "nova.conf*"`
srcfiles=`find bin -type f ! -name "melange.conf*"`
srcfiles+=" `find tools/*`"
srcfiles+=" nova setup.py plugins/xenserver/xenapi/etc/xapi.d/plugins/glance"
srcfiles+=" bin melange"
srcfiles+=" setup.py bin"
# Just run PEP8 in current environment
#
# NOTE(sirp): W602 (deprecated 3-arg raise) is being ignored for the