From ac776472205690423cb00f94723684c570ced287 Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Wed, 20 Mar 2019 11:39:27 -0400 Subject: [PATCH] Test: report state on each phase The test can be asked to report its state, or it can do it itself. Given that the test knows when it enters each phase, let's ask it to report it. Because the *state* is now reported, it's possible for a test to finish (for instance by killing itself) without setting a valid (user visible) status, such as "PASS", "FAIL", etc. Signed-off-by: Cleber Rosa --- avocado/core/test.py | 3 +++ selftests/functional/test_basic.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/avocado/core/test.py b/avocado/core/test.py index 2baa808f..03a4d8a2 100644 --- a/avocado/core/test.py +++ b/avocado/core/test.py @@ -830,6 +830,7 @@ class Test(unittest.TestCase, TestData): try: if skip_test is False: self.__phase = 'SETUP' + self.report_state() self.setUp() except exceptions.TestSkipError as details: skip_test = True @@ -845,6 +846,7 @@ class Test(unittest.TestCase, TestData): else: try: self.__phase = 'TEST' + self.report_state() testMethod() except exceptions.TestCancel as details: stacktrace.log_exc_info(sys.exc_info(), logger=LOG_JOB) @@ -863,6 +865,7 @@ class Test(unittest.TestCase, TestData): try: if skip_test is False: self.__phase = 'TEARDOWN' + self.report_state() self.tearDown() except exceptions.TestSkipError as details: stacktrace.log_exc_info(sys.exc_info(), logger=LOG_JOB) diff --git a/selftests/functional/test_basic.py b/selftests/functional/test_basic.py index 4f372889..b4cdebe5 100644 --- a/selftests/functional/test_basic.py +++ b/selftests/functional/test_basic.py @@ -306,7 +306,9 @@ class RunnerOperationTest(unittest.TestCase): self.assertEqual(results["tests"][0]["status"], "ERROR", "%s != %s\n%s" % (results["tests"][0]["status"], "ERROR", res)) - self.assertIn("Test died without reporting the status", + self.assertIn("Test reports unsupported test status", + results["tests"][0]["fail_reason"]) + self.assertIn("status: None", results["tests"][0]["fail_reason"]) def test_runner_tests_fail(self): -- GitLab