From 243ddd45600a6820a90ca6a29c837e9b1bd0d2e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rud=C3=A1=20Moura?= Date: Wed, 10 Jun 2015 18:45:44 -0300 Subject: [PATCH] avocado.core.remote.runner: When setup/teardown fails, exit gently. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When setup() or tear_down() fails, Avocado will provide a gentle error message and a proper exit code and put the traceback in the test log. ./scripts/avocado run --remote-host nowhereland passtest LOGIN : rmoura@nowhereland:22 Avocado job failed: JobError: Name lookup failed for nowhereland Prior to this commit, when setup or tear_down failed, Avocado dumps the traceback and prints that it crashed, which can potentially confuses the user. Signed-off-by: Rudá Moura --- avocado/core/remote/runner.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/avocado/core/remote/runner.py b/avocado/core/remote/runner.py index 0d0fd3b2..4e9ded32 100644 --- a/avocado/core/remote/runner.py +++ b/avocado/core/remote/runner.py @@ -13,6 +13,7 @@ # Author: Ruda Moura """Remote test runner.""" +import sys import json import os import re @@ -22,6 +23,7 @@ from avocado.core import status from avocado.core.runner import TestRunner from avocado.core.remote.test import RemoteTest from avocado.utils import archive +from avocado.utils import stacktrace from fabric.exceptions import CommandTimeout @@ -126,7 +128,11 @@ class RemoteTestRunner(TestRunner): if not timeout: # avoid timeout = 0 timeout = None failures = [] - self.result.setup() + try: + self.result.setup() + except Exception, details: + stacktrace.log_exc_info(sys.exc_info(), logger='avocado.test') + raise exceptions.JobError(details) results = self.run_test(self.result.urls, timeout) remote_log_dir = os.path.dirname(results['debuglog']) self.result.start_tests() @@ -152,5 +158,9 @@ class RemoteTestRunner(TestRunner): archive.uncompress(zip_path_filename, local_log_dir) os.remove(zip_path_filename) self.result.end_tests() - self.result.tear_down() + try: + self.result.tear_down() + except Exception, details: + stacktrace.log_exc_info(sys.exc_info(), logger='avocado.test') + raise exceptions.JobError(details) return failures -- GitLab