未验证 提交 39c994d1 编写于 作者: A Amador Pahim

Merge branch 'ldoktor-test-variables3'

Signed-off-by: NAmador Pahim <apahim@redhat.com>
......@@ -302,7 +302,7 @@ class TestRunner(object):
instance = loader.load_test(test_factory)
if instance.runner_queue is None:
instance.runner_queue = queue
instance.set_runner_queue(queue)
runtime.CURRENT_TEST = instance
early_state = instance.get_state()
early_state['early_status'] = True
......
......@@ -225,15 +225,14 @@ class Test(unittest.TestCase):
params = []
elif isinstance(params, tuple):
params, mux_path = params[0], params[1]
self.params = varianter.AvocadoParams(params, self.name,
mux_path,
self.default_params)
self.__params = varianter.AvocadoParams(params, self.name,
mux_path,
self.default_params)
default_timeout = getattr(self, "timeout", None)
self.timeout = self.params.get("timeout", default=default_timeout)
self.log.info('START %s', self.name)
self.text_output = None
self.__status = None
self.__fail_reason = None
self.__fail_class = None
......@@ -243,7 +242,7 @@ class Test(unittest.TestCase):
self.paused = False
self.paused_msg = ''
self.runner_queue = runner_queue
self.__runner_queue = runner_queue
unittest.TestCase.__init__(self, methodName=methodName)
......@@ -289,6 +288,13 @@ class Test(unittest.TestCase):
"""
return self.__outputdir
@property
def params(self):
"""
Parameters of this test (AvocadoParam instance)
"""
return self.__params
@property
def basedir(self):
"""
......@@ -365,6 +371,22 @@ class Test(unittest.TestCase):
cache_dirs.append(datadir_cache)
return cache_dirs
@property
def runner_queue(self):
"""
The communication channel between test and test runner
"""
return self.__runner_queue
def set_runner_queue(self, runner_queue):
"""
Override the runner_queue
"""
self.assertTrue(self.__runner_queue is None, "Overriding of runner_"
"queue multiple times is not allowed -> old=%s new=%s"
% (self.__runner_queue, runner_queue))
self.__runner_queue = runner_queue
@property
def status(self):
"""
......@@ -428,9 +450,9 @@ class Test(unittest.TestCase):
"""
if self.running and self.time_start:
self._update_time_elapsed()
preserve_attr = ['basedir', 'debugdir', 'depsdir', 'fail_reason',
'logdir', 'logfile', 'name', 'resultsdir', 'srcdir',
'status', 'text_output', 'time_elapsed',
preserve_attr = ['basedir', 'fail_reason',
'logdir', 'logfile', 'name', 'srcdir',
'status', 'time_elapsed',
'traceback', 'workdir', 'whiteboard', 'time_start',
'time_end', 'running', 'paused', 'paused_msg',
'fail_class', 'params', "timeout"]
......@@ -691,8 +713,6 @@ class Test(unittest.TestCase):
self._tag_end()
self._report()
self.log.info("")
with open(self.logfile, 'r') as log_file_obj:
self.text_output = log_file_obj.read()
self._stop_logging()
def _report(self):
......
......@@ -61,7 +61,12 @@ class XUnitResult(Result):
traceback = document.createCDATASection(traceback_content)
element.appendChild(traceback)
system_out = Element('system-out')
system_out_cdata_content = self._escape_cdata(test.get('text_output', self.UNKNOWN))
try:
with open(test.get("logfile"), "r") as logfile_obj:
text_output = logfile_obj.read()
except (TypeError, IOError):
text_output = self.UNKNOWN
system_out_cdata_content = self._escape_cdata(text_output)
system_out_cdata = document.createCDATASection(system_out_cdata_content)
system_out.appendChild(system_out_cdata)
element.appendChild(system_out)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册