diff --git a/avocado/core/runner.py b/avocado/core/runner.py index 801dfdb1ca565ce6c2084f795d0d65fbafb7c464..ccb374935055e43d06a03b6d7dc40405af53e726 100644 --- a/avocado/core/runner.py +++ b/avocado/core/runner.py @@ -28,6 +28,7 @@ import time from . import test from . import exceptions from . import output +from . import status from .loader import loader from .status import mapping from ..utils import wait @@ -394,6 +395,17 @@ class TestRunner(object): if ctrl_c_count > 0: self.job.log.debug('') + # Make sure the test status is correct + if test_state.get('status') not in status.user_facing_status: + test_state['fail_reason'] = ("Test reports unsupported test " + "status %s.\nOriginal fail_reason: %s" + "\nOriginal fail_class: %s" + % (test_state.get('status'), + test_state.get('fail_reason'), + test_state.get('fail_class'))) + test_state['fail_class'] = "RUNNER" + test_state['status'] = 'ERROR' + self.result.check_test(test_state) if test_state['status'] == "INTERRUPTED": summary.add("INTERRUPTED") diff --git a/selftests/functional/test_basic.py b/selftests/functional/test_basic.py index 3ac8257d17fa25f199bbd1e239a973e29ca1ad4d..6d139a06ba620fb7862854b045837c9c0e78477c 100644 --- a/selftests/functional/test_basic.py +++ b/selftests/functional/test_basic.py @@ -50,6 +50,18 @@ class LocalImportTest(Test): self.log.info(hello()) ''' +UNSUPPORTED_STATUS_TEST_CONTENTS = ''' +from avocado import Test + +class FakeStatusTest(Test): + def run_avocado(self): + super(FakeStatusTest, self).run_avocado() + self.status = 'not supported' + + def test(self): + pass +''' + class RunnerOperationTest(unittest.TestCase): @@ -134,6 +146,22 @@ class RunnerOperationTest(unittest.TestCase): "%s" % (self.tmpdir, mytest)) process.run(cmd_line) + def test_unsupported_status(self): + os.chdir(basedir) + with script.TemporaryScript("fake_status.py", + UNSUPPORTED_STATUS_TEST_CONTENTS, + "avocado_unsupported_status") as tst: + res = process.run("./scripts/avocado run --sysinfo=off " + "--job-results-dir %s %s --json -" + % (self.tmpdir, tst), ignore_status=True) + self.assertEqual(res.exit_status, exit_codes.AVOCADO_TESTS_FAIL) + results = json.loads(res.stdout) + self.assertEqual(results["tests"][0]["status"], "ERROR", + "%s != %s\n%s" % (results["tests"][0]["status"], + "ERROR", res)) + self.assertIn("Original fail_reason: None", + results["tests"][0]["fail_reason"]) + def test_runner_tests_fail(self): os.chdir(basedir) cmd_line = './scripts/avocado run --sysinfo=off --job-results-dir %s passtest failtest passtest' % self.tmpdir