提交 1d4bd66d 编写于 作者: L Lucas Meneghel Rodrigues 提交者: Lucas Meneghel Rodrigues

Merge pull request #74 from ruda/job_owns_start_file_logging

Job  class owns execution of start_file_logging()
......@@ -166,8 +166,6 @@ class Job(object):
else:
test_result_class = result.HumanTestResult
if self.args is not None:
self.args.test_result_debuglog = self.debuglog
self.args.test_result_loglevel = self.loglevel
self.args.test_result_total = len(urls)
test_result = test_result_class(self.output_manager, self.args)
return test_result
......@@ -223,7 +221,12 @@ class Job(object):
test_result = self._make_test_result(params_list)
self.test_runner = self._make_test_runner(test_result)
self.output_manager.start_file_logging(self.debuglog,
self.loglevel)
self.output_manager.debuglog = self.debuglog
failures = self.test_runner.run(params_list)
self.output_manager.stop_file_logging()
# If it's all good so far, set job status to 'PASS'
if self.status == 'RUNNING':
self.status = 'PASS'
......@@ -234,6 +237,7 @@ class Job(object):
if self.args.archive:
name = os.path.basename(self.debugdir)
archive.create_zip(name, self.debugdir)
tests_status = not bool(failures)
if tests_status:
return error_codes.numeric_status['AVOCADO_ALL_OK']
......
......@@ -33,9 +33,7 @@ class JSONTestResult(TestResult):
Called once before any tests are executed.
"""
TestResult.start_tests(self)
self.stream.start_file_logging(self.args.test_result_debuglog,
self.args.test_result_loglevel)
self.json = {'debuglog': self.args.test_result_debuglog,
self.json = {'debuglog': self.stream.debuglog,
'tests': []}
def end_test(self, test):
......@@ -62,7 +60,6 @@ class JSONTestResult(TestResult):
Called once after all tests are executed.
"""
TestResult.end_tests(self)
self.stream.stop_file_logging()
self.json.update({
'total': self.tests_total,
'pass': len(self.passed),
......
......@@ -78,7 +78,7 @@ class VMTestRunner(TestRunner):
if not status.mapping[test.status]:
failures.append(test.tagged_name)
self.result.end_tests()
local_log_dir = os.path.dirname(self.result.args.test_result_debuglog)
local_log_dir = os.path.dirname(self.result.stream.debuglog)
zip_filename = os.path.basename(remote_log_dir) + '.zip'
zip_path_filename = os.path.join(local_log_dir, zip_filename)
self.result.vm.remote.receive_files(local_log_dir, zip_filename)
......@@ -172,7 +172,7 @@ class VMTestResult(TestResult):
self.stream.log_header("TOTAL SKIPPED: %d" % len(self.skipped))
self.stream.log_header("TOTAL WARNED: %d" % len(self.warned))
self.stream.log_header("ELAPSED TIME: %.2f s" % self.total_time)
self.stream.log_header("DEBUG LOG: %s" % self.args.test_result_debuglog)
self.stream.log_header("DEBUG LOG: %s" % self.stream.debuglog)
def start_test(self, test):
"""
......
......@@ -138,10 +138,7 @@ class HumanTestResult(TestResult):
Called once before any tests are executed.
"""
TestResult.start_tests(self)
if hasattr(self.args, 'test_result_debuglog'):
self.stream.start_file_logging(self.args.test_result_debuglog,
self.args.test_result_loglevel)
self.stream.log_header("DEBUG LOG: %s" % self.args.test_result_debuglog)
self.stream.log_header("DEBUG LOG: %s" % self.stream.debuglog)
self.stream.log_header("TOTAL TESTS: %s" % self.tests_total)
def end_tests(self):
......@@ -154,8 +151,6 @@ class HumanTestResult(TestResult):
self.stream.log_header("TOTAL SKIPPED: %d" % len(self.skipped))
self.stream.log_header("TOTAL WARNED: %d" % len(self.warned))
self.stream.log_header("ELAPSED TIME: %.2f s" % self.total_time)
if hasattr(self.args, 'test_result_debuglog'):
self.stream.stop_file_logging()
def start_test(self, test):
"""
......
......@@ -47,10 +47,9 @@ class JSONResultTest(unittest.TestCase):
def setUp(self):
self.tmpfile = mkstemp()
args = argparse.Namespace(json_output=self.tmpfile[1],
test_result_debuglog='debuglog',
test_result_loglevel='loglevel')
args = argparse.Namespace(json_output=self.tmpfile[1])
stream = _Stream()
stream.debuglog = 'debuglog'
self.test_result = jsonresult.JSONTestResult(stream, args)
self.test_result.filename = self.tmpfile[1]
self.test_result.start_tests()
......
......@@ -48,9 +48,9 @@ class _Stream(object):
class VMResultTest(unittest.TestCase):
def setUp(self):
args = argparse.Namespace(test_result_debuglog='debuglog',
test_result_loglevel='loglevel')
args = argparse.Namespace()
stream = _Stream()
stream.debuglog = 'debuglog'
self.test_result = vm.VMTestResult(stream, args)
j = '''{"tests": [{"test": "sleeptest.1", "url": "sleeptest", "status": "PASS", "time": 1.23}],
"debuglog": "/home/user/avocado/logs/run-2014-05-26-15.45.37/debug.log",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册