提交 4ac908d0 编写于 作者: A Amador Pahim

fix output on unknown tests

When the tests references cannot be resolved to a test_suite, the
results plugins should not output anything.

Reference: https://trello.com/c/oMQsQHC6Signed-off-by: NAmador Pahim <apahim@redhat.com>
上级 9df6d22c
......@@ -74,6 +74,9 @@ class JSONResult(Result):
hasattr(job.args, 'json_output')):
return
if not result.tests_total:
return
content = self._render(result)
if getattr(job.args, 'json_job_result', 'off') == 'on':
json_path = os.path.join(job.logdir, 'results.json')
......
......@@ -111,6 +111,9 @@ class XUnitResult(Result):
hasattr(job.args, 'xunit_output')):
return
if not result.tests_total:
return
content = self._render(result)
if getattr(job.args, 'xunit_job_result', 'off') == 'on':
xunit_path = os.path.join(job.logdir, 'results.xml')
......
......@@ -459,6 +459,22 @@ class OutputPluginTest(unittest.TestCase):
self.assertIn("not found", result.stderr)
self.assertNotIn("Avocado crashed", result.stderr)
def test_results_plugins_no_tests(self):
os.chdir(basedir)
cmd_line = ("%s run UNEXISTING --job-results-dir %s"
% (AVOCADO, self.tmpdir))
exit_code = process.system(cmd_line, ignore_status=True)
self.assertEqual(exit_code, exit_codes.AVOCADO_JOB_FAIL)
xunit_results = os.path.join(self.tmpdir, 'latest', 'results.xml')
self.assertFalse(os.path.exists(xunit_results))
json_results = os.path.join(self.tmpdir, 'latest', 'results.json')
self.assertFalse(os.path.exists(json_results))
tap_results = os.path.join(self.tmpdir, 'latest', 'results.tap')
self.assertFalse(os.path.exists(tap_results))
def tearDown(self):
shutil.rmtree(self.tmpdir)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册