提交 1ac34e5a 编写于 作者: C Cleber Rosa

Human plugin: only print job results when job is successful

The UI was showing information about the job, no matter if the job got
to run tests.

Even though the formal available statuses of a job are not too evolved
and documented, Avocado already sets a job status as "PASS" when it
finishes running the tests.  This involves most of the job phases.

Let's use that to check if the UI should print information about the
test results and job execution time.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 0c129cea
......@@ -94,11 +94,12 @@ class Human(ResultEvents):
def post_tests(self, job):
if not self.owns_stdout:
return
self.log.info("RESULTS : PASS %d | ERROR %d | FAIL %d | SKIP %d | "
"WARN %d | INTERRUPT %s | CANCEL %s", job.result.passed,
job.result.errors, job.result.failed, job.result.skipped,
job.result.warned, job.result.interrupted,
job.result.cancelled)
if job.status == 'PASS':
self.log.info("RESULTS : PASS %d | ERROR %d | FAIL %d | SKIP %d | "
"WARN %d | INTERRUPT %s | CANCEL %s", job.result.passed,
job.result.errors, job.result.failed, job.result.skipped,
job.result.warned, job.result.interrupted,
job.result.cancelled)
class HumanJob(JobPre, JobPost):
......@@ -114,7 +115,7 @@ class HumanJob(JobPre, JobPost):
pass
def post(self, job):
if job.time_elapsed != -1:
if job.status == 'PASS':
if not getattr(job.args, 'stdout_claimed_by', None):
log = logging.getLogger("avocado.app")
log.info("JOB TIME : %.2f s", job.time_elapsed)
......@@ -463,8 +463,8 @@ class OutputPluginTest(unittest.TestCase):
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)
result = process.run(cmd_line, ignore_status=True)
self.assertEqual(result.exit_status, exit_codes.AVOCADO_JOB_FAIL)
xunit_results = os.path.join(self.tmpdir, 'latest', 'results.xml')
self.assertFalse(os.path.exists(xunit_results))
......@@ -475,6 +475,10 @@ class OutputPluginTest(unittest.TestCase):
tap_results = os.path.join(self.tmpdir, 'latest', 'results.tap')
self.assertFalse(os.path.exists(tap_results))
# Check that no UI output was generated
self.assertNotIn("RESULTS : PASS ", result.stdout)
self.assertNotIn("JOB TIME :", result.stdout)
def tearDown(self):
shutil.rmtree(self.tmpdir)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册