Commit 4221bf9e by David Baumgold Committed by Christine Lytwynec

Set verbosity on paver test tasks

parent da6d70a9
...@@ -6,6 +6,7 @@ import sys ...@@ -6,6 +6,7 @@ import sys
from paver.easy import sh, task, cmdopts, needs from paver.easy import sh, task, cmdopts, needs
from pavelib.utils.test import suites from pavelib.utils.test import suites
from pavelib.utils.envs import Env from pavelib.utils.envs import Env
from optparse import make_option
try: try:
from pygments.console import colorize from pygments.console import colorize
...@@ -25,7 +26,10 @@ __test__ = False # do not collect ...@@ -25,7 +26,10 @@ __test__ = False # do not collect
("test_id=", "t", "Test id"), ("test_id=", "t", "Test id"),
("failed", "f", "Run only failed tests"), ("failed", "f", "Run only failed tests"),
("fail_fast", "x", "Run only failed tests"), ("fail_fast", "x", "Run only failed tests"),
("fasttest", "a", "Run without collectstatic") ("fasttest", "a", "Run without collectstatic"),
make_option("--verbose", action="store_const", const=2, dest="verbosity"),
make_option("-q", "--quiet", action="store_const", const=0, dest="verbosity"),
make_option("-v", "--verbosity", action="count", dest="verbosity", default=1),
]) ])
def test_system(options): def test_system(options):
""" """
...@@ -38,6 +42,7 @@ def test_system(options): ...@@ -38,6 +42,7 @@ def test_system(options):
'failed_only': getattr(options, 'failed', None), 'failed_only': getattr(options, 'failed', None),
'fail_fast': getattr(options, 'fail_fast', None), 'fail_fast': getattr(options, 'fail_fast', None),
'fasttest': getattr(options, 'fasttest', None), 'fasttest': getattr(options, 'fasttest', None),
'verbosity': getattr(options, 'verbosity', 1),
} }
if test_id: if test_id:
...@@ -66,6 +71,9 @@ def test_system(options): ...@@ -66,6 +71,9 @@ def test_system(options):
("test_id=", "t", "Test id"), ("test_id=", "t", "Test id"),
("failed", "f", "Run only failed tests"), ("failed", "f", "Run only failed tests"),
("fail_fast", "x", "Run only failed tests"), ("fail_fast", "x", "Run only failed tests"),
make_option("--verbose", action="store_const", const=2, dest="verbosity"),
make_option("-q", "--quiet", action="store_const", const=0, dest="verbosity"),
make_option("-v", "--verbosity", action="count", dest="verbosity", default=1),
]) ])
def test_lib(options): def test_lib(options):
""" """
...@@ -77,6 +85,7 @@ def test_lib(options): ...@@ -77,6 +85,7 @@ def test_lib(options):
opts = { opts = {
'failed_only': getattr(options, 'failed', None), 'failed_only': getattr(options, 'failed', None),
'fail_fast': getattr(options, 'fail_fast', None), 'fail_fast': getattr(options, 'fail_fast', None),
'verbosity': getattr(options, 'verbosity', 1),
} }
if test_id: if test_id:
...@@ -98,6 +107,9 @@ def test_lib(options): ...@@ -98,6 +107,9 @@ def test_lib(options):
@cmdopts([ @cmdopts([
("failed", "f", "Run only failed tests"), ("failed", "f", "Run only failed tests"),
("fail_fast", "x", "Run only failed tests"), ("fail_fast", "x", "Run only failed tests"),
make_option("--verbose", action="store_const", const=2, dest="verbosity"),
make_option("-q", "--quiet", action="store_const", const=0, dest="verbosity"),
make_option("-v", "--verbosity", action="count", dest="verbosity", default=1),
]) ])
def test_python(options): def test_python(options):
""" """
...@@ -106,6 +118,7 @@ def test_python(options): ...@@ -106,6 +118,7 @@ def test_python(options):
opts = { opts = {
'failed_only': getattr(options, 'failed', None), 'failed_only': getattr(options, 'failed', None),
'fail_fast': getattr(options, 'fail_fast', None), 'fail_fast': getattr(options, 'fail_fast', None),
'verbosity': getattr(options, 'verbosity', 1),
} }
python_suite = suites.PythonTestSuite('Python Tests', **opts) python_suite = suites.PythonTestSuite('Python Tests', **opts)
...@@ -130,13 +143,21 @@ def test_i18n(): ...@@ -130,13 +143,21 @@ def test_i18n():
'pavelib.prereqs.install_prereqs', 'pavelib.prereqs.install_prereqs',
'pavelib.utils.test.utils.clean_reports_dir', 'pavelib.utils.test.utils.clean_reports_dir',
) )
def test(): @cmdopts([
make_option("--verbose", action="store_const", const=2, dest="verbosity"),
make_option("-q", "--quiet", action="store_const", const=0, dest="verbosity"),
make_option("-v", "--verbosity", action="count", dest="verbosity", default=1),
])
def test(options):
""" """
Run all tests Run all tests
""" """
opts = {
'verbosity': getattr(options, 'verbosity', 1)
}
# Subsuites to be added to the main suite # Subsuites to be added to the main suite
python_suite = suites.PythonTestSuite('Python Tests') python_suite = suites.PythonTestSuite('Python Tests', **opts)
i18n_suite = suites.I18nTestSuite('i18n') i18n_suite = suites.I18nTestSuite('i18n', **opts)
js_suite = suites.JsTestSuite('JS Tests', mode='run', with_coverage=True) js_suite = suites.JsTestSuite('JS Tests', mode='run', with_coverage=True)
# Main suite to be run # Main suite to be run
......
...@@ -30,10 +30,12 @@ class I18nTestSuite(TestSuite): ...@@ -30,10 +30,12 @@ class I18nTestSuite(TestSuite):
cmd = ( cmd = (
"{pythonpath_prefix} nosetests {repo_root}/i18n/tests " "{pythonpath_prefix} nosetests {repo_root}/i18n/tests "
"--with-xunit --xunit-file={xunit_report}".format( "--with-xunit --xunit-file={xunit_report} "
"--verbosity={verbosity}.format(
pythonpath_prefix=pythonpath_prefix, pythonpath_prefix=pythonpath_prefix,
repo_root=Env.REPO_ROOT, repo_root=Env.REPO_ROOT,
xunit_report=self.xunit_report, xunit_report=self.xunit_report,
verbosity=self.verbosity,
) )
) )
......
...@@ -110,9 +110,10 @@ class SystemTestSuite(NoseTestSuite): ...@@ -110,9 +110,10 @@ class SystemTestSuite(NoseTestSuite):
@property @property
def cmd(self): def cmd(self):
cmd = ( cmd = (
'./manage.py {system} test {test_id} {test_opts} ' './manage.py {system} test --verbosity={verbosity} '
'--traceback --settings=test'.format( '{test_id} {test_opts} --traceback --settings=test'.format(
system=self.root, system=self.root,
verbosity=self.verbosity,
test_id=self.test_id, test_id=self.test_id,
test_opts=self.test_options_flags, test_opts=self.test_options_flags,
) )
...@@ -158,11 +159,13 @@ class LibTestSuite(NoseTestSuite): ...@@ -158,11 +159,13 @@ class LibTestSuite(NoseTestSuite):
def cmd(self): def cmd(self):
cmd = ( cmd = (
"nosetests --id-file={test_ids} {test_id} {test_opts} " "nosetests --id-file={test_ids} {test_id} {test_opts} "
"--with-xunit --xunit-file={xunit_report}".format( "--with-xunit --xunit-file={xunit_report} "
"--verbosity={verbosity}".format(
test_ids=self.test_ids, test_ids=self.test_ids,
test_id=self.test_id, test_id=self.test_id,
test_opts=self.test_options_flags, test_opts=self.test_options_flags,
xunit_report=self.xunit_report, xunit_report=self.xunit_report,
verbosity=self.verbosity,
) )
) )
......
...@@ -21,6 +21,16 @@ class TestSuite(object): ...@@ -21,6 +21,16 @@ class TestSuite(object):
self.root = args[0] self.root = args[0]
self.subsuites = kwargs.get('subsuites', []) self.subsuites = kwargs.get('subsuites', [])
self.failed_suites = [] self.failed_suites = []
self.verbosity = kwargs.get('verbosity', 1)
@property
def verbose(self):
"""
Boolean version of `self.verbosity`. If `self.verbosity` is greater than
1, `self.verbose` is True. Note that the default value for
`self.verbosity` is 1, so the default value for `self.verbose` is False.
"""
return self.verbosity > 1
def __enter__(self): def __enter__(self):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment