提交 a56e7f24 编写于 作者: C Cleber Rosa 提交者: Lukáš Doktor

avocado/core/job.py: move test suite validation to create_test_suite

This is the right place to criticize the test suite.  Even though I
don't feel it's right to abort the application from within the job
class, this prevents the current user experience to break.

In the near future, I'd like to see removed, and avocado runs without
a test suite to run and give these exact results: no tests were
available to be run, so none were executed.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 f91d5aa2
......@@ -429,6 +429,17 @@ class Job(object):
stacktrace.log_exc_info(sys.exc_info(), 'avocado.app.debug')
raise exceptions.OptionValidationError(details)
if not self.test_suite:
if self.references:
references = " ".join(self.references)
e_msg = ("No tests found for given test references, try "
"'avocado list -V %s' for details" % references)
else:
e_msg = ("No test references provided nor any other arguments "
"resolved into tests. Please double check the executed"
" command.")
raise exceptions.OptionValidationError(e_msg)
def pre_tests(self):
"""
Run the pre tests execution hooks
......@@ -441,17 +452,6 @@ class Job(object):
self._job_pre_post_dispatcher.map_method('pre', self)
def run_tests(self):
if not self.test_suite:
if self.references:
references = " ".join(self.references)
e_msg = ("No tests found for given test references, try "
"'avocado list -V %s' for details" % references)
else:
e_msg = ("No test references provided nor any other arguments "
"resolved into tests. Please double check the executed"
" command.")
raise exceptions.OptionValidationError(e_msg)
mux = getattr(self.args, "mux", None)
if mux is None:
mux = multiplexer.Mux()
......
......@@ -6,6 +6,7 @@ if sys.version_info[:2] == (2, 6):
else:
import unittest
from avocado.core import exceptions
from avocado.core import test
from avocado.core import job
from avocado.core import exit_codes
......@@ -42,8 +43,8 @@ class JobTest(unittest.TestCase):
def test_job_create_test_suite_empty(self):
args = argparse.Namespace()
myjob = job.Job(args)
myjob.create_test_suite()
self.assertEqual(myjob.test_suite, [])
self.assertRaises(exceptions.OptionValidationError,
myjob.create_test_suite)
def test_job_create_test_suite_simple(self):
simple_tests_found = self._find_simple_test_candidates()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册